From: Rafael Espindola Date: Tue, 12 Aug 2014 15:39:14 +0000 (+0000) Subject: Add a plugin testcase for merging weak variables. X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=f531e9267168dcbd93655efd660958b928de5853;p=oota-llvm.git Add a plugin testcase for merging weak variables. 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 --- diff --git a/test/tools/gold/Inputs/weak.ll b/test/tools/gold/Inputs/weak.ll new file mode 100644 index 00000000000..53b1d1650d1 --- /dev/null +++ b/test/tools/gold/Inputs/weak.ll @@ -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 index 00000000000..da88f14a212 --- /dev/null +++ b/test/tools/gold/weak.ll @@ -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