Page MenuHomePhabricator

Revert "[IR] Copy comdats in GlobalObject::copyAttributesFrom" (D20631, rL270743)
ClosedPublic

Authored by jlebar on Jun 15 2016, 1:22 PM.

Details

Summary

This 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.

Diff Detail

Repository
rL LLVM

Event Timeline

jlebar updated this revision to Diff 60889.Jun 15 2016, 1:22 PM
jlebar retitled this revision from to Revert "[IR] Copy comdats in GlobalObject::copyAttributesFrom" (D20631, rL270743).
jlebar updated this object.
jlebar added reviewers: majnemer, rnk.
jlebar added a subscriber: llvm-commits.
rnk edited edge metadata.Jun 15 2016, 1:35 PM

This patch should fix DAE:

diff --git a/lib/Transforms/IPO/DeadArgumentElimination.cpp b/lib/Transforms/IPO/DeadArgumentElimination.cpp
index d9da5e8..3caaa4a 100644
--- a/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -147,6 +147,7 @@ bool DeadArgumentEliminationPass::DeleteDeadVarargs(Function &Fn) {
   // 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::RemoveDeadStuffFromFunction(Function *F) {
   // 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.
test/Transforms/DeadArgElim/comdat.ll
1 ↗(On Diff #60889)

Please keep this test case and fix DAE

jlebar updated this revision to Diff 60901.Jun 15 2016, 1:53 PM
jlebar edited edge metadata.

Fix DAE.

rnk accepted this revision.Jun 15 2016, 4:03 PM
rnk edited edge metadata.

lgtm

This revision is now accepted and ready to land.Jun 15 2016, 4:03 PM
This revision was automatically updated to reflect the committed changes.