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

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 1 08:04:40 PST 2024


================
@@ -2770,15 +2770,31 @@ bool llvm::replaceAllDbgUsesWith(Instruction &From, Value &To,
   return false;
 }
 
+void llvm::handleUnreachableTerminator(Instruction *I) {
+  // RemoveDIs: erase debug-info on this instruction manually.
+  I->dropDbgValues();
+  unsigned Opcode = I->getOpcode();
+  if (Opcode >= Instruction::Ret && Opcode <= Instruction::Invoke &&
----------------
ParkHanbum wrote:

I thought that only the above commands could be processed among the terminators. This is just my opinion, so please let me know if I'm wrong. 

this is my sample IRs.
```
icatch.dispatch:
  %tmp1 = catchswitch within none [label %icatch] unwind to caller
icatch:
  %tmp2 = catchpad within %tmp1 [ptr null, i32 64, ptr null]
  catchret from %tmp2 to label %exit
unreach.cleanupret:
  %cl = cleanuppad within none []
  cleanupret from %cl unwind to caller

unreach.indirectbr:
  indirectbr ptr %gep, [label %unreach.switch]

unreach.callbr:
  callbr void asm "", "!i"()
  to label %dummy [label %toexit]
``` 

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


More information about the llvm-commits mailing list