inline-optnone.ll 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ; RUN: opt < %s -inline -S | FileCheck %s
  2. ; Test that functions with attribute optnone are not inlined.
  3. ; Also test that only functions with attribute alwaysinline are
  4. ; valid candidates for inlining if the caller has the optnone attribute.
  5. ; Function Attrs: alwaysinline nounwind readnone uwtable
  6. define i32 @alwaysInlineFunction(i32 %a) #0 {
  7. entry:
  8. %mul = mul i32 %a, %a
  9. ret i32 %mul
  10. }
  11. ; Function Attrs: nounwind readnone uwtable
  12. define i32 @simpleFunction(i32 %a) #1 {
  13. entry:
  14. %add = add i32 %a, %a
  15. ret i32 %add
  16. }
  17. ; Function Attrs: nounwind noinline optnone readnone uwtable
  18. define i32 @OptnoneFunction(i32 %a) #2 {
  19. entry:
  20. %0 = tail call i32 @alwaysInlineFunction(i32 %a)
  21. %1 = tail call i32 @simpleFunction(i32 %a)
  22. %add = add i32 %0, %1
  23. ret i32 %add
  24. }
  25. ; CHECK-LABEL: @OptnoneFunction
  26. ; CHECK-NOT: call i32 @alwaysInlineFunction(i32 %a)
  27. ; CHECK: call i32 @simpleFunction(i32 %a)
  28. ; CHECK: ret
  29. ; Function Attrs: nounwind readnone uwtable
  30. define i32 @bar(i32 %a) #1 {
  31. entry:
  32. %0 = tail call i32 @OptnoneFunction(i32 5)
  33. %1 = tail call i32 @simpleFunction(i32 6)
  34. %add = add i32 %0, %1
  35. ret i32 %add
  36. }
  37. ; CHECK-LABEL: @bar
  38. ; CHECK: call i32 @OptnoneFunction(i32 5)
  39. ; CHECK-NOT: call i32 @simpleFunction(i32 6)
  40. ; CHECK: ret
  41. attributes #0 = { alwaysinline nounwind readnone uwtable }
  42. attributes #1 = { nounwind readnone uwtable }
  43. attributes #2 = { nounwind noinline optnone readnone uwtable }