Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; ModuleID = 'full.ll'
- target triple = "unknown-unknown-unknown"
- %closure.1 = type { %thunk*, i8* (%thunk*, %thunk*)* }
- %thunk = type { i1, i8* }
- %thunk_inner = type { i8*, i8* (i8*)* }
- @add_null = private constant %closure.1 { %thunk* null, i8* (%thunk*, %thunk*)* @add_closure }
- @add = linkonce_odr constant %thunk { i1 true, i8* bitcast (%closure.1* @add_null to i8*) }
- ; Function Attrs: nounwind
- declare noalias i8* @malloc(i32) #0
- define private noalias i8* @add_ptr(%thunk* nocapture %.1, %thunk* nocapture %.2) {
- .3:
- %t.i = load %thunk* %.1
- %evald.i = extractvalue %thunk %t.i, 0
- %val.i = extractvalue %thunk %t.i, 1
- br i1 %evald.i, label %eval_thunk.exit, label %evaluate.i
- evaluate.i: ; preds = %.3
- %tin_cast.i = bitcast i8* %val.i to %thunk_inner*
- %tin.i = load %thunk_inner* %tin_cast.i
- %env.i = extractvalue %thunk_inner %tin.i, 0
- %fun.i = extractvalue %thunk_inner %tin.i, 1
- %res.i = tail call i8* %fun.i(i8* %env.i)
- %t_new.i = insertvalue %thunk { i1 true, i8* null }, i8* %res.i, 1
- store %thunk %t_new.i, %thunk* %.1
- br label %eval_thunk.exit
- eval_thunk.exit: ; preds = %.3, %evaluate.i
- %.41 = phi i8* [ %res.i, %evaluate.i ], [ %val.i, %.3 ]
- %.5 = bitcast i8* %.41 to i32*
- %.6 = load i32* %.5
- %t.i2 = load %thunk* %.2
- %evald.i3 = extractvalue %thunk %t.i2, 0
- %val.i4 = extractvalue %thunk %t.i2, 1
- br i1 %evald.i3, label %eval_thunk.exit13, label %evaluate.i11
- evaluate.i11: ; preds = %eval_thunk.exit
- %tin_cast.i5 = bitcast i8* %val.i4 to %thunk_inner*
- %tin.i6 = load %thunk_inner* %tin_cast.i5
- %env.i7 = extractvalue %thunk_inner %tin.i6, 0
- %fun.i8 = extractvalue %thunk_inner %tin.i6, 1
- %res.i9 = tail call i8* %fun.i8(i8* %env.i7)
- %t_new.i10 = insertvalue %thunk { i1 true, i8* null }, i8* %res.i9, 1
- store %thunk %t_new.i10, %thunk* %.2
- br label %eval_thunk.exit13
- eval_thunk.exit13: ; preds = %eval_thunk.exit, %evaluate.i11
- %.714 = phi i8* [ %res.i9, %evaluate.i11 ], [ %val.i4, %eval_thunk.exit ]
- %.8 = bitcast i8* %.714 to i32*
- %.9 = load i32* %.8
- %res.i15 = add i32 %.9, %.6
- %res_ptr = tail call i8* @malloc(i32 4)
- %res_cast = bitcast i8* %res_ptr to i32*
- store i32 %res.i15, i32* %res_cast
- ret i8* %res_ptr
- }
- ; Function Attrs: nounwind
- define linkonce_odr noalias i8* @add_closure(%thunk* nocapture readnone %env_null, %thunk* %arg) #0 {
- .3:
- %c1.i = insertvalue %closure.1 zeroinitializer, %thunk* %arg, 0
- %c2.i = insertvalue %closure.1 %c1.i, i8* (%thunk*, %thunk*)* @add_ptr, 1
- %c_ptr.i = tail call i8* @malloc(i32 16) #0
- %c_cast.i = bitcast i8* %c_ptr.i to %closure.1*
- store %closure.1 %c2.i, %closure.1* %c_cast.i
- ret i8* %c_ptr.i
- }
- define i32 @main() {
- eval_thunk.exit:
- %env_pass_ptr = tail call i8* @malloc(i32 8)
- %env_pass_cast = bitcast i8* %env_pass_ptr to [1 x %thunk*]*
- store [1 x %thunk*] [%thunk* @add], [1 x %thunk*]* %env_pass_cast
- %0 = getelementptr inbounds [1 x %thunk*]* %env_pass_cast, i32 0, i32 0
- %1 = load %thunk** %0
- %env_pass.i = insertvalue [1 x %thunk*] zeroinitializer, %thunk* %1, 0
- %env_pass_ptr.i = tail call i8* @malloc(i32 8)
- %env_pass_cast.i = bitcast i8* %env_pass_ptr.i to [1 x %thunk*]*
- store [1 x %thunk*] %env_pass.i, [1 x %thunk*]* %env_pass_cast.i
- %ti1.i = insertvalue %thunk_inner zeroinitializer, i8* %env_pass_ptr.i, 0
- %ti2.i = insertvalue %thunk_inner %ti1.i, i8* (i8*)* @.2, 1
- %ti_ptr.i = tail call i8* @malloc(i32 16) #0
- %ti_cast.i = bitcast i8* %ti_ptr.i to %thunk_inner*
- store %thunk_inner %ti2.i, %thunk_inner* %ti_cast.i
- %num.i = tail call i8* @malloc(i32 4)
- %num32.i = bitcast i8* %num.i to i32*
- store i32 20, i32* %num32.i
- %t.i4 = insertvalue %thunk { i1 true, i8* null }, i8* %num.i, 1
- %t_ptr.i5 = tail call i8* @malloc(i32 16)
- %t_cast.i6 = bitcast i8* %t_ptr.i5 to %thunk*
- store %thunk %t.i4, %thunk* %t_cast.i6
- %tin_cast.i = bitcast i8* %ti_ptr.i to %thunk_inner*
- %tin.i = load %thunk_inner* %tin_cast.i
- %env.i8 = extractvalue %thunk_inner %tin.i, 0
- %fun.i9 = extractvalue %thunk_inner %tin.i, 1
- %res.i10 = tail call i8* %fun.i9(i8* %env.i8)
- %c_cast.i = bitcast i8* %res.i10 to %closure.1*
- %c.i = load %closure.1* %c_cast.i
- %env.i = extractvalue %closure.1 %c.i, 0
- %fun.i = extractvalue %closure.1 %c.i, 1
- %res.i = tail call i8* %fun.i(%thunk* %env.i, %thunk* %t_cast.i6)
- %res_cast = bitcast i8* %res.i to i32*
- %res = load i32* %res_cast
- ret i32 %res
- }
- define private i8* @.2(i8* nocapture readonly %env) {
- .3:
- %env_ptr = bitcast i8* %env to [1 x %thunk*]*
- %0 = getelementptr inbounds [1 x %thunk*]* %env_ptr, i32 0, i32 0
- %1 = load %thunk** %0
- %num = tail call i8* @malloc(i32 4)
- %num32 = bitcast i8* %num to i32*
- store i32 10, i32* %num32
- %t.i = insertvalue %thunk { i1 true, i8* null }, i8* %num, 1
- %t_ptr.i = tail call i8* @malloc(i32 16) #0
- %t_cast.i = bitcast i8* %t_ptr.i to %thunk*
- store %thunk %t.i, %thunk* %t_cast.i
- %t.i1 = load %thunk* %1
- %evald.i = extractvalue %thunk %t.i1, 0
- %val.i = extractvalue %thunk %t.i1, 1
- br i1 %evald.i, label %eval_thunk.exit, label %evaluate.i
- evaluate.i: ; preds = %.3
- %tin_cast.i = bitcast i8* %val.i to %thunk_inner*
- %tin.i = load %thunk_inner* %tin_cast.i
- %env.i = extractvalue %thunk_inner %tin.i, 0
- %fun.i = extractvalue %thunk_inner %tin.i, 1
- %res.i = tail call i8* %fun.i(i8* %env.i)
- %t_new.i = insertvalue %thunk { i1 true, i8* null }, i8* %res.i, 1
- store %thunk %t_new.i, %thunk* %1
- br label %eval_thunk.exit
- eval_thunk.exit: ; preds = %.3, %evaluate.i
- %operator2 = phi i8* [ %res.i, %evaluate.i ], [ %val.i, %.3 ]
- %c_cast.i = bitcast i8* %operator2 to %closure.1*
- %c.i = load %closure.1* %c_cast.i
- %env.i3 = extractvalue %closure.1 %c.i, 0
- %fun.i4 = extractvalue %closure.1 %c.i, 1
- %res.i5 = tail call i8* %fun.i4(%thunk* %env.i3, %thunk* %t_cast.i)
- ret i8* %res.i5
- }
- attributes #0 = { nounwind }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement