Advertisement
Guest User

opt-llvm

a guest
Apr 15th, 2015
269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.07 KB | None | 0 0
  1. ; ModuleID = 'full.ll'
  2. target triple = "unknown-unknown-unknown"
  3.  
  4. %closure.1 = type { %thunk*, i8* (%thunk*, %thunk*)* }
  5. %thunk = type { i1, i8* }
  6. %thunk_inner = type { i8*, i8* (i8*)* }
  7.  
  8. @add_null = private constant %closure.1 { %thunk* null, i8* (%thunk*, %thunk*)* @add_closure }
  9. @add = linkonce_odr constant %thunk { i1 true, i8* bitcast (%closure.1* @add_null to i8*) }
  10.  
  11. ; Function Attrs: nounwind
  12. declare noalias i8* @malloc(i32) #0
  13.  
  14. define private noalias i8* @add_ptr(%thunk* nocapture %.1, %thunk* nocapture %.2) {
  15. .3:
  16. %t.i = load %thunk* %.1
  17. %evald.i = extractvalue %thunk %t.i, 0
  18. %val.i = extractvalue %thunk %t.i, 1
  19. br i1 %evald.i, label %eval_thunk.exit, label %evaluate.i
  20.  
  21. evaluate.i: ; preds = %.3
  22. %tin_cast.i = bitcast i8* %val.i to %thunk_inner*
  23. %tin.i = load %thunk_inner* %tin_cast.i
  24. %env.i = extractvalue %thunk_inner %tin.i, 0
  25. %fun.i = extractvalue %thunk_inner %tin.i, 1
  26. %res.i = tail call i8* %fun.i(i8* %env.i)
  27. %t_new.i = insertvalue %thunk { i1 true, i8* null }, i8* %res.i, 1
  28. store %thunk %t_new.i, %thunk* %.1
  29. br label %eval_thunk.exit
  30.  
  31. eval_thunk.exit: ; preds = %.3, %evaluate.i
  32. %.41 = phi i8* [ %res.i, %evaluate.i ], [ %val.i, %.3 ]
  33. %.5 = bitcast i8* %.41 to i32*
  34. %.6 = load i32* %.5
  35. %t.i2 = load %thunk* %.2
  36. %evald.i3 = extractvalue %thunk %t.i2, 0
  37. %val.i4 = extractvalue %thunk %t.i2, 1
  38. br i1 %evald.i3, label %eval_thunk.exit13, label %evaluate.i11
  39.  
  40. evaluate.i11: ; preds = %eval_thunk.exit
  41. %tin_cast.i5 = bitcast i8* %val.i4 to %thunk_inner*
  42. %tin.i6 = load %thunk_inner* %tin_cast.i5
  43. %env.i7 = extractvalue %thunk_inner %tin.i6, 0
  44. %fun.i8 = extractvalue %thunk_inner %tin.i6, 1
  45. %res.i9 = tail call i8* %fun.i8(i8* %env.i7)
  46. %t_new.i10 = insertvalue %thunk { i1 true, i8* null }, i8* %res.i9, 1
  47. store %thunk %t_new.i10, %thunk* %.2
  48. br label %eval_thunk.exit13
  49.  
  50. eval_thunk.exit13: ; preds = %eval_thunk.exit, %evaluate.i11
  51. %.714 = phi i8* [ %res.i9, %evaluate.i11 ], [ %val.i4, %eval_thunk.exit ]
  52. %.8 = bitcast i8* %.714 to i32*
  53. %.9 = load i32* %.8
  54. %res.i15 = add i32 %.9, %.6
  55. %res_ptr = tail call i8* @malloc(i32 4)
  56. %res_cast = bitcast i8* %res_ptr to i32*
  57. store i32 %res.i15, i32* %res_cast
  58. ret i8* %res_ptr
  59. }
  60.  
  61. ; Function Attrs: nounwind
  62. define linkonce_odr noalias i8* @add_closure(%thunk* nocapture readnone %env_null, %thunk* %arg) #0 {
  63. .3:
  64. %c1.i = insertvalue %closure.1 zeroinitializer, %thunk* %arg, 0
  65. %c2.i = insertvalue %closure.1 %c1.i, i8* (%thunk*, %thunk*)* @add_ptr, 1
  66. %c_ptr.i = tail call i8* @malloc(i32 16) #0
  67. %c_cast.i = bitcast i8* %c_ptr.i to %closure.1*
  68. store %closure.1 %c2.i, %closure.1* %c_cast.i
  69. ret i8* %c_ptr.i
  70. }
  71.  
  72. define i32 @main() {
  73. eval_thunk.exit:
  74. %env_pass_ptr = tail call i8* @malloc(i32 8)
  75. %env_pass_cast = bitcast i8* %env_pass_ptr to [1 x %thunk*]*
  76. store [1 x %thunk*] [%thunk* @add], [1 x %thunk*]* %env_pass_cast
  77. %0 = getelementptr inbounds [1 x %thunk*]* %env_pass_cast, i32 0, i32 0
  78. %1 = load %thunk** %0
  79. %env_pass.i = insertvalue [1 x %thunk*] zeroinitializer, %thunk* %1, 0
  80. %env_pass_ptr.i = tail call i8* @malloc(i32 8)
  81. %env_pass_cast.i = bitcast i8* %env_pass_ptr.i to [1 x %thunk*]*
  82. store [1 x %thunk*] %env_pass.i, [1 x %thunk*]* %env_pass_cast.i
  83. %ti1.i = insertvalue %thunk_inner zeroinitializer, i8* %env_pass_ptr.i, 0
  84. %ti2.i = insertvalue %thunk_inner %ti1.i, i8* (i8*)* @.2, 1
  85. %ti_ptr.i = tail call i8* @malloc(i32 16) #0
  86. %ti_cast.i = bitcast i8* %ti_ptr.i to %thunk_inner*
  87. store %thunk_inner %ti2.i, %thunk_inner* %ti_cast.i
  88. %num.i = tail call i8* @malloc(i32 4)
  89. %num32.i = bitcast i8* %num.i to i32*
  90. store i32 20, i32* %num32.i
  91. %t.i4 = insertvalue %thunk { i1 true, i8* null }, i8* %num.i, 1
  92. %t_ptr.i5 = tail call i8* @malloc(i32 16)
  93. %t_cast.i6 = bitcast i8* %t_ptr.i5 to %thunk*
  94. store %thunk %t.i4, %thunk* %t_cast.i6
  95. %tin_cast.i = bitcast i8* %ti_ptr.i to %thunk_inner*
  96. %tin.i = load %thunk_inner* %tin_cast.i
  97. %env.i8 = extractvalue %thunk_inner %tin.i, 0
  98. %fun.i9 = extractvalue %thunk_inner %tin.i, 1
  99. %res.i10 = tail call i8* %fun.i9(i8* %env.i8)
  100. %c_cast.i = bitcast i8* %res.i10 to %closure.1*
  101. %c.i = load %closure.1* %c_cast.i
  102. %env.i = extractvalue %closure.1 %c.i, 0
  103. %fun.i = extractvalue %closure.1 %c.i, 1
  104. %res.i = tail call i8* %fun.i(%thunk* %env.i, %thunk* %t_cast.i6)
  105. %res_cast = bitcast i8* %res.i to i32*
  106. %res = load i32* %res_cast
  107. ret i32 %res
  108. }
  109.  
  110. define private i8* @.2(i8* nocapture readonly %env) {
  111. .3:
  112. %env_ptr = bitcast i8* %env to [1 x %thunk*]*
  113. %0 = getelementptr inbounds [1 x %thunk*]* %env_ptr, i32 0, i32 0
  114. %1 = load %thunk** %0
  115. %num = tail call i8* @malloc(i32 4)
  116. %num32 = bitcast i8* %num to i32*
  117. store i32 10, i32* %num32
  118. %t.i = insertvalue %thunk { i1 true, i8* null }, i8* %num, 1
  119. %t_ptr.i = tail call i8* @malloc(i32 16) #0
  120. %t_cast.i = bitcast i8* %t_ptr.i to %thunk*
  121. store %thunk %t.i, %thunk* %t_cast.i
  122. %t.i1 = load %thunk* %1
  123. %evald.i = extractvalue %thunk %t.i1, 0
  124. %val.i = extractvalue %thunk %t.i1, 1
  125. br i1 %evald.i, label %eval_thunk.exit, label %evaluate.i
  126.  
  127. evaluate.i: ; preds = %.3
  128. %tin_cast.i = bitcast i8* %val.i to %thunk_inner*
  129. %tin.i = load %thunk_inner* %tin_cast.i
  130. %env.i = extractvalue %thunk_inner %tin.i, 0
  131. %fun.i = extractvalue %thunk_inner %tin.i, 1
  132. %res.i = tail call i8* %fun.i(i8* %env.i)
  133. %t_new.i = insertvalue %thunk { i1 true, i8* null }, i8* %res.i, 1
  134. store %thunk %t_new.i, %thunk* %1
  135. br label %eval_thunk.exit
  136.  
  137. eval_thunk.exit: ; preds = %.3, %evaluate.i
  138. %operator2 = phi i8* [ %res.i, %evaluate.i ], [ %val.i, %.3 ]
  139. %c_cast.i = bitcast i8* %operator2 to %closure.1*
  140. %c.i = load %closure.1* %c_cast.i
  141. %env.i3 = extractvalue %closure.1 %c.i, 0
  142. %fun.i4 = extractvalue %closure.1 %c.i, 1
  143. %res.i5 = tail call i8* %fun.i4(%thunk* %env.i3, %thunk* %t_cast.i)
  144. ret i8* %res.i5
  145. }
  146.  
  147. attributes #0 = { nounwind }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement