xref: /aosp_15_r20/external/llvm/test/Analysis/CFLAliasAnalysis/Steensgaard/multilevel-combine.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; This testcase ensures that CFL AA responds conservatively when we union
2*9880d681SAndroid Build Coastguard Worker; groups of pointers together through ternary/conditional operations
3*9880d681SAndroid Build Coastguard Worker; Derived from:
4*9880d681SAndroid Build Coastguard Worker; void foo(bool c) {
5*9880d681SAndroid Build Coastguard Worker;   char a, b;
6*9880d681SAndroid Build Coastguard Worker;   char *m = c ? &a : &b;
7*9880d681SAndroid Build Coastguard Worker;   *m;
8*9880d681SAndroid Build Coastguard Worker; }
9*9880d681SAndroid Build Coastguard Worker;
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -disable-basicaa -cfl-steens-aa -aa-eval -print-may-aliases -disable-output 2>&1 | FileCheck %s
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Worker%T = type { i32, [10 x i8] }
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Worker; CHECK:     Function: test
16*9880d681SAndroid Build Coastguard Worker
17*9880d681SAndroid Build Coastguard Workerdefine void @test(i1 %C) {
18*9880d681SAndroid Build Coastguard Worker; CHECK: 10 Total Alias Queries Performed
19*9880d681SAndroid Build Coastguard Worker; CHECK: 4 no alias responses
20*9880d681SAndroid Build Coastguard Worker  %M = alloca %T*, align 8 ; NoAlias with %A, %B, %MS, %AP
21*9880d681SAndroid Build Coastguard Worker  %A = alloca %T, align 8
22*9880d681SAndroid Build Coastguard Worker  %B = alloca %T, align 8
23*9880d681SAndroid Build Coastguard Worker
24*9880d681SAndroid Build Coastguard Worker  %MS = select i1 %C, %T* %B, %T* %A
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Worker  store %T* %MS, %T** %M
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Worker  %AP = load %T*, %T** %M ; PartialAlias with %A, %B
29*9880d681SAndroid Build Coastguard Worker
30*9880d681SAndroid Build Coastguard Worker  ret void
31*9880d681SAndroid Build Coastguard Worker}
32