Add a hasPoisonGeneratingFlags proxy wrapper to Instruction [NFC]

This just cuts down on casts to Operator.
This commit is contained in:
Philip Reames 2021-11-16 08:48:16 -08:00
parent 7f287390d7
commit ed6b69a38f
2 changed files with 9 additions and 2 deletions

View File

@ -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();

View File

@ -141,6 +141,10 @@ bool Instruction::hasNoSignedWrap() const {
return cast<OverflowingBinaryOperator>(this)->hasNoSignedWrap();
}
bool Instruction::hasPoisonGeneratingFlags() const {
return cast<Operator>(this)->hasPoisonGeneratingFlags();
}
void Instruction::dropPoisonGeneratingFlags() {
switch (getOpcode()) {
case Instruction::Add:
@ -164,8 +168,7 @@ void Instruction::dropPoisonGeneratingFlags() {
}
// TODO: FastMathFlags!
assert(!cast<Operator>(this)->hasPoisonGeneratingFlags() &&
"must be kept in sync");
assert(!hasPoisonGeneratingFlags() && "must be kept in sync");
}
void Instruction::dropUndefImplyingAttrsAndUnknownMetadata(