1; RUN: opt < %s -passes=constmerge -S | FileCheck %s 2 3; Don't merge constants with specified sections. 4 5@T1G1 = internal constant i32 1, section "foo" 6@T1G2 = internal constant i32 1, section "bar" 7@T1G3 = internal constant i32 1, section "bar" 8 9; CHECK: @T1G1 10; CHECK: @T1G2 11; CHECK: @T1G3 12 13define void @test1(ptr %P1, ptr %P2, ptr %P3) { 14 store ptr @T1G1, ptr %P1 15 store ptr @T1G2, ptr %P2 16 store ptr @T1G3, ptr %P3 17 ret void 18} 19 20@T2a = internal constant i32 224 21@T2b = internal addrspace(30) constant i32 224 22 23; CHECK: @T2a 24; CHECK: @T2b 25 26define void @test2(ptr %P1, ptr %P2) { 27 store ptr @T2a, ptr %P1 28 store ptr addrspace(30) @T2b, ptr %P2 29 ret void 30} 31 32; PR8144 - Don't merge globals marked attribute(used) 33; CHECK: @T3A = 34; CHECK: @T3B = 35 36@T3A = internal constant i32 0 37@T3B = internal constant i32 0 38@llvm.used = appending global [2 x ptr] [ptr @T3A, ptr @T3B], section 39"llvm.metadata" 40 41define void @test3() { 42 call void asm sideeffect "T3A, T3B",""() ; invisible use of T3A and T3B 43 ret void 44} 45 46; Don't merge constants with !type annotations. 47 48@T4A1 = internal constant i32 2, !type !0 49@T4A2 = internal unnamed_addr constant i32 2, !type !1 50 51@T4B1 = internal constant i32 3, !type !0 52@T4B2 = internal unnamed_addr constant i32 3, !type !0 53 54@T4C1 = internal constant i32 4, !type !0 55@T4C2 = unnamed_addr constant i32 4 56 57@T4D1 = unnamed_addr constant i32 5, !type !0 58@T4D2 = internal constant i32 5 59 60!0 = !{i64 0, !"typeinfo name for A"} 61!1 = !{i64 0, !"typeinfo name for B"} 62 63; CHECK: @T4A1 64; CHECK: @T4A2 65; CHECK: @T4B1 66; CHECK: @T4B2 67; CHECK: @T4C1 68; CHECK: @T4C2 69; CHECK: @T4D1 70; CHECK: @T4D2 71 72define void @test4(ptr %P1, ptr %P2, ptr %P3, ptr %P4, ptr %P5, ptr %P6, ptr %P7, ptr %P8) { 73 store ptr @T4A1, ptr %P1 74 store ptr @T4A2, ptr %P2 75 store ptr @T4B1, ptr %P3 76 store ptr @T4B2, ptr %P4 77 store ptr @T4C1, ptr %P5 78 store ptr @T4C2, ptr %P6 79 store ptr @T4D1, ptr %P7 80 store ptr @T4D2, ptr %P8 81 ret void 82} 83 84; CHECK: @T5tls 85; CHECK: @T5ua 86 87@T5tls = private thread_local constant i32 555 88@T5ua = private unnamed_addr constant i32 555 89 90define void @test5(ptr %P1, ptr %P2) { 91 store ptr @T5tls, ptr %P1 92 store ptr @T5ua, ptr %P2 93 ret void 94} 95