Prefer common over weak linkage when linking.

This matches the behavior of ELF linkers.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217443 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola
2014-09-09 14:27:09 +00:00
parent efed46fe31
commit ec8b573e54
3 changed files with 10 additions and 2 deletions

View File

@@ -721,8 +721,9 @@ bool ModuleLinker::getLinkageResult(GlobalValue *Dest, const GlobalValue *Src,
} else if (Src->isWeakForLinker()) {
assert(!Dest->hasExternalWeakLinkage());
assert(!Dest->hasAvailableExternallyLinkage());
if (Dest->hasLinkOnceLinkage() &&
(Src->hasWeakLinkage() || Src->hasCommonLinkage())) {
if ((Dest->hasLinkOnceLinkage() && Src->hasWeakLinkage()) ||
((Dest->hasLinkOnceLinkage() || Dest->hasWeakLinkage()) &&
Src->hasCommonLinkage())) {
LinkFromSrc = true;
LT = Src->getLinkage();
} else {

View File

@@ -0,0 +1 @@
@test1_a = weak global i8 1

6
test/Linker/linkage2.ll Normal file
View File

@@ -0,0 +1,6 @@
; RUN: llvm-link %s %p/Inputs/linkage2.ll -S | FileCheck %s
; RUN: llvm-link %p/Inputs/linkage2.ll %s -S | FileCheck %s
@test1_a = common global i8 0
; CHECK: @test1_a = common global i8 0