summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2020-01-07 15:10:30 -0600
committerJohannes Doerfert <johannes@jdoerfert.de>2020-01-08 19:32:37 -0600
commit1e46eb74be6527377e47090bbe0fc9298f7de2c5 (patch)
treebeb4f5997c1a613bd0328ebfc8d9b29007b748ee /llvm/lib
parent76aab66d34446ccf764cf8127b73e1517df75fb4 (diff)
downloadbcm5719-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.cpp5
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());
OpenPOWER on IntegriCloud