llvm.org GIT mirror llvm / 348e5e7
Add back removed code. It still causes LLVM to miscompile. But not having it breaks other things. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151594 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 8 years ago
2 changed file(s) with 30 addition(s) and 3 deletion(s). Raw diff Collapse all Expand all
578578 for (Module::iterator I = SrcM->begin(), E = SrcM->end(); I != E; ++I) {
579579 if (GlobalValue *DGV = getLinkedToGlobal(I))
580580 TypeMap.addTypeMapping(DGV->getType(), I->getType());
581 }
582
583 // Incorporate types by name, scanning all the types in the source module.
584 // At this point, the destination module may have a type "%foo = { i32 }" for
585 // example. When the source module got loaded into the same LLVMContext, if
586 // it had the same type, it would have been renamed to "%foo.42 = { i32 }".
587 // Though it isn't required for correctness, attempt to link these up to clean
588 // up the IR.
589 std::vector SrcStructTypes;
590 SrcM->findUsedStructTypes(SrcStructTypes);
591
592 SmallPtrSet SrcStructTypesSet(SrcStructTypes.begin(),
593 SrcStructTypes.end());
594
595 for (unsigned i = 0, e = SrcStructTypes.size(); i != e; ++i) {
596 StructType *ST = SrcStructTypes[i];
597 if (!ST->hasName()) continue;
598
599 // Check to see if there is a dot in the name followed by a digit.
600 size_t DotPos = ST->getName().rfind('.');
601 if (DotPos == 0 || DotPos == StringRef::npos ||
602 ST->getName().back() == '.' || !isdigit(ST->getName()[DotPos+1]))
603 continue;
604
605 // Check to see if the destination module has a struct with the prefix name.
606 if (StructType *DST = DstM->getTypeByName(ST->getName().substr(0, DotPos)))
607 // Don't use it if this actually came from the source module. They're in
608 // the same LLVMContext after all.
609 if (!SrcStructTypesSet.count(DST))
610 TypeMap.addTypeMapping(DST, ST);
581611 }
582612
583613 // Don't bother incorporating aliases, they aren't generally typed well.
0 ; RUN: echo "%X = type { i32 } @G2 = global %X { i32 4 }" > %t.ll
11 ; RUN: llvm-link %s %t.ll -S | FileCheck %s
2 ; XFAIL: *
32 ; PR11464
4
5 ; FIXME: XFAIL until is addressed.
63
74 %X = type { i32 }
85 @G = global %X { i32 4 }