optimization-remarks.ll 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. ; RUN: opt < %s -inline -pass-remarks=inline -pass-remarks-missed=inline -pass-remarks-analysis=inline -S 2>&1 | FileCheck %s
  2. ; CHECK: foo should always be inlined (cost=always)
  3. ; CHECK: foo inlined into bar
  4. ; CHECK: foz should never be inlined (cost=never)
  5. ; CHECK: foz will not be inlined into bar
  6. ; Function Attrs: alwaysinline nounwind uwtable
  7. define i32 @foo(i32 %x, i32 %y) #0 {
  8. entry:
  9. %x.addr = alloca i32, align 4
  10. %y.addr = alloca i32, align 4
  11. store i32 %x, i32* %x.addr, align 4
  12. store i32 %y, i32* %y.addr, align 4
  13. %0 = load i32, i32* %x.addr, align 4
  14. %1 = load i32, i32* %y.addr, align 4
  15. %add = add nsw i32 %0, %1
  16. ret i32 %add
  17. }
  18. ; Function Attrs: noinline nounwind uwtable
  19. define float @foz(i32 %x, i32 %y) #1 {
  20. entry:
  21. %x.addr = alloca i32, align 4
  22. %y.addr = alloca i32, align 4
  23. store i32 %x, i32* %x.addr, align 4
  24. store i32 %y, i32* %y.addr, align 4
  25. %0 = load i32, i32* %x.addr, align 4
  26. %1 = load i32, i32* %y.addr, align 4
  27. %mul = mul nsw i32 %0, %1
  28. %conv = sitofp i32 %mul to float
  29. ret float %conv
  30. }
  31. ; Function Attrs: nounwind uwtable
  32. define i32 @bar(i32 %j) #2 {
  33. entry:
  34. %j.addr = alloca i32, align 4
  35. store i32 %j, i32* %j.addr, align 4
  36. %0 = load i32, i32* %j.addr, align 4
  37. %1 = load i32, i32* %j.addr, align 4
  38. %sub = sub nsw i32 %1, 2
  39. %call = call i32 @foo(i32 %0, i32 %sub)
  40. %conv = sitofp i32 %call to float
  41. %2 = load i32, i32* %j.addr, align 4
  42. %sub1 = sub nsw i32 %2, 2
  43. %3 = load i32, i32* %j.addr, align 4
  44. %call2 = call float @foz(i32 %sub1, i32 %3)
  45. %mul = fmul float %conv, %call2
  46. %conv3 = fptosi float %mul to i32
  47. ret i32 %conv3
  48. }
  49. attributes #0 = { alwaysinline nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
  50. attributes #1 = { noinline nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
  51. attributes #2 = { nounwind uwtable "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
  52. !llvm.ident = !{!0}
  53. !0 = !{!"clang version 3.5.0 "}