Skip to content

Commit

Permalink
[Coverity] Fix unchecked return value, NFC
Browse files Browse the repository at this point in the history
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
  • Loading branch information
phoebewang committed May 2, 2023
1 parent bd08f1b commit c2dd36c
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions llvm/lib/CodeGen/EarlyIfConversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit c2dd36c

Please sign in to comment.