2
0

byval-tail-call.ll 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. ; RUN: opt < %s -basicaa -tailcallelim -inline -instcombine -dse -S | FileCheck %s
  2. ; PR7272
  3. ; Calls that capture byval parameters cannot be marked as tail calls. Other
  4. ; tails that don't capture byval parameters can still be tail calls.
  5. target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32-n8:16:32"
  6. target triple = "i386-pc-linux-gnu"
  7. declare void @ext(i32*)
  8. define void @bar(i32* byval %x) {
  9. call void @ext(i32* %x)
  10. ret void
  11. }
  12. define void @foo(i32* %x) {
  13. ; CHECK-LABEL: define void @foo(
  14. ; CHECK: llvm.lifetime.start
  15. ; CHECK: store i32 %2, i32* %x
  16. call void @bar(i32* byval %x)
  17. ret void
  18. }
  19. define internal void @qux(i32* byval %x) {
  20. call void @ext(i32* %x)
  21. tail call void @ext(i32* null)
  22. ret void
  23. }
  24. define void @frob(i32* %x) {
  25. ; CHECK-LABEL: define void @frob(
  26. ; CHECK: %[[POS:.*]] = alloca i32
  27. ; CHECK: %[[VAL:.*]] = load i32, i32* %x
  28. ; CHECK: store i32 %[[VAL]], i32* %[[POS]]
  29. ; CHECK: {{^ *}}call void @ext(i32* nonnull %[[POS]]
  30. ; CHECK: tail call void @ext(i32* null)
  31. ; CHECK: ret void
  32. tail call void @qux(i32* byval %x)
  33. ret void
  34. }