[llvm-commits] [llvm] r151594 - in /llvm/trunk: lib/Linker/LinkModules.cpp test/Linker/link-type-names.ll
Bill Wendling
isanbard at gmail.com
Mon Feb 27 15:48:30 PST 2012
Author: void
Date: Mon Feb 27 17:48:30 2012
New Revision: 151594
URL: http://llvm.org/viewvc/llvm-project?rev=151594&view=rev
Log:
Add back removed code. It still causes LLVM to miscompile. But not having it breaks other things.
Modified:
llvm/trunk/lib/Linker/LinkModules.cpp
llvm/trunk/test/Linker/link-type-names.ll
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=151594&r1=151593&r2=151594&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Mon Feb 27 17:48:30 2012
@@ -581,6 +581,36 @@
TypeMap.addTypeMapping(DGV->getType(), I->getType());
}
+ // Incorporate types by name, scanning all the types in the source module.
+ // At this point, the destination module may have a type "%foo = { i32 }" for
+ // example. When the source module got loaded into the same LLVMContext, if
+ // it had the same type, it would have been renamed to "%foo.42 = { i32 }".
+ // Though it isn't required for correctness, attempt to link these up to clean
+ // up the IR.
+ std::vector<StructType*> SrcStructTypes;
+ SrcM->findUsedStructTypes(SrcStructTypes);
+
+ SmallPtrSet<StructType*, 32> SrcStructTypesSet(SrcStructTypes.begin(),
+ SrcStructTypes.end());
+
+ for (unsigned i = 0, e = SrcStructTypes.size(); i != e; ++i) {
+ StructType *ST = SrcStructTypes[i];
+ if (!ST->hasName()) continue;
+
+ // Check to see if there is a dot in the name followed by a digit.
+ size_t DotPos = ST->getName().rfind('.');
+ if (DotPos == 0 || DotPos == StringRef::npos ||
+ ST->getName().back() == '.' || !isdigit(ST->getName()[DotPos+1]))
+ continue;
+
+ // Check to see if the destination module has a struct with the prefix name.
+ if (StructType *DST = DstM->getTypeByName(ST->getName().substr(0, DotPos)))
+ // Don't use it if this actually came from the source module. They're in
+ // the same LLVMContext after all.
+ if (!SrcStructTypesSet.count(DST))
+ TypeMap.addTypeMapping(DST, ST);
+ }
+
// Don't bother incorporating aliases, they aren't generally typed well.
// Now that we have discovered all of the type equivalences, get a body for
Modified: llvm/trunk/test/Linker/link-type-names.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Linker/link-type-names.ll?rev=151594&r1=151593&r2=151594&view=diff
==============================================================================
--- llvm/trunk/test/Linker/link-type-names.ll (original)
+++ llvm/trunk/test/Linker/link-type-names.ll Mon Feb 27 17:48:30 2012
@@ -1,10 +1,7 @@
; RUN: echo "%X = type { i32 } @G2 = global %X { i32 4 }" > %t.ll
; RUN: llvm-link %s %t.ll -S | FileCheck %s
-; XFAIL: *
; PR11464
-; FIXME: XFAIL until <rdar://problem/10913281> is addressed.
-
%X = type { i32 }
@G = global %X { i32 4 }
More information about the llvm-commits
mailing list