diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h index 9ca7b530bf71..9878082ffffa 100644 --- a/llvm/include/llvm/IR/Instruction.h +++ b/llvm/include/llvm/IR/Instruction.h @@ -387,6 +387,10 @@ public: /// Determine whether the no signed wrap flag is set. bool hasNoSignedWrap() const; + /// Return true if this operator has flags which may cause this instruction + /// to evaluate to poison despite having non-poison inputs. + bool hasPoisonGeneratingFlags() const; + /// Drops flags that may cause this instruction to evaluate to poison despite /// having non-poison inputs. void dropPoisonGeneratingFlags(); diff --git a/llvm/lib/IR/Instruction.cpp b/llvm/lib/IR/Instruction.cpp index 2463773aefd1..a4659da7e807 100644 --- a/llvm/lib/IR/Instruction.cpp +++ b/llvm/lib/IR/Instruction.cpp @@ -141,6 +141,10 @@ bool Instruction::hasNoSignedWrap() const { return cast(this)->hasNoSignedWrap(); } +bool Instruction::hasPoisonGeneratingFlags() const { + return cast(this)->hasPoisonGeneratingFlags(); +} + void Instruction::dropPoisonGeneratingFlags() { switch (getOpcode()) { case Instruction::Add: @@ -164,8 +168,7 @@ void Instruction::dropPoisonGeneratingFlags() { } // TODO: FastMathFlags! - assert(!cast(this)->hasPoisonGeneratingFlags() && - "must be kept in sync"); + assert(!hasPoisonGeneratingFlags() && "must be kept in sync"); } void Instruction::dropUndefImplyingAttrsAndUnknownMetadata(