[llvm-commits] [llvm] r116788 - in /llvm/trunk: lib/Linker/LinkModules.cpp test/Linker/PR8300.ll
Rafael Espindola
rafael.espindola at gmail.com
Mon Oct 18 19:02:57 PDT 2010
Author: rafael
Date: Mon Oct 18 21:02:57 2010
New Revision: 116788
URL: http://llvm.org/viewvc/llvm-project?rev=116788&view=rev
Log:
Fix PR8300 by remembering to keep the bitcast in all cases.
Added:
llvm/trunk/test/Linker/PR8300.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=116788&r1=116787&r2=116788&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Mon Oct 18 21:02:57 2010
@@ -668,6 +668,13 @@
GlobalValue* DAliasee = cast<GlobalValue>(VMI->second);
GlobalValue* DGV = NULL;
+ // Fixup aliases to bitcasts. Note that aliases to GEPs are still broken
+ // by this, but aliases to GEPs are broken to a lot of other things, so
+ // it's less important.
+ Constant *DAliaseeConst = DAliasee;
+ if (SGA->getType() != DAliasee->getType())
+ DAliaseeConst = ConstantExpr::getBitCast(DAliasee, SGA->getType());
+
// Try to find something 'similar' to SGA in destination module.
if (!DGV && !SGA->hasLocalLinkage()) {
DGV = Dest->getNamedAlias(SGA->getName());
@@ -721,7 +728,7 @@
"': aliasee is not global variable");
NewGA = new GlobalAlias(SGA->getType(), SGA->getLinkage(),
- SGA->getName(), DAliasee, Dest);
+ SGA->getName(), DAliaseeConst, Dest);
CopyGVAttributes(NewGA, SGA);
// Any uses of DGV need to change to NewGA, with cast, if needed.
@@ -750,7 +757,7 @@
"': aliasee is not function");
NewGA = new GlobalAlias(SGA->getType(), SGA->getLinkage(),
- SGA->getName(), DAliasee, Dest);
+ SGA->getName(), DAliaseeConst, Dest);
CopyGVAttributes(NewGA, SGA);
// Any uses of DF need to change to NewGA, with cast, if needed.
@@ -772,14 +779,8 @@
} else {
// No linking to be performed, simply create an identical version of the
// alias over in the dest module...
- Constant *Aliasee = DAliasee;
- // Fixup aliases to bitcasts. Note that aliases to GEPs are still broken
- // by this, but aliases to GEPs are broken to a lot of other things, so
- // it's less important.
- if (SGA->getType() != DAliasee->getType())
- Aliasee = ConstantExpr::getBitCast(DAliasee, SGA->getType());
NewGA = new GlobalAlias(SGA->getType(), SGA->getLinkage(),
- SGA->getName(), Aliasee, Dest);
+ SGA->getName(), DAliaseeConst, Dest);
CopyGVAttributes(NewGA, SGA);
// Proceed to 'common' steps
Added: llvm/trunk/test/Linker/PR8300.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/PR8300.ll?rev=116788&view=auto
==============================================================================
--- llvm/trunk/test/Linker/PR8300.ll (added)
+++ llvm/trunk/test/Linker/PR8300.ll Mon Oct 18 21:02:57 2010
@@ -0,0 +1,13 @@
+; RUN: echo {%foo2 = type \{ \[8 x i8\] \} \
+; RUN: declare void @zed(%foo2*) } > %t.ll
+; RUN: llvm-link %t.ll %s -o %t.bc
+
+%foo = type { [8 x i8] }
+%bar = type { [9 x i8] }
+
+ at zed = alias bitcast (void (%bar*)* @xyz to void (%foo*)*)
+
+define void @xyz(%bar* %this) {
+entry:
+ ret void
+}
More information about the llvm-commits
mailing list