xref: /aosp_15_r20/external/llvm/test/Transforms/ConstantMerge/dont-merge.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt < %s -constmerge -S | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Don't merge constants with specified sections.
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker@T1G1 = internal constant i32 1, section "foo"
6*9880d681SAndroid Build Coastguard Worker@T1G2 = internal constant i32 1, section "bar"
7*9880d681SAndroid Build Coastguard Worker@T1G3 = internal constant i32 1, section "bar"
8*9880d681SAndroid Build Coastguard Worker
9*9880d681SAndroid Build Coastguard Worker; CHECK: @T1G1
10*9880d681SAndroid Build Coastguard Worker; CHECK: @T1G2
11*9880d681SAndroid Build Coastguard Worker; CHECK: @T1G3
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerdefine void @test1(i32** %P1, i32** %P2, i32** %P3) {
14*9880d681SAndroid Build Coastguard Worker        store i32* @T1G1, i32** %P1
15*9880d681SAndroid Build Coastguard Worker        store i32* @T1G2, i32** %P2
16*9880d681SAndroid Build Coastguard Worker        store i32* @T1G3, i32** %P3
17*9880d681SAndroid Build Coastguard Worker        ret void
18*9880d681SAndroid Build Coastguard Worker}
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker@T2a = internal constant i32 224
21*9880d681SAndroid Build Coastguard Worker@T2b = internal addrspace(30) constant i32 224
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Worker; CHECK: @T2a
24*9880d681SAndroid Build Coastguard Worker; CHECK: @T2b
25*9880d681SAndroid Build Coastguard Worker
26*9880d681SAndroid Build Coastguard Workerdefine void @test2(i32** %P1, i32 addrspace(30)** %P2) {
27*9880d681SAndroid Build Coastguard Worker        store i32* @T2a, i32** %P1
28*9880d681SAndroid Build Coastguard Worker        store i32 addrspace(30)*  @T2b, i32 addrspace(30)** %P2
29*9880d681SAndroid Build Coastguard Worker        ret void
30*9880d681SAndroid Build Coastguard Worker}
31*9880d681SAndroid Build Coastguard Worker
32*9880d681SAndroid Build Coastguard Worker; PR8144 - Don't merge globals marked attribute(used)
33*9880d681SAndroid Build Coastguard Worker; CHECK: @T3A =
34*9880d681SAndroid Build Coastguard Worker; CHECK: @T3B =
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Worker@T3A = internal constant i32 0
37*9880d681SAndroid Build Coastguard Worker@T3B = internal constant i32 0
38*9880d681SAndroid Build Coastguard Worker@llvm.used = appending global [2 x i32*] [i32* @T3A, i32* @T3B], section
39*9880d681SAndroid Build Coastguard Worker"llvm.metadata"
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workerdefine void @test3() {
42*9880d681SAndroid Build Coastguard Worker  call void asm sideeffect "T3A, T3B",""() ; invisible use of T3A and T3B
43*9880d681SAndroid Build Coastguard Worker  ret void
44*9880d681SAndroid Build Coastguard Worker}
45