llvm.org GIT mirror llvm / 2e61194
Revert 146728 as it's causing failures on some of the external bots as well as internal nightly testers. Original commit message: By popular demand, link up types by name if they are isomorphic and one is an autorenamed version of the other. This makes the IR easier to read, because we don't end up with random renamed versions of the types after LTO'ing a large app. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146838 91177308-0d34-0410-b5e6-96231b3b80d8 Chad Rosier 8 years ago
2 changed file(s) with 0 addition(s) and 34 deletion(s). Raw diff Collapse all Expand all
542542 TypeMap.addTypeMapping(DGV->getType(), I->getType());
543543 }
544544
545 // Incorporate types by name, scanning all the types in the source module.
546 // At this point, the destination module may have a type "%foo = { i32 }" for
547 // example. When the source module got loaded into the same LLVMContext, if
548 // it had the same type, it would have been renamed to "%foo.42 = { i32 }".
549 // Though it isn't required for correctness, attempt to link these up to clean
550 // up the IR.
551 std::vector SrcStructTypes;
552 SrcM->findUsedStructTypes(SrcStructTypes);
553
554 for (unsigned i = 0, e = SrcStructTypes.size(); i != e; ++i) {
555 StructType *ST = SrcStructTypes[i];
556 if (!ST->hasName()) continue;
557
558 // Check to see if there is a dot in the name followed by a digit.
559 size_t DotPos = ST->getName().rfind('.');
560 if (DotPos == 0 || DotPos == StringRef::npos ||
561 ST->getName().back() == '.' || !isdigit(ST->getName()[DotPos+1]))
562 continue;
563
564 // Check to see if the destination module has a struct with the prefix name.
565 if (StructType *DST = DstM->getTypeByName(ST->getName().substr(0, DotPos)))
566 TypeMap.addTypeMapping(DST, ST);
567 }
568
569
570545 // Don't bother incorporating aliases, they aren't generally typed well.
571546
572547 // Now that we have discovered all of the type equivalences, get a body for
+0
-9
test/Linker/link-type-names.ll less more
None ; RUN: echo "%X = type { i32 } @G2 = global %X { i32 4 }" > %t.ll
1 ; RUN: llvm-link %s %t.ll -S | FileCheck %s
2
3 %X = type { i32 }
4 @G = global %X { i32 4 }
5
6
7 ; CHECK: @G = global %X { i32 4 }
8 ; CHECK: @G2 = global %X { i32 4 }