deadretval2.ll 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. ; RUN: opt < %s -deadargelim -die -S > %t
  2. ; RUN: cat %t | not grep DEAD
  3. ; RUN: cat %t | grep LIVE | count 4
  4. @P = external global i32 ; <i32*> [#uses=1]
  5. ; Dead arg only used by dead retval
  6. define internal i32 @test(i32 %DEADARG) {
  7. ret i32 %DEADARG
  8. }
  9. define internal i32 @test2(i32 %DEADARG) {
  10. %DEADRETVAL = call i32 @test( i32 %DEADARG ) ; <i32> [#uses=1]
  11. ret i32 %DEADRETVAL
  12. }
  13. define void @test3(i32 %X) {
  14. %DEADRETVAL = call i32 @test2( i32 %X ) ; <i32> [#uses=0]
  15. ret void
  16. }
  17. define internal i32 @foo() {
  18. %DEAD = load i32, i32* @P ; <i32> [#uses=1]
  19. ret i32 %DEAD
  20. }
  21. define internal i32 @id(i32 %X) {
  22. ret i32 %X
  23. }
  24. define void @test4() {
  25. %DEAD = call i32 @foo( ) ; <i32> [#uses=1]
  26. %DEAD2 = call i32 @id( i32 %DEAD ) ; <i32> [#uses=0]
  27. ret void
  28. }
  29. ; These test if returning another functions return value properly marks that
  30. ; other function's return value as live. We do this twice, with the functions in
  31. ; different orders (ie, first the caller, than the callee and first the callee
  32. ; and then the caller) since DAE processes functions one by one and handles
  33. ; these cases slightly different.
  34. define internal i32 @test5() {
  35. ret i32 123
  36. }
  37. define i32 @test6() {
  38. %LIVE = call i32 @test5()
  39. ret i32 %LIVE
  40. }
  41. define i32 @test7() {
  42. %LIVE = call i32 @test8()
  43. ret i32 %LIVE
  44. }
  45. define internal i32 @test8() {
  46. ret i32 124
  47. }