mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-26 22:26:16 +00:00
IndVarSimplify: Avoid UB from binding a reference to a null pointer
Calling operator* on a WeakVH whose Value is null hits undefined behaviour, since we bind the value to a reference. Instead, go through `operator Value*` so that we work with the pointer itself. Found by ubsan. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240214 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
ac5e008dfd
commit
40f8babe9a
@ -2013,10 +2013,11 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) {
|
|||||||
|
|
||||||
// Now that we're done iterating through lists, clean up any instructions
|
// Now that we're done iterating through lists, clean up any instructions
|
||||||
// which are now dead.
|
// which are now dead.
|
||||||
while (!DeadInsts.empty())
|
while (!DeadInsts.empty()) {
|
||||||
if (Instruction *Inst =
|
Value *V = static_cast<Value *>(DeadInsts.pop_back_val());
|
||||||
dyn_cast_or_null<Instruction>(&*DeadInsts.pop_back_val()))
|
if (Instruction *Inst = dyn_cast_or_null<Instruction>(V))
|
||||||
RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI);
|
RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI);
|
||||||
|
}
|
||||||
|
|
||||||
// The Rewriter may not be used from this point on.
|
// The Rewriter may not be used from this point on.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user