xref: /aosp_15_r20/external/llvm/test/Transforms/InstCombine/2004-01-13-InstCombineInvokePHI.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; Test for a problem afflicting several C++ programs in the testsuite.  The
2*9880d681SAndroid Build Coastguard Worker; instcombine pass is trying to get rid of the cast in the invoke instruction,
3*9880d681SAndroid Build Coastguard Worker; inserting a cast of the return value after the PHI instruction, but which is
4*9880d681SAndroid Build Coastguard Worker; used by the PHI instruction.  This is bad: because of the semantics of the
5*9880d681SAndroid Build Coastguard Worker; invoke instruction, we really cannot perform this transformation at all at
6*9880d681SAndroid Build Coastguard Worker; least without splitting the critical edge.
7*9880d681SAndroid Build Coastguard Worker;
8*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -instcombine -disable-output
9*9880d681SAndroid Build Coastguard Worker
10*9880d681SAndroid Build Coastguard Workerdeclare i8* @test()
11*9880d681SAndroid Build Coastguard Worker
12*9880d681SAndroid Build Coastguard Workerdefine i32 @foo() personality i32 (...)* @__gxx_personality_v0 {
13*9880d681SAndroid Build Coastguard Workerentry:
14*9880d681SAndroid Build Coastguard Worker        br i1 true, label %cont, label %call
15*9880d681SAndroid Build Coastguard Worker
16*9880d681SAndroid Build Coastguard Workercall:           ; preds = %entry
17*9880d681SAndroid Build Coastguard Worker        %P = invoke i32* bitcast (i8* ()* @test to i32* ()*)( )
18*9880d681SAndroid Build Coastguard Worker                        to label %cont unwind label %N          ; <i32*> [#uses=1]
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Workercont:           ; preds = %call, %entry
21*9880d681SAndroid Build Coastguard Worker        %P2 = phi i32* [ %P, %call ], [ null, %entry ]          ; <i32*> [#uses=1]
22*9880d681SAndroid Build Coastguard Worker        %V = load i32, i32* %P2              ; <i32> [#uses=1]
23*9880d681SAndroid Build Coastguard Worker        ret i32 %V
24*9880d681SAndroid Build Coastguard Worker
25*9880d681SAndroid Build Coastguard WorkerN:              ; preds = %call
26*9880d681SAndroid Build Coastguard Worker        %exn = landingpad {i8*, i32}
27*9880d681SAndroid Build Coastguard Worker                 cleanup
28*9880d681SAndroid Build Coastguard Worker        ret i32 0
29*9880d681SAndroid Build Coastguard Worker}
30*9880d681SAndroid Build Coastguard Worker
31*9880d681SAndroid Build Coastguard Workerdeclare i32 @__gxx_personality_v0(...)
32