[llvm] [ValueTracking] Fix "getOperand() out of range!" assertion crash (PR #87482)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 4 14:18:07 PDT 2024


================
@@ -7378,7 +7378,7 @@ static bool handleGuaranteedWellDefinedOps(const Instruction *I,
     }
     case Instruction::Ret:
       if (I->getFunction()->hasRetAttribute(Attribute::NoUndef) &&
-          Handle(I->getOperand(0)))
+          Handle(cast<ReturnInst>(I)->getReturnValue()))
----------------
preames wrote:

Calling Handle with a nullptr seems surprising here.  I'd add a clause to the if condition to avoid calling Handle instead.

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


More information about the llvm-commits mailing list