Skip to content

Instantly share code, notes, and snippets.

@NathanHowell
Created October 31, 2014 08:16
Show Gist options
  • Select an option

  • Save NathanHowell/938a781b8f1819b85750 to your computer and use it in GitHub Desktop.

Select an option

Save NathanHowell/938a781b8f1819b85750 to your computer and use it in GitHub Desktop.
foo :: Int -> Int
foo x | x > 0 = x -1
foo x | otherwise = 0
; ModuleID = '<stdin>'
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-apple-darwin10.0.0"
%__stginit_Blah_struct = type <{}>
%Blah_foo1_closure_struct = type <{ i64, i64 }>
%Blah_foo_closure_struct = type <{ i64 }>
%Blah_foo_entry_struct = type <{ i64, i64, i64 }>
%c122_entry_struct = type <{ i64, i64 }>
@__stginit_Blah = global %__stginit_Blah_struct zeroinitializer
@Blah_foo1_closure = global %Blah_foo1_closure_struct <{ i64 ptrtoint (i8* @ghczmprim_GHCziTypes_Izh_static_info to i64), i64 0 }>
@Blah_foo_closure = global %Blah_foo_closure_struct <{ i64 ptrtoint (void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)* @Blah_foo_info to i64) }>
@Blah_foo_info_itable = constant %Blah_foo_entry_struct <{ i64 4294967301, i64 0, i64 15 }>, section "X98A__STRIP,__me1", align 8
@c122_info_itable = internal constant %c122_entry_struct <{ i64 0, i64 32 }>, section "X98A__STRIP,__me3", align 8
@ghczmprim_GHCziTypes_Izh_static_info = external global i8
@stg_gc_unpt_r1 = external global i8
@ghczmprim_GHCziTypes_Izh_con_info = external global i8
@llvm.used = appending constant [1 x i8*] [i8* bitcast (%c122_entry_struct* @c122_info_itable to i8*)], section "llvm.metadata"
define cc10 void @Blah_foo_info(i64* noalias nocapture %Base_Arg, i64* noalias nocapture %Sp_Arg, i64* noalias nocapture %Hp_Arg, i64 %R1_Arg, i64 %R2_Arg, i64 %R3_Arg, i64 %R4_Arg, i64 %R5_Arg, i64 %R6_Arg, i64 %SpLim_Arg) nounwind section "X98A__STRIP,__me2" align 8 {
c125:
%ln12v = getelementptr inbounds i64* %Sp_Arg, i64 -1
%ln12w = ptrtoint i64* %ln12v to i64
%ln12x = icmp ult i64 %ln12w, %SpLim_Arg
br i1 %ln12x, label %c12r, label %c12s
c12s: ; preds = %c125
store i64 ptrtoint (void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)* @c122_info to i64), i64* %ln12v, align 8, !tbaa !0
%ln12H = and i64 %R2_Arg, 7
%ln12I = icmp eq i64 %ln12H, 0
br i1 %ln12I, label %c123, label %u12t
c123: ; preds = %c12s
%ln12L = inttoptr i64 %R2_Arg to i64*
%ln12M = load i64* %ln12L, align 8, !tbaa !2
%ln12N = inttoptr i64 %ln12M to void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)*
tail call cc10 void %ln12N(i64* %Base_Arg, i64* %ln12v, i64* %Hp_Arg, i64 %R2_Arg, i64 undef, i64 undef, i64 undef, i64 undef, i64 undef, i64 %SpLim_Arg) nounwind
ret void
u12t: ; preds = %c12s
tail call cc10 void @c122_info(i64* %Base_Arg, i64* %ln12v, i64* %Hp_Arg, i64 %R2_Arg, i64 undef, i64 undef, i64 undef, i64 undef, i64 undef, i64 %SpLim_Arg) nounwind
ret void
c12r: ; preds = %c125
%ln12V = getelementptr inbounds i64* %Base_Arg, i64 -1
%ln12X = load i64* %ln12V, align 8, !tbaa !4
%ln12Y = inttoptr i64 %ln12X to void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)*
tail call cc10 void %ln12Y(i64* %Base_Arg, i64* %Sp_Arg, i64* %Hp_Arg, i64 ptrtoint (%Blah_foo_closure_struct* @Blah_foo_closure to i64), i64 %R2_Arg, i64 undef, i64 undef, i64 undef, i64 undef, i64 %SpLim_Arg) nounwind
ret void
}
define internal cc10 void @c122_info(i64* noalias nocapture %Base_Arg, i64* noalias nocapture %Sp_Arg, i64* noalias nocapture %Hp_Arg, i64 %R1_Arg, i64 %R2_Arg, i64 %R3_Arg, i64 %R4_Arg, i64 %R5_Arg, i64 %R6_Arg, i64 %SpLim_Arg) nounwind section "X98A__STRIP,__me4" align 8 {
c122:
%ln133 = getelementptr inbounds i64* %Hp_Arg, i64 2
%ln137 = ptrtoint i64* %ln133 to i64
%ln138 = getelementptr inbounds i64* %Base_Arg, i64 107
%ln13a = load i64* %ln138, align 8, !tbaa !4
%ln13b = icmp ugt i64 %ln137, %ln13a
br i1 %ln13b, label %c12q, label %c12p
c12p: ; preds = %c122
%ln13f = add i64 %R1_Arg, 7
%ln13g = inttoptr i64 %ln13f to i64*
%ln13h = load i64* %ln13g, align 8, !tbaa !2
%ln13j = icmp sgt i64 %ln13h, 0
br i1 %ln13j, label %c12m, label %c12n
c12n: ; preds = %c12p
%ln13r = getelementptr inbounds i64* %Sp_Arg, i64 1
%ln13x = load i64* %ln13r, align 8, !tbaa !0
%ln13y = inttoptr i64 %ln13x to void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)*
tail call cc10 void %ln13y(i64* %Base_Arg, i64* %ln13r, i64* %Hp_Arg, i64 add (i64 ptrtoint (%Blah_foo1_closure_struct* @Blah_foo1_closure to i64), i64 1), i64 undef, i64 undef, i64 undef, i64 undef, i64 undef, i64 %SpLim_Arg) nounwind
ret void
c12m: ; preds = %c12p
%ln13E = getelementptr inbounds i64* %Hp_Arg, i64 1
store i64 ptrtoint (i8* @ghczmprim_GHCziTypes_Izh_con_info to i64), i64* %ln13E, align 8, !tbaa !3
%ln13H = add i64 %ln13h, -1
store i64 %ln13H, i64* %ln133, align 8, !tbaa !3
%ln13M = add i64 %ln137, -7
%ln13O = getelementptr inbounds i64* %Sp_Arg, i64 1
%ln13U = load i64* %ln13O, align 8, !tbaa !0
%ln13V = inttoptr i64 %ln13U to void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)*
tail call cc10 void %ln13V(i64* %Base_Arg, i64* %ln13O, i64* %ln133, i64 %ln13M, i64 undef, i64 undef, i64 undef, i64 undef, i64 undef, i64 %SpLim_Arg) nounwind
ret void
c12q: ; preds = %c122
%ln13Z = getelementptr inbounds i64* %Base_Arg, i64 113
store i64 16, i64* %ln13Z, align 8, !tbaa !4
tail call cc10 void bitcast (i8* @stg_gc_unpt_r1 to void (i64*, i64*, i64*, i64, i64, i64, i64, i64, i64, i64)*)(i64* %Base_Arg, i64* %Sp_Arg, i64* %ln133, i64 %R1_Arg, i64 undef, i64 undef, i64 undef, i64 undef, i64 undef, i64 %SpLim_Arg) nounwind
ret void
}
!0 = metadata !{metadata !"stack", metadata !1}
!1 = metadata !{metadata !"top", i8* null}
!2 = metadata !{metadata !"rx", metadata !3}
!3 = metadata !{metadata !"heap", metadata !1}
!4 = metadata !{metadata !"base", metadata !1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment