xref: /aosp_15_r20/external/llvm/test/Transforms/DeadArgElim/2008-06-23-DeadAfterLive.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -deadargelim -die -S > %t
2*9880d681SAndroid Build Coastguard Worker; RUN: cat %t | grep 123
3*9880d681SAndroid Build Coastguard Worker
4*9880d681SAndroid Build Coastguard Worker; This test tries to catch wrongful removal of return values for a specific case
5*9880d681SAndroid Build Coastguard Worker; that was breaking llvm-gcc builds.
6*9880d681SAndroid Build Coastguard Worker
7*9880d681SAndroid Build Coastguard Worker; This function has a live return value, it is used by @alive.
8*9880d681SAndroid Build Coastguard Workerdefine internal i32 @test5() {
9*9880d681SAndroid Build Coastguard Worker  ret i32 123
10*9880d681SAndroid Build Coastguard Worker}
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Worker; This function doesn't use the return value @test5 and tries to lure DAE into
13*9880d681SAndroid Build Coastguard Worker; marking @test5's return value dead because only this call is unused.
14*9880d681SAndroid Build Coastguard Workerdefine i32 @dead() {
15*9880d681SAndroid Build Coastguard Worker  %DEAD = call i32 @test5()
16*9880d681SAndroid Build Coastguard Worker  ret i32 0
17*9880d681SAndroid Build Coastguard Worker}
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker; This function ensures the retval of @test5 is live.
20*9880d681SAndroid Build Coastguard Workerdefine i32 @alive() {
21*9880d681SAndroid Build Coastguard Worker  %LIVE = call i32 @test5()
22*9880d681SAndroid Build Coastguard Worker  ret i32 %LIVE
23*9880d681SAndroid Build Coastguard Worker}
24