diff options
| author | Max Kazantsev <mkazantsev@azul.com> | 2022-07-18 16:13:58 +0700 |
|---|---|---|
| committer | Max Kazantsev <mkazantsev@azul.com> | 2022-07-18 16:26:06 +0700 |
| commit | d693fd29f1885e72b90428999aee92573abb9c2d (patch) | |
| tree | 00091cb97def49b8c2f74515a79a024951ee5300 /llvm/lib/IR/IntrinsicInst.cpp | |
| parent | 28b1ba1c0742a521037df7ef3a45cc969863eb06 (diff) | |
| download | llvm-d693fd29f1885e72b90428999aee92573abb9c2d.zip llvm-d693fd29f1885e72b90428999aee92573abb9c2d.tar.gz llvm-d693fd29f1885e72b90428999aee92573abb9c2d.tar.bz2 | |
[Verifier] Make Verifier recognize undef tokens as correct IR
Undef tokens may appear in unreached code as result of RAUW of some optimization,
and it should not be considered as bad IR.
Patch by Dmitry Bakunevich!
Differential Revision: https://reviews.llvm.org/D128904
Reviewed By: mkazantsev
Diffstat (limited to 'llvm/lib/IR/IntrinsicInst.cpp')
| -rw-r--r-- | llvm/lib/IR/IntrinsicInst.cpp | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/llvm/lib/IR/IntrinsicInst.cpp b/llvm/lib/IR/IntrinsicInst.cpp index 65a9a32..c50d690 100644 --- a/llvm/lib/IR/IntrinsicInst.cpp +++ b/llvm/lib/IR/IntrinsicInst.cpp @@ -694,8 +694,10 @@ unsigned BinaryOpIntrinsic::getNoWrapKind() const { return OverflowingBinaryOperator::NoUnsignedWrap; } -const GCStatepointInst *GCProjectionInst::getStatepoint() const { +const Value *GCProjectionInst::getStatepoint() const { const Value *Token = getArgOperand(0); + if (isa<UndefValue>(Token)) + return Token; // This takes care both of relocates for call statepoints and relocates // on normal path of invoke statepoint. @@ -714,13 +716,23 @@ const GCStatepointInst *GCProjectionInst::getStatepoint() const { } Value *GCRelocateInst::getBasePtr() const { - if (auto Opt = getStatepoint()->getOperandBundle(LLVMContext::OB_gc_live)) + auto Statepoint = getStatepoint(); + if (isa<UndefValue>(Statepoint)) + return UndefValue::get(Statepoint->getType()); + + auto *GCInst = cast<GCStatepointInst>(Statepoint); + if (auto Opt = GCInst->getOperandBundle(LLVMContext::OB_gc_live)) return *(Opt->Inputs.begin() + getBasePtrIndex()); - return *(getStatepoint()->arg_begin() + getBasePtrIndex()); + return *(GCInst->arg_begin() + getBasePtrIndex()); } Value *GCRelocateInst::getDerivedPtr() const { - if (auto Opt = getStatepoint()->getOperandBundle(LLVMContext::OB_gc_live)) + auto *Statepoint = getStatepoint(); + if (isa<UndefValue>(Statepoint)) + return UndefValue::get(Statepoint->getType()); + + auto *GCInst = cast<GCStatepointInst>(Statepoint); + if (auto Opt = GCInst->getOperandBundle(LLVMContext::OB_gc_live)) return *(Opt->Inputs.begin() + getDerivedPtrIndex()); - return *(getStatepoint()->arg_begin() + getDerivedPtrIndex()); + return *(GCInst->arg_begin() + getDerivedPtrIndex()); } |
