[llvm] b4352e4 - [Attributor][FIX] Do not RAUW void values

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 14 19:45:39 PST 2020


Author: Johannes Doerfert
Date: 2020-02-14T21:44:46-06:00
New Revision: b4352e43d86e0b2ab93665e46c9cb9bddef3fd7a

URL: https://github.com/llvm/llvm-project/commit/b4352e43d86e0b2ab93665e46c9cb9bddef3fd7a
DIFF: https://github.com/llvm/llvm-project/commit/b4352e43d86e0b2ab93665e46c9cb9bddef3fd7a.diff

LOG: [Attributor][FIX] Do not RAUW void values

This caused an error when passes iterated over cached assumptions in the
tracker and assumed them to be `null` or an instruction. I failed to
create a test case so far.

Added: 
    

Modified: 
    llvm/lib/Transforms/IPO/Attributor.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 67f8b62c0168..76081a5adc04 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -7527,7 +7527,8 @@ ChangeStatus Attributor::run() {
     for (auto &V : ToBeDeletedInsts) {
       if (Instruction *I = dyn_cast_or_null<Instruction>(V)) {
         CGModifiedFunctions.insert(I->getFunction());
-        I->replaceAllUsesWith(UndefValue::get(I->getType()));
+        if (!I->getType()->isVoidTy())
+          I->replaceAllUsesWith(UndefValue::get(I->getType()));
         if (!isa<PHINode>(I) && isInstructionTriviallyDead(I))
           DeadInsts.push_back(I);
         else
@@ -8251,9 +8252,9 @@ static bool runAttributorOnFunctions(InformationCache &InfoCache,
     A.identifyDefaultAbstractAttributes(*F);
   }
 
+  Module &M = *Functions.front()->getParent();
   ChangeStatus Changed = A.run();
-  assert(!verifyModule(*Functions.front()->getParent(), &errs()) &&
-         "Module verification failed!");
+  assert(!verifyModule(M, &errs()) && "Module verification failed!");
   LLVM_DEBUG(dbgs() << "[Attributor] Done with " << Functions.size()
                     << " functions, result: " << Changed << ".\n");
   return Changed == ChangeStatus::CHANGED;


        


More information about the llvm-commits mailing list