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

Justin Lebar via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 15 13:22:57 PDT 2016


jlebar created this revision.
jlebar added reviewers: majnemer, rnk.
jlebar added a subscriber: llvm-commits.

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.

http://reviews.llvm.org/D21403

Files:
  lib/IR/Globals.cpp
  lib/Linker/IRMover.cpp
  test/Transforms/DeadArgElim/comdat.ll

Index: test/Transforms/DeadArgElim/comdat.ll
===================================================================
--- test/Transforms/DeadArgElim/comdat.ll
+++ /dev/null
@@ -1,14 +0,0 @@
-; RUN: opt -S < %s -deadargelim | FileCheck %s
-
-$f = comdat any
-
-define void @f() comdat {
-  call void @g(i32 0)
-  ret void
-}
-
-define internal void @g(i32 %dead) comdat($f) {
-  ret void
-}
-
-; CHECK: define internal void @g() comdat($f) {
Index: lib/Linker/IRMover.cpp
===================================================================
--- lib/Linker/IRMover.cpp
+++ lib/Linker/IRMover.cpp
@@ -637,11 +637,6 @@
 
   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: lib/IR/Globals.cpp
===================================================================
--- lib/IR/Globals.cpp
+++ lib/IR/Globals.cpp
@@ -96,7 +96,6 @@
   if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
     setAlignment(GV->getAlignment());
     setSection(GV->getSection());
-    setComdat(const_cast<GlobalObject *>(GV)->getComdat());
   }
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D21403.60889.patch
Type: text/x-patch
Size: 1378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160615/86df0adb/attachment.bin>


More information about the llvm-commits mailing list