Skip to content

Commit c2dd36c

Browse files
committed
[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
1 parent bd08f1b commit c2dd36c

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

llvm/lib/CodeGen/EarlyIfConversion.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -343,8 +343,11 @@ bool SSAIfConv::canPredicateInstrs(MachineBasicBlock *MBB) {
343343
// Apply predicate to all instructions in the machine block.
344344
void SSAIfConv::PredicateBlock(MachineBasicBlock *MBB, bool ReversePredicate) {
345345
auto Condition = Cond;
346-
if (ReversePredicate)
347-
TII->reverseBranchCondition(Condition);
346+
if (ReversePredicate) {
347+
bool CanRevCond = !TII->reverseBranchCondition(Condition);
348+
assert(CanRevCond && "Reversed predicate is not supported");
349+
(void)CanRevCond;
350+
}
348351
// Terminators don't need to be predicated as they will be removed.
349352
for (MachineBasicBlock::iterator I = MBB->begin(),
350353
E = MBB->getFirstTerminator();

0 commit comments

Comments
 (0)