From ed6b69a38f9944a1831f8c36825ae41fbe9bf637 Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Tue, 16 Nov 2021 08:48:16 -0800 Subject: [PATCH] Add a hasPoisonGeneratingFlags proxy wrapper to Instruction [NFC] This just cuts down on casts to Operator. --- llvm/include/llvm/IR/Instruction.h | 4 ++++ llvm/lib/IR/Instruction.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h index 9ca7b53..9878082 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 2463773..a4659da 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( -- 2.7.4