From c2dd36cd398ae7e1685476adcb0653caaa028d27 Mon Sep 17 00:00:00 2001 From: Phoebe Wang Date: Mon, 1 May 2023 22:24:24 +0800 Subject: [PATCH] [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 --- llvm/lib/CodeGen/EarlyIfConversion.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/EarlyIfConversion.cpp b/llvm/lib/CodeGen/EarlyIfConversion.cpp index a0dfff72705959..86c3d96b1bf089 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();