[PATCH] D133640: Unreachable code RAUW from UndefValue to PoisonValue [NFC]

Manuel Brito via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Sep 10 05:05:13 PDT 2022


ManuelJBrito created this revision.
ManuelJBrito added a reviewer: nlopes.
Herald added a subscriber: hiraditya.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Replacing the following instances of UndefValue with PoisonValue, where the UndefValue is used as an arbitrary value.

llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp

- @cleanup if the result is not used then the inserted instructions are removed, RAUW arbitrary value

llvm/lib/Transforms/Utils/BasicBlockUtils.cpp

- @FoldSingleEntryPHINodes when we have a self referential single entry phi node, RAUW arbitrary value

llvm/lib/Transforms/Utils/CallGraphUpdater.cpp

- @finalize Remove all references to removed functions RAUW arbitrary value

llvm/tools/bugpoint/CrashDebugger.cpp

- @TestInts the program is cloned and instructions are removed to narrow down source of crash, RAUW arbitrary value

llvm/lib/CodeGen/WinEHPrepare.cpp

- @demotePHIsOnFunclets RAUW arbitrary value for lingering uses of removed PHI nodes


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133640

Files:
  llvm/lib/CodeGen/WinEHPrepare.cpp
  llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
  llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
  llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
  llvm/tools/bugpoint/CrashDebugger.cpp


Index: llvm/tools/bugpoint/CrashDebugger.cpp
===================================================================
--- llvm/tools/bugpoint/CrashDebugger.cpp
+++ llvm/tools/bugpoint/CrashDebugger.cpp
@@ -791,7 +791,7 @@
             !Inst.isEHPad() && !Inst.getType()->isTokenTy() &&
             !Inst.isSwiftError()) {
           if (!Inst.getType()->isVoidTy())
-            Inst.replaceAllUsesWith(UndefValue::get(Inst.getType()));
+            Inst.replaceAllUsesWith(PoisonValue::get(Inst.getType()));
           Inst.eraseFromParent();
         }
       }
Index: llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
===================================================================
--- llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
+++ llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
@@ -2666,7 +2666,7 @@
 #endif
     assert(!I->getType()->isVoidTy() &&
            "inserted instruction should have non-void types");
-    I->replaceAllUsesWith(UndefValue::get(I->getType()));
+    I->replaceAllUsesWith(PoisonValue::get(I->getType()));
     I->eraseFromParent();
   }
 }
Index: llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
===================================================================
--- llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
+++ llvm/lib/Transforms/Utils/CallGraphUpdater.cpp
@@ -36,7 +36,7 @@
       CallGraphNode *DeadCGN = (*CG)[DeadFn];
       DeadCGN->removeAllCalledFunctions();
       CG->getExternalCallingNode()->removeAnyCallEdgeTo(DeadCGN);
-      DeadFn->replaceAllUsesWith(UndefValue::get(DeadFn->getType()));
+      DeadFn->replaceAllUsesWith(PoisonValue::get(DeadFn->getType()));
     }
 
     // Then remove the node and function from the module.
@@ -51,7 +51,7 @@
     // no call graph was provided.
     for (Function *DeadFn : DeadFunctions) {
       DeadFn->removeDeadConstantUsers();
-      DeadFn->replaceAllUsesWith(UndefValue::get(DeadFn->getType()));
+      DeadFn->replaceAllUsesWith(PoisonValue::get(DeadFn->getType()));
 
       if (LCG && !ReplacedFunctions.count(DeadFn)) {
         // Taken mostly from the inliner:
Index: llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
===================================================================
--- llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
+++ llvm/lib/Transforms/Utils/BasicBlockUtils.cpp
@@ -149,7 +149,7 @@
     if (PN->getIncomingValue(0) != PN)
       PN->replaceAllUsesWith(PN->getIncomingValue(0));
     else
-      PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
+      PN->replaceAllUsesWith(PoisonValue::get(PN->getType()));
 
     if (MemDep)
       MemDep->removeInstruction(PN);  // Memdep updates AA itself.
Index: llvm/lib/CodeGen/WinEHPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/WinEHPrepare.cpp
+++ llvm/lib/CodeGen/WinEHPrepare.cpp
@@ -733,7 +733,7 @@
 
   for (auto *PN : PHINodes) {
     // There may be lingering uses on other EH PHIs being removed
-    PN->replaceAllUsesWith(UndefValue::get(PN->getType()));
+    PN->replaceAllUsesWith(PoisonValue::get(PN->getType()));
     PN->eraseFromParent();
   }
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D133640.459280.patch
Type: text/x-patch
Size: 3114 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220910/1ae66514/attachment.bin>


More information about the llvm-commits mailing list