[llvm] c2dd36c - [Coverity] Fix unchecked return value, NFC

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Mon May 1 22:43:39 PDT 2023


Author: Phoebe Wang
Date: 2023-05-02T13:43:28+08:00
New Revision: c2dd36cd398ae7e1685476adcb0653caaa028d27

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

LOG: [Coverity] Fix unchecked return value, NFC

The `ReversePredicate` should have made sure the reverse predicate is
supported by target, but the check comes from early function and might
be invalid by any mistake. So it's better to double confirm it here.

Differential Revision: https://reviews.llvm.org/D149586

Added: 
    

Modified: 
    llvm/lib/CodeGen/EarlyIfConversion.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/EarlyIfConversion.cpp b/llvm/lib/CodeGen/EarlyIfConversion.cpp
index a0dfff7270595..86c3d96b1bf08 100644
--- a/llvm/lib/CodeGen/EarlyIfConversion.cpp
+++ b/llvm/lib/CodeGen/EarlyIfConversion.cpp
@@ -343,8 +343,11 @@ bool SSAIfConv::canPredicateInstrs(MachineBasicBlock *MBB) {
 // Apply predicate to all instructions in the machine block.
 void SSAIfConv::PredicateBlock(MachineBasicBlock *MBB, bool ReversePredicate) {
   auto Condition = Cond;
-  if (ReversePredicate)
-    TII->reverseBranchCondition(Condition);
+  if (ReversePredicate) {
+    bool CanRevCond = !TII->reverseBranchCondition(Condition);
+    assert(CanRevCond && "Reversed predicate is not supported");
+    (void)CanRevCond;
+  }
   // Terminators don't need to be predicated as they will be removed.
   for (MachineBasicBlock::iterator I = MBB->begin(),
                                    E = MBB->getFirstTerminator();


        


More information about the llvm-commits mailing list