nonnull.ll 923 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. ; RUN: opt -S -inline %s | FileCheck %s
  2. declare void @foo()
  3. declare void @bar()
  4. define void @callee(i8* %arg) {
  5. %cmp = icmp eq i8* %arg, null
  6. br i1 %cmp, label %expensive, label %done
  7. ; This block is designed to be too expensive to inline. We can only inline
  8. ; callee if this block is known to be dead.
  9. expensive:
  10. call void @foo()
  11. call void @foo()
  12. call void @foo()
  13. call void @foo()
  14. call void @foo()
  15. call void @foo()
  16. call void @foo()
  17. call void @foo()
  18. call void @foo()
  19. call void @foo()
  20. ret void
  21. done:
  22. call void @bar()
  23. ret void
  24. }
  25. ; Positive test - arg is known non null
  26. define void @caller(i8* nonnull %arg) {
  27. ; CHECK-LABEL: @caller
  28. ; CHECK: call void @bar()
  29. call void @callee(i8* nonnull %arg)
  30. ret void
  31. }
  32. ; Negative test - arg is not known to be non null
  33. define void @caller2(i8* %arg) {
  34. ; CHECK-LABEL: @caller2
  35. ; CHECK: call void @callee(
  36. call void @callee(i8* %arg)
  37. ret void
  38. }