keepalive.ll 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ; RUN: opt < %s -deadargelim -S | FileCheck %s
  2. %Ty = type <{ i32, i32 }>
  3. ; Check if the pass doesn't modify anything that doesn't need changing. We feed
  4. ; an unused argument to each function to lure it into changing _something_ about
  5. ; the function and then changing too much.
  6. ; This checks if the return value attributes are not removed
  7. ; CHECK: define internal zeroext i32 @test1() #0
  8. define internal zeroext i32 @test1(i32 %DEADARG1) nounwind {
  9. ret i32 1
  10. }
  11. ; This checks if the struct doesn't get non-packed
  12. ; CHECK-LABEL: define internal <{ i32, i32 }> @test2(
  13. define internal <{ i32, i32 }> @test2(i32 %DEADARG1) {
  14. ret <{ i32, i32 }> <{ i32 1, i32 2 }>
  15. }
  16. ; We use this external function to make sure the return values don't become dead
  17. declare void @user(i32, <{ i32, i32 }>)
  18. define void @caller() {
  19. %B = call i32 @test1(i32 1)
  20. %C = call <{ i32, i32 }> @test2(i32 2)
  21. call void @user(i32 %B, <{ i32, i32 }> %C)
  22. ret void
  23. }
  24. ; We can't remove 'this' here, as that would put argmem in ecx instead of
  25. ; memory.
  26. define internal x86_thiscallcc i32 @unused_this(i32* %this, i32* inalloca %argmem) {
  27. %v = load i32, i32* %argmem
  28. ret i32 %v
  29. }
  30. ; CHECK-LABEL: define internal x86_thiscallcc i32 @unused_this(i32* %this, i32* inalloca %argmem)
  31. define i32 @caller2() {
  32. %t = alloca i32
  33. %m = alloca inalloca i32
  34. store i32 42, i32* %m
  35. %v = call x86_thiscallcc i32 @unused_this(i32* %t, i32* inalloca %m)
  36. ret i32 %v
  37. }
  38. ; CHECK: attributes #0 = { nounwind }