diff --git a/llvm/test/Regression/Transforms/DeadArgElim/deadretval.ll b/llvm/test/Regression/Transforms/DeadArgElim/deadretval.ll new file mode 100644 index 000000000000..33b4bd7cb6be --- /dev/null +++ b/llvm/test/Regression/Transforms/DeadArgElim/deadretval.ll @@ -0,0 +1,19 @@ +; RUN: llvm-as < %s | opt -deadargelim | llvm-dis | not grep DEAD + +implementation + +internal int %test(int %DEADARG) { ; Dead arg only used by dead retval + ret int %DEADARG +} + +int %test2(int %A) { + %DEAD = call int %test(int %A) + ret int 123 +} + +int %test3() { + %X = call int %test2(int 3232) + %Y = add int %X, -123 + ret int %Y +} + diff --git a/llvm/test/Regression/Transforms/DeadArgElim/deadretval2.ll b/llvm/test/Regression/Transforms/DeadArgElim/deadretval2.ll new file mode 100644 index 000000000000..2596fa66fa2b --- /dev/null +++ b/llvm/test/Regression/Transforms/DeadArgElim/deadretval2.ll @@ -0,0 +1,36 @@ +; RUN: llvm-as < %s | opt -deadargelim -die | llvm-dis | not grep DEAD + +%P = external global int + +implementation + + +internal int %test(int %DEADARG) { ; Dead arg only used by dead retval + ret int %DEADARG +} + +internal int %test2(int %DEADARG) { + %DEADRETVAL = call int %test(int %DEADARG) + ret int %DEADRETVAL +} + +void %test3(int %X) { + %DEADRETVAL = call int %test2(int %X) + ret void +} + +internal int %foo() { + %DEAD = load int* %P + ret int %DEAD +} + +internal int %id(int %X) { + ret int %X +} + +void %test4() { + %DEAD = call int %foo() + %DEAD2 = call int %id(int %DEAD) + ret void +} +