Keep unnamed_addr when linking.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123364 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2011-01-13 05:12:34 +00:00
parent d72479c2f0
commit c2a94da313
5 changed files with 35 additions and 0 deletions

View File

@ -352,6 +352,8 @@ static void CopyGVAttributes(GlobalValue *DestGV, const GlobalValue *SrcGV) {
unsigned Alignment = std::max(DestGV->getAlignment(), SrcGV->getAlignment());
DestGV->copyAttributesFrom(SrcGV);
DestGV->setAlignment(Alignment);
if (SrcGV->hasUnnamedAddr())
DestGV->setUnnamedAddr(true);
}
/// GetLinkageResult - This analyzes the two global values and determines what

View File

@ -0,0 +1,11 @@
; RUN: llvm-link %s %p/unnamed-addr1-b.ll -S -o - | FileCheck %s
@foo = external global i32
define i32 @bar() {
entry:
%tmp = load i32* @foo, align 4
ret i32 %tmp
}
; CHECK: @foo = common unnamed_addr global i32 0, align 4

View File

@ -0,0 +1,4 @@
; This file is for use with unnamed-addr1-a.ll
; RUN: true
@foo = common unnamed_addr global i32 0, align 4

View File

@ -0,0 +1,11 @@
; RUN: llvm-link %s %p/unnamed-addr2-b.ll -S -o - | FileCheck %s
define i32 @bar() {
entry:
%call = tail call i32 @foo()
ret i32 %call
}
declare i32 @foo()
; CHECK: define unnamed_addr i32 @foo()

View File

@ -0,0 +1,7 @@
; This file is for use with unnamed-addr2-a.ll
; RUN: true
define unnamed_addr i32 @foo() {
entry:
ret i32 42
}