diff options
| author | Justin Bogner <mail@justinbogner.com> | 2015-06-20 06:24:05 +0000 |
|---|---|---|
| committer | Justin Bogner <mail@justinbogner.com> | 2015-06-20 06:24:05 +0000 |
| commit | 485212f67c971584d4994daf38c70b651682ad3b (patch) | |
| tree | 4742269b31c1ac9ac06e13563e31d4969cceb580 /llvm/lib/Transforms | |
| parent | 34d3376afc51813df319378610de6d2ec467f87a (diff) | |
| download | bcm5719-llvm-485212f67c971584d4994daf38c70b651682ad3b.tar.gz bcm5719-llvm-485212f67c971584d4994daf38c70b651682ad3b.zip | |
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.
llvm-svn: 240214
Diffstat (limited to 'llvm/lib/Transforms')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/IndVarSimplify.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp index ad2c9726dac..e931382ea98 100644 --- a/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp +++ b/llvm/lib/Transforms/Scalar/IndVarSimplify.cpp @@ -2013,10 +2013,11 @@ bool IndVarSimplify::runOnLoop(Loop *L, LPPassManager &LPM) { // Now that we're done iterating through lists, clean up any instructions // which are now dead. - while (!DeadInsts.empty()) - if (Instruction *Inst = - dyn_cast_or_null<Instruction>(&*DeadInsts.pop_back_val())) + while (!DeadInsts.empty()) { + Value *V = static_cast<Value *>(DeadInsts.pop_back_val()); + if (Instruction *Inst = dyn_cast_or_null<Instruction>(V)) RecursivelyDeleteTriviallyDeadInstructions(Inst, TLI); + } // The Rewriter may not be used from this point on. |

