brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.5 KiB · 6d37bd1 Raw
60 lines · plain
1; RUN: opt < %s -passes='deadargelim,function(dce)' -S > %t2; RUN: cat %t | not grep DEAD3; RUN: cat %t | grep LIVE | count 44 5@P = external global i32                ; <ptr> [#uses=1]6 7; Dead arg only used by dead retval8define internal i32 @test(i32 %DEADARG) {9        ret i32 %DEADARG10}11 12define internal i32 @test2(i32 %DEADARG) {13        %DEADRETVAL = call i32 @test( i32 %DEADARG )            ; <i32> [#uses=1]14        ret i32 %DEADRETVAL15}16 17define void @test3(i32 %X) {18        %DEADRETVAL = call i32 @test2( i32 %X )         ; <i32> [#uses=0]19        ret void20}21 22define internal i32 @foo() {23        %DEAD = load i32, ptr @P            ; <i32> [#uses=1]24        ret i32 %DEAD25}26 27define internal i32 @id(i32 %X) {28        ret i32 %X29}30 31define void @test4() {32        %DEAD = call i32 @foo( )                ; <i32> [#uses=1]33        %DEAD2 = call i32 @id( i32 %DEAD )              ; <i32> [#uses=0]34        ret void35}36 37; These test if returning another functions return value properly marks that38; other function's return value as live. We do this twice, with the functions in39; different orders (ie, first the caller, than the callee and first the callee40; and then the caller) since DAE processes functions one by one and handles41; these cases slightly different.42 43define internal i32 @test5() {44  ret i32 123 45}46 47define i32 @test6() {48  %LIVE = call i32 @test5()49  ret i32 %LIVE50}51 52define i32 @test7() {53  %LIVE = call i32 @test8()54  ret i32 %LIVE55}56 57define internal i32 @test8() {58  ret i32 12459}60