Skip to content

Commit c05f3c9

Browse files
author
Justin Lebar
committedJun 15, 2016
[IR] [DAE] Copy comdats during DAE, and don't copy comdats in GlobalObject::copyAttributesFrom.
Summary: This reverts the changes to Globals.cpp and IRMover.cpp in "[IR] Copy comdats in GlobalObject::copyAttributesFrom" (D20631, rL270743). The DeadArgElim test is left unchanged, and we change DAE to explicitly copy comdats. The reverted change breaks copyAttributesFrom when the destination lives in a different module from the source. The decision in D21255 was to revert this patch and handle comdat copying separately from copyAttributesFrom. Reviewers: majnemer, rnk Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D21403 llvm-svn: 272855
1 parent 2a445cf commit c05f3c9

File tree

3 files changed

+2
-6
lines changed

3 files changed

+2
-6
lines changed
 

‎llvm/lib/IR/Globals.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ void GlobalObject::copyAttributesFrom(const GlobalValue *Src) {
9696
if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
9797
setAlignment(GV->getAlignment());
9898
setSection(GV->getSection());
99-
setComdat(const_cast<GlobalObject *>(GV)->getComdat());
10099
}
101100
}
102101

‎llvm/lib/Linker/IRMover.cpp

-5
Original file line numberDiff line numberDiff line change
@@ -637,11 +637,6 @@ GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV,
637637

638638
NewGV->copyAttributesFrom(SGV);
639639

640-
// Don't copy the comdat, it's from the original module. We'll handle it
641-
// later.
642-
if (auto *NewGO = dyn_cast<GlobalObject>(NewGV))
643-
NewGO->setComdat(nullptr);
644-
645640
// Remove these copied constants in case this stays a declaration, since
646641
// they point to the source module. If the def is linked the values will
647642
// be mapped in during linkFunctionBody.

‎llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ bool DeadArgumentEliminationPass::DeleteDeadVarargs(Function &Fn) {
147147
// Create the new function body and insert it into the module...
148148
Function *NF = Function::Create(NFTy, Fn.getLinkage());
149149
NF->copyAttributesFrom(&Fn);
150+
NF->setComdat(Fn.getComdat());
150151
Fn.getParent()->getFunctionList().insert(Fn.getIterator(), NF);
151152
NF->takeName(&Fn);
152153

@@ -813,6 +814,7 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
813814
// Create the new function body and insert it into the module...
814815
Function *NF = Function::Create(NFTy, F->getLinkage());
815816
NF->copyAttributesFrom(F);
817+
NF->setComdat(F->getComdat());
816818
NF->setAttributes(NewPAL);
817819
// Insert the new function before the old function, so we won't be processing
818820
// it again.

0 commit comments

Comments
 (0)