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
This commit is contained in:
Rafael Espindola 2014-08-12 15:39:14 +00:00
parent 87d7e906ce
commit f531e92671
2 changed files with 18 additions and 0 deletions

View File

@ -0,0 +1,2 @@
@a = weak global i32 41
@c = global i32* @a

16
test/tools/gold/weak.ll Normal file
View File

@ -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