Add a plugin testcase for merging weak variables.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 12 Aug 2014 15:39:14 +0000 (15:39 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 12 Aug 2014 15:39:14 +0000 (15:39 +0000)
I initially thought I could implement COMDATs with aliases by just
internalizing GVs instead of dropping them. This is a counter
example: Internalizing one of the @a would make @b and @c point
to different variables.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215447 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/gold/Inputs/weak.ll [new file with mode: 0644]
test/tools/gold/weak.ll [new file with mode: 0644]

diff --git a/test/tools/gold/Inputs/weak.ll b/test/tools/gold/Inputs/weak.ll
new file mode 100644 (file)
index 0000000..53b1d16
--- /dev/null
@@ -0,0 +1,2 @@
+@a = weak global i32 41
+@c = global i32* @a
diff --git a/test/tools/gold/weak.ll b/test/tools/gold/weak.ll
new file mode 100644 (file)
index 0000000..da88f14
--- /dev/null
@@ -0,0 +1,16 @@
+; RUN: llvm-as %s -o %t.o
+; RUN: llvm-as %p/Inputs/weak.ll -o %t2.o
+
+; RUN: ld -plugin %llvmshlibdir/LLVMgold.so \
+; RUN:    --plugin-opt=emit-llvm \
+; RUN:    -shared %t.o %t2.o -o %t3.o
+; RUN: llvm-dis %t3.o -o - | FileCheck %s
+
+@a = weak global i32 42
+@b = global i32* @a
+
+; Test that @b and @c end up pointing to the same variable.
+
+; CHECK: @a = weak global i32 42
+; CHECK: @b = global i32* @a
+; CHECK: @c = global i32* @a