[PATCH] D20631: [IR] Copy comdats in GlobalObject::copyAttributesFrom
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed May 25 11:42:52 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL270743: [IR] Copy comdats in GlobalObject::copyAttributesFrom (authored by rnk).
Changed prior to commit:
http://reviews.llvm.org/D20631?vs=58441&id=58468#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20631
Files:
llvm/trunk/lib/IR/Globals.cpp
llvm/trunk/lib/Linker/IRMover.cpp
llvm/trunk/test/Transforms/DeadArgElim/comdat.ll
Index: llvm/trunk/lib/IR/Globals.cpp
===================================================================
--- llvm/trunk/lib/IR/Globals.cpp
+++ llvm/trunk/lib/IR/Globals.cpp
@@ -96,6 +96,7 @@
if (const auto *GV = dyn_cast<GlobalObject>(Src)) {
setAlignment(GV->getAlignment());
setSection(GV->getSection());
+ setComdat(const_cast<GlobalObject *>(GV)->getComdat());
}
}
Index: llvm/trunk/lib/Linker/IRMover.cpp
===================================================================
--- llvm/trunk/lib/Linker/IRMover.cpp
+++ llvm/trunk/lib/Linker/IRMover.cpp
@@ -622,6 +622,11 @@
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: llvm/trunk/test/Transforms/DeadArgElim/comdat.ll
===================================================================
--- llvm/trunk/test/Transforms/DeadArgElim/comdat.ll
+++ llvm/trunk/test/Transforms/DeadArgElim/comdat.ll
@@ -0,0 +1,14 @@
+; 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) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20631.58468.patch
Type: text/x-patch
Size: 1505 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160525/8d1829fe/attachment.bin>
More information about the llvm-commits
mailing list