[PATCH] D31685: [Bugpoint] Erase comdat annotat after setting linkage to external.

bryant via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 16:22:16 PDT 2017


bryant created this revision.

Not entirely sure whether this is correct. I was unable to use Bugpoint to debug a miscompilation because its function splitting phase caused many verifier errors of this type: "Declaration may not be in a Comdat!" This patch resolved the issue.

This is similar in spirit to https://reviews.llvm.org/D21274 .


Repository:
  rL LLVM

https://reviews.llvm.org/D31685

Files:
  tools/bugpoint/ExtractFunction.cpp


Index: tools/bugpoint/ExtractFunction.cpp
===================================================================
--- tools/bugpoint/ExtractFunction.cpp
+++ tools/bugpoint/ExtractFunction.cpp
@@ -309,13 +309,16 @@
                                 ValueToValueMapTy &VMap) {
   // Make sure functions & globals are all external so that linkage
   // between the two modules will work.
-  for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I)
+  for (Module::iterator I = M->begin(), E = M->end(); I != E; ++I) {
     I->setLinkage(GlobalValue::ExternalLinkage);
+    I->setComdat(nullptr);
+  }
   for (Module::global_iterator I = M->global_begin(), E = M->global_end();
        I != E; ++I) {
     if (I->hasName() && I->getName()[0] == '\01')
       I->setName(I->getName().substr(1));
     I->setLinkage(GlobalValue::ExternalLinkage);
+    I->setComdat(nullptr);
   }
 
   ValueToValueMapTy NewVMap;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D31685.94136.patch
Type: text/x-patch
Size: 909 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170404/612cb9f1/attachment.bin>


More information about the llvm-commits mailing list