]> granicus.if.org Git - llvm/commitdiff
[IR] [DAE] Copy comdats during DAE, and don't copy comdats in GlobalObject::copyAttri...
authorJustin Lebar <jlebar@google.com>
Wed, 15 Jun 2016 23:20:15 +0000 (23:20 +0000)
committerJustin Lebar <jlebar@google.com>
Wed, 15 Jun 2016 23:20:15 +0000 (23:20 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272855 91177308-0d34-0410-b5e6-96231b3b80d8

lib/IR/Globals.cpp
lib/Linker/IRMover.cpp
lib/Transforms/IPO/DeadArgumentElimination.cpp

index c5e1b9b9fa033463f1ccb73732dd8187f9d9d2e6..6715484518a9d2246c2a8f1e8c8ec6dbe71cabfb 100644 (file)
@@ -96,7 +96,6 @@ void GlobalObject::copyAttributesFrom(const GlobalValue *Src) {
   if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
     setAlignment(GV->getAlignment());
     setSection(GV->getSection());
-    setComdat(const_cast<GlobalObject *>(GV)->getComdat());
   }
 }
 
index 14b0a43030dab4655524f932c0c8c3b466dd5d71..7d09b7be868f98b898c9912ffc2437a5a4d169b3 100644 (file)
@@ -637,11 +637,6 @@ GlobalValue *IRLinker::copyGlobalValueProto(const GlobalValue *SGV,
 
   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.
index d9da5e893219a5088cba86e22359a901ff8752dd..3caaa4a321820f3945a9465fa1d863cfd0459fb3 100644 (file)
@@ -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.