[llvm] r272855 - [IR] [DAE] Copy comdats during DAE, and don't copy comdats in GlobalObject::copyAttributesFrom.
Justin Lebar via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 15 16:20:16 PDT 2016
Author: jlebar
Date: Wed Jun 15 18:20:15 2016
New Revision: 272855
URL: http://llvm.org/viewvc/llvm-project?rev=272855&view=rev
Log:
[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
Modified:
llvm/trunk/lib/IR/Globals.cpp
llvm/trunk/lib/Linker/IRMover.cpp
llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=272855&r1=272854&r2=272855&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Wed Jun 15 18:20:15 2016
@@ -96,7 +96,6 @@ void GlobalObject::copyAttributesFrom(co
if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
setAlignment(GV->getAlignment());
setSection(GV->getSection());
- setComdat(const_cast<GlobalObject *>(GV)->getComdat());
}
}
Modified: llvm/trunk/lib/Linker/IRMover.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/IRMover.cpp?rev=272855&r1=272854&r2=272855&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp (original)
+++ llvm/trunk/lib/Linker/IRMover.cpp Wed Jun 15 18:20:15 2016
@@ -637,11 +637,6 @@ GlobalValue *IRLinker::copyGlobalValuePr
NewGV->copyAttributesFrom(SGV);
- // Don't copy the comdat, it's from the original module. We'll handle it
- // later.
- if (auto *NewGO = dyn_cast<GlobalObject>(NewGV))
- NewGO->setComdat(nullptr);
-
// Remove these copied constants in case this stays a declaration, since
// they point to the source module. If the def is linked the values will
// be mapped in during linkFunctionBody.
Modified: llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp?rev=272855&r1=272854&r2=272855&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/DeadArgumentElimination.cpp Wed Jun 15 18:20:15 2016
@@ -147,6 +147,7 @@ bool DeadArgumentEliminationPass::Delete
// Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, Fn.getLinkage());
NF->copyAttributesFrom(&Fn);
+ NF->setComdat(Fn.getComdat());
Fn.getParent()->getFunctionList().insert(Fn.getIterator(), NF);
NF->takeName(&Fn);
@@ -813,6 +814,7 @@ bool DeadArgumentEliminationPass::Remove
// Create the new function body and insert it into the module...
Function *NF = Function::Create(NFTy, F->getLinkage());
NF->copyAttributesFrom(F);
+ NF->setComdat(F->getComdat());
NF->setAttributes(NewPAL);
// Insert the new function before the old function, so we won't be processing
// it again.
More information about the llvm-commits
mailing list