]> granicus.if.org Git - llvm/commitdiff
[Bugpoint] Erase comdat annotations after removing a global's initializer.
authorJustin Lebar <jlebar@google.com>
Wed, 15 Jun 2016 23:20:12 +0000 (23:20 +0000)
committerJustin Lebar <jlebar@google.com>
Wed, 15 Jun 2016 23:20:12 +0000 (23:20 +0000)
Summary:
This is necessary to keep the verifier happy after bugpoint removes an
initializer from a global variable with a comdat annotation, because
globals without initializers may not have comdats.

Reviewers: majnemer, rnk

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21274

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

tools/bugpoint/CrashDebugger.cpp
tools/bugpoint/ExtractFunction.cpp

index b161d88882ad5feebb01f05862419b70c196afb4..02e488ed3da8bd18eb680c2686703b439f7cf8fb 100644 (file)
@@ -164,6 +164,7 @@ ReduceCrashingGlobalVariables::TestGlobalVariables(
     if (I.hasInitializer() && !GVSet.count(&I)) {
       DeleteGlobalInitializer(&I);
       I.setLinkage(GlobalValue::ExternalLinkage);
+      I.setComdat(nullptr);
     }
 
   // Try running the hacked up program...
@@ -668,6 +669,7 @@ static bool DebugACrash(BugDriver &BD,
       if (I->hasInitializer()) {
         DeleteGlobalInitializer(&*I);
         I->setLinkage(GlobalValue::ExternalLinkage);
+        I->setComdat(nullptr);
         DeletedInit = true;
       }
 
index fe0ab69dc162d8f1ebfb287eb1ca1f3dadc6fc52..ae202c3f77e21b3702eff4c89d3f8df9f15b74fa 100644 (file)
@@ -215,6 +215,8 @@ void llvm::DeleteGlobalInitializer(GlobalVariable *GV) {
 //
 void llvm::DeleteFunctionBody(Function *F) {
   eliminateAliases(F);
+  // Function declarations can't have comdats.
+  F->setComdat(nullptr);
 
   // delete the body of the function...
   F->deleteBody();