[llvm] [InstCombine] If return-inst in unreachable refers to an inst change it to poison (#65107) (PR #78444)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 30 02:05:46 PST 2024


================
@@ -2779,6 +2779,11 @@ llvm::removeAllNonTerminatorAndEHPadInstructions(BasicBlock *BB) {
   Instruction *EndInst = BB->getTerminator(); // Last not to be deleted.
   // RemoveDIs: erasing debug-info must be done manually.
   EndInst->dropDbgValues();
+
+  if (isa<ReturnInst>(EndInst) && EndInst->getNumOperands() > 0 &&
+      isa<Instruction>(EndInst->getOperand(0)))
+    EndInst->setOperand(0, PoisonValue::get(EndInst->getOperand(0)->getType()));
----------------
nikic wrote:

The handling should be generic, not for specific terminator types.

https://github.com/llvm/llvm-project/pull/78444


More information about the llvm-commits mailing list