diff options
author | Johannes Doerfert <johannes@jdoerfert.de> | 2020-01-07 15:10:30 -0600 |
---|---|---|
committer | Johannes Doerfert <johannes@jdoerfert.de> | 2020-01-08 19:32:37 -0600 |
commit | 1e46eb74be6527377e47090bbe0fc9298f7de2c5 (patch) | |
tree | beb4f5997c1a613bd0328ebfc8d9b29007b748ee /llvm/lib | |
parent | 76aab66d34446ccf764cf8127b73e1517df75fb4 (diff) | |
download | bcm5719-llvm-1e46eb74be6527377e47090bbe0fc9298f7de2c5.tar.gz bcm5719-llvm-1e46eb74be6527377e47090bbe0fc9298f7de2c5.zip |
[Attributor][FIX] Avoid dangling value pointers during code modification
When we replace instructions with unreachable we delete instructions. We
now avoid dangling pointers to those deleted instructions in the
`ToBeChangedToUnreachableInsts` set. Other modification collections
might need to be updated in the future as well.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/IPO/Attributor.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp index 13fcf6aa724..b3b9e1e185a 100644 --- a/llvm/lib/Transforms/IPO/Attributor.cpp +++ b/llvm/lib/Transforms/IPO/Attributor.cpp @@ -5668,8 +5668,9 @@ ChangeStatus Attributor::run(Module &M) { } } } - for (Instruction *I : ToBeChangedToUnreachableInsts) - changeToUnreachable(I, /* UseLLVMTrap */ false); + for (auto &V : ToBeChangedToUnreachableInsts) + if (Instruction *I = dyn_cast_or_null<Instruction>(V)) + changeToUnreachable(I, /* UseLLVMTrap */ false); for (Instruction *I : TerminatorsToFold) ConstantFoldTerminator(I->getParent()); |