[llvm] r241483 - [llvm-extract] Drop comdats from declarations

Reid Kleckner reid at kleckner.net
Mon Jul 6 11:48:02 PDT 2015


Author: rnk
Date: Mon Jul  6 13:48:02 2015
New Revision: 241483

URL: http://llvm.org/viewvc/llvm-project?rev=241483&view=rev
Log:
[llvm-extract] Drop comdats from declarations

The verifier rejects comdats on declarations.

Modified:
    llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
    llvm/trunk/test/Other/extract.ll

Modified: llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp?rev=241483&r1=241482&r2=241483&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/ExtractGV.cpp Mon Jul  6 13:48:02 2015
@@ -93,8 +93,11 @@ namespace {
 
         makeVisible(*I, Delete);
 
-        if (Delete)
+        if (Delete) {
+          // Make this a declaration and drop it's comdat.
           I->setInitializer(nullptr);
+          I->setComdat(nullptr);
+        }
       }
 
       // Visit the Functions.
@@ -108,8 +111,11 @@ namespace {
 
         makeVisible(*I, Delete);
 
-        if (Delete)
+        if (Delete) {
+          // Make this a declaration and drop it's comdat.
           I->deleteBody();
+          I->setComdat(nullptr);
+        }
       }
 
       // Visit the Aliases.

Modified: llvm/trunk/test/Other/extract.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Other/extract.ll?rev=241483&r1=241482&r2=241483&view=diff
==============================================================================
--- llvm/trunk/test/Other/extract.ll (original)
+++ llvm/trunk/test/Other/extract.ll Mon Jul  6 13:48:02 2015
@@ -7,19 +7,22 @@
 ; llvm-extract uses lazy bitcode loading, so make sure it correctly reads
 ; from bitcode files in addition to assembly files.
 
-; CHECK: define hidden void @foo() {
+; CHECK: define hidden void @foo() comdat($x) {
 ; CHECK:   ret void
 ; CHECK: }
 
 ; The private linkage for foo() should be changed to external linkage and
 ; hidden visibility added.
 ; DELETE: declare hidden void @foo()
+; DELETE-NOT: comdat
 ; DELETE: define void @bar() {
 ; DELETE:   call void @foo()
 ; DELETE:   ret void
 ; DELETE: }
 
-define private void @foo() {
+$x = comdat any
+
+define private void @foo() comdat($x) {
   ret void
 }
 define void @bar() {





More information about the llvm-commits mailing list