forked from OSchip/llvm-project
LoopReroll::isLoopControlIV - use cast<> instead of dyn_cast<> to avoid dereference of nullptr
The pointer is always dereferenced by isCompareUsedByBranch, so assert the cast is correct instead of returning nullptr
This commit is contained in:
parent
37bd80cd98
commit
a5d6851489
|
@ -559,12 +559,12 @@ bool LoopReroll::isLoopControlIV(Loop *L, Instruction *IV) {
|
|||
}
|
||||
// Must be a CMP or an ext (of a value with nsw) then CMP
|
||||
else {
|
||||
Instruction *UUser = dyn_cast<Instruction>(UU);
|
||||
auto *UUser = cast<Instruction>(UU);
|
||||
// Skip SExt if we are extending an nsw value
|
||||
// TODO: Allow ZExt too
|
||||
if (BO->hasNoSignedWrap() && UUser && UUser->hasOneUse() &&
|
||||
if (BO->hasNoSignedWrap() && UUser->hasOneUse() &&
|
||||
isa<SExtInst>(UUser))
|
||||
UUser = dyn_cast<Instruction>(*(UUser->user_begin()));
|
||||
UUser = cast<Instruction>(*(UUser->user_begin()));
|
||||
if (!isCompareUsedByBranch(UUser))
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue