forked from OSchip/llvm-project
[SCEVExpander] GetOptimalInsertionPointForCastOf(): gracefully handle Constant's
I guess this case hasn't come up thus far, and i'm not sure if it can really happen for the existing usages, thus no test in *this* commit. But, the following commit adds test coverage, there we'd expirience a crash without this fix.
This commit is contained in:
parent
b8a3705896
commit
442c408e0e
|
@ -130,8 +130,17 @@ SCEVExpander::GetOptimalInsertionPointForCastOf(Value *V) const {
|
|||
}
|
||||
|
||||
// Cast the instruction immediately after the instruction.
|
||||
Instruction *I = cast<Instruction>(V);
|
||||
return findInsertPointAfter(I, &*Builder.GetInsertPoint());
|
||||
if (Instruction *I = dyn_cast<Instruction>(V))
|
||||
return findInsertPointAfter(I, &*Builder.GetInsertPoint());
|
||||
|
||||
// Otherwise, this must be some kind of a constant,
|
||||
// so let's plop this cast into the function's entry block.
|
||||
assert(isa<Constant>(V) &&
|
||||
"Expected the cast argument to be a global/constant");
|
||||
return Builder.GetInsertBlock()
|
||||
->getParent()
|
||||
->getEntryBlock()
|
||||
.getFirstInsertionPt();
|
||||
}
|
||||
|
||||
/// InsertNoopCastOfTo - Insert a cast of V to the specified type,
|
||||
|
|
Loading…
Reference in New Issue