[llvm-commits] [llvm] r123364 - in /llvm/trunk: lib/Linker/LinkModules.cpp test/Linker/unnamed-addr1-a.ll test/Linker/unnamed-addr1-b.ll test/Linker/unnamed-addr2-a.ll test/Linker/unnamed-addr2-b.ll
Rafael Espindola
rafael.espindola at gmail.com
Wed Jan 12 21:12:34 PST 2011
Author: rafael
Date: Wed Jan 12 23:12:34 2011
New Revision: 123364
URL: http://llvm.org/viewvc/llvm-project?rev=123364&view=rev
Log:
Keep unnamed_addr when linking.
Added:
llvm/trunk/test/Linker/unnamed-addr1-a.ll
llvm/trunk/test/Linker/unnamed-addr1-b.ll
llvm/trunk/test/Linker/unnamed-addr2-a.ll
llvm/trunk/test/Linker/unnamed-addr2-b.ll
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=123364&r1=123363&r2=123364&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Wed Jan 12 23:12:34 2011
@@ -352,6 +352,8 @@
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
Added: llvm/trunk/test/Linker/unnamed-addr1-a.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/unnamed-addr1-a.ll?rev=123364&view=auto
==============================================================================
--- llvm/trunk/test/Linker/unnamed-addr1-a.ll (added)
+++ llvm/trunk/test/Linker/unnamed-addr1-a.ll Wed Jan 12 23:12:34 2011
@@ -0,0 +1,11 @@
+; RUN: llvm-link %s %p/unnamed-addr1-b.ll -S -o - | FileCheck %s
+
+ at 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
Added: llvm/trunk/test/Linker/unnamed-addr1-b.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/unnamed-addr1-b.ll?rev=123364&view=auto
==============================================================================
--- llvm/trunk/test/Linker/unnamed-addr1-b.ll (added)
+++ llvm/trunk/test/Linker/unnamed-addr1-b.ll Wed Jan 12 23:12:34 2011
@@ -0,0 +1,4 @@
+; This file is for use with unnamed-addr1-a.ll
+; RUN: true
+
+ at foo = common unnamed_addr global i32 0, align 4
Added: llvm/trunk/test/Linker/unnamed-addr2-a.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/unnamed-addr2-a.ll?rev=123364&view=auto
==============================================================================
--- llvm/trunk/test/Linker/unnamed-addr2-a.ll (added)
+++ llvm/trunk/test/Linker/unnamed-addr2-a.ll Wed Jan 12 23:12:34 2011
@@ -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()
Added: llvm/trunk/test/Linker/unnamed-addr2-b.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/unnamed-addr2-b.ll?rev=123364&view=auto
==============================================================================
--- llvm/trunk/test/Linker/unnamed-addr2-b.ll (added)
+++ llvm/trunk/test/Linker/unnamed-addr2-b.ll Wed Jan 12 23:12:34 2011
@@ -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
+}
More information about the llvm-commits
mailing list