[llvm] r215447 - Add a plugin testcase for merging weak variables.

Rafael Espindola rafael.espindola at gmail.com
Tue Aug 12 08:39:14 PDT 2014


Author: rafael
Date: Tue Aug 12 10:39:14 2014
New Revision: 215447

URL: http://llvm.org/viewvc/llvm-project?rev=215447&view=rev
Log:
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.

Added:
    llvm/trunk/test/tools/gold/Inputs/weak.ll
    llvm/trunk/test/tools/gold/weak.ll

Added: llvm/trunk/test/tools/gold/Inputs/weak.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/Inputs/weak.ll?rev=215447&view=auto
==============================================================================
--- llvm/trunk/test/tools/gold/Inputs/weak.ll (added)
+++ llvm/trunk/test/tools/gold/Inputs/weak.ll Tue Aug 12 10:39:14 2014
@@ -0,0 +1,2 @@
+ at a = weak global i32 41
+ at c = global i32* @a

Added: llvm/trunk/test/tools/gold/weak.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/gold/weak.ll?rev=215447&view=auto
==============================================================================
--- llvm/trunk/test/tools/gold/weak.ll (added)
+++ llvm/trunk/test/tools/gold/weak.ll Tue Aug 12 10:39:14 2014
@@ -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
+
+ at a = weak global i32 42
+ at 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





More information about the llvm-commits mailing list