[llvm] ed6b69a - Add a hasPoisonGeneratingFlags proxy wrapper to Instruction [NFC]

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 16 08:59:46 PST 2021


Author: Philip Reames
Date: 2021-11-16T08:48:16-08:00
New Revision: ed6b69a38f9944a1831f8c36825ae41fbe9bf637

URL: https://github.com/llvm/llvm-project/commit/ed6b69a38f9944a1831f8c36825ae41fbe9bf637
DIFF: https://github.com/llvm/llvm-project/commit/ed6b69a38f9944a1831f8c36825ae41fbe9bf637.diff

LOG: Add a hasPoisonGeneratingFlags proxy wrapper to Instruction [NFC]

This just cuts down on casts to Operator.

Added: 
    

Modified: 
    llvm/include/llvm/IR/Instruction.h
    llvm/lib/IR/Instruction.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Instruction.h b/llvm/include/llvm/IR/Instruction.h
index 9ca7b530bf712..9878082ffffaf 100644
--- a/llvm/include/llvm/IR/Instruction.h
+++ b/llvm/include/llvm/IR/Instruction.h
@@ -387,6 +387,10 @@ class Instruction : public User,
   /// 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 2463773aefd1f..a4659da7e8073 100644
--- a/llvm/lib/IR/Instruction.cpp
+++ b/llvm/lib/IR/Instruction.cpp
@@ -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(


        


More information about the llvm-commits mailing list