xref: /aosp_15_r20/external/llvm/test/Transforms/GlobalOpt/localize-constexpr.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -S < %s -globalopt | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker@G = internal global i32 42
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Workerdefine i8 @f() norecurse {
6*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @f
7*9880d681SAndroid Build Coastguard Worker; CHECK: alloca
8*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: @G
9*9880d681SAndroid Build Coastguard Worker; CHECK: }
10*9880d681SAndroid Build Coastguard Worker  store i32 42, i32* @G
11*9880d681SAndroid Build Coastguard Worker  %a = load i8, i8* bitcast (i32* @G to i8*)
12*9880d681SAndroid Build Coastguard Worker  ret i8 %a
13*9880d681SAndroid Build Coastguard Worker}
14*9880d681SAndroid Build Coastguard Worker
15*9880d681SAndroid Build Coastguard Worker@H = internal global i32 42
16*9880d681SAndroid Build Coastguard Worker@Halias = alias i32, i32* @H
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard Worker; @H can't be localized because @Halias uses it, and @Halias can't be converted to an instruction.
19*9880d681SAndroid Build Coastguard Workerdefine i8 @g() norecurse {
20*9880d681SAndroid Build Coastguard Worker; CHECK-LABEL: @g
21*9880d681SAndroid Build Coastguard Worker; CHECK-NOT: alloca
22*9880d681SAndroid Build Coastguard Worker; CHECK: @H
23*9880d681SAndroid Build Coastguard Worker; CHECK: }
24*9880d681SAndroid Build Coastguard Worker  store i32 42, i32* @H
25*9880d681SAndroid Build Coastguard Worker  %a = load i8, i8* bitcast (i32* @H to i8*)
26*9880d681SAndroid Build Coastguard Worker  ret i8 %a
27*9880d681SAndroid Build Coastguard Worker}
28*9880d681SAndroid Build Coastguard Worker
29