95 lines · plain
1; RUN: opt < %s -passes=constmerge -S | FileCheck %s2 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: @T1G110; CHECK: @T1G211; CHECK: @T1G312 13define void @test1(ptr %P1, ptr %P2, ptr %P3) {14 store ptr @T1G1, ptr %P115 store ptr @T1G2, ptr %P216 store ptr @T1G3, ptr %P317 ret void18}19 20@T2a = internal constant i32 22421@T2b = internal addrspace(30) constant i32 22422 23; CHECK: @T2a24; CHECK: @T2b25 26define void @test2(ptr %P1, ptr %P2) {27 store ptr @T2a, ptr %P128 store ptr addrspace(30) @T2b, ptr %P229 ret void30}31 32; PR8144 - Don't merge globals marked attribute(used)33; CHECK: @T3A = 34; CHECK: @T3B = 35 36@T3A = internal constant i32 037@T3B = internal constant i32 038@llvm.used = appending global [2 x ptr] [ptr @T3A, ptr @T3B], section39"llvm.metadata"40 41define void @test3() {42 call void asm sideeffect "T3A, T3B",""() ; invisible use of T3A and T3B43 ret void44}45 46; Don't merge constants with !type annotations.47 48@T4A1 = internal constant i32 2, !type !049@T4A2 = internal unnamed_addr constant i32 2, !type !150 51@T4B1 = internal constant i32 3, !type !052@T4B2 = internal unnamed_addr constant i32 3, !type !053 54@T4C1 = internal constant i32 4, !type !055@T4C2 = unnamed_addr constant i32 456 57@T4D1 = unnamed_addr constant i32 5, !type !058@T4D2 = internal constant i32 559 60!0 = !{i64 0, !"typeinfo name for A"}61!1 = !{i64 0, !"typeinfo name for B"}62 63; CHECK: @T4A164; CHECK: @T4A265; CHECK: @T4B166; CHECK: @T4B267; CHECK: @T4C168; CHECK: @T4C269; CHECK: @T4D170; CHECK: @T4D271 72define void @test4(ptr %P1, ptr %P2, ptr %P3, ptr %P4, ptr %P5, ptr %P6, ptr %P7, ptr %P8) {73 store ptr @T4A1, ptr %P174 store ptr @T4A2, ptr %P275 store ptr @T4B1, ptr %P376 store ptr @T4B2, ptr %P477 store ptr @T4C1, ptr %P578 store ptr @T4C2, ptr %P679 store ptr @T4D1, ptr %P780 store ptr @T4D2, ptr %P881 ret void82}83 84; CHECK: @T5tls85; CHECK: @T5ua86 87@T5tls = private thread_local constant i32 55588@T5ua = private unnamed_addr constant i32 55589 90define void @test5(ptr %P1, ptr %P2) {91 store ptr @T5tls, ptr %P192 store ptr @T5ua, ptr %P293 ret void94}95