diff options
author | Florian Hahn <flo@fhahn.com> | 2019-07-20 12:25:47 +0000 |
---|---|---|
committer | Florian Hahn <flo@fhahn.com> | 2019-07-20 12:25:47 +0000 |
commit | 0a7faa4e3d9ff9f8eebc8be6a85123c5e5f50103 (patch) | |
tree | 49ed08c7bc85356df965a508411e9de283b24c46 /llvm/lib/Transforms/Utils/Local.cpp | |
parent | cbd28cd05bb11e9d76d71c6cc2d38d89dbb1fe1a (diff) | |
download | bcm5719-llvm-0a7faa4e3d9ff9f8eebc8be6a85123c5e5f50103.tar.gz bcm5719-llvm-0a7faa4e3d9ff9f8eebc8be6a85123c5e5f50103.zip |
[Local] Zap blockaddress without users in ConstantFoldTerminator.
If the blockaddress is not destoryed, the destination block will still
be marked as having its address taken, limiting further transformations.
I think there are other places where the dead blockaddress constants are kept
around, I'll look into that as follow up.
Reviewers: craig.topper, brzycki, davide
Reviewed By: brzycki, davide
Differential Revision: https://reviews.llvm.org/D64936
llvm-svn: 366633
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/Local.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp index 39b6b889f91..c2d4303ecb0 100644 --- a/llvm/lib/Transforms/Utils/Local.cpp +++ b/llvm/lib/Transforms/Utils/Local.cpp @@ -324,8 +324,14 @@ bool llvm::ConstantFoldTerminator(BasicBlock *BB, bool DeleteDeadConditions, Value *Address = IBI->getAddress(); IBI->eraseFromParent(); if (DeleteDeadConditions) + // Delete pointer cast instructions. RecursivelyDeleteTriviallyDeadInstructions(Address, TLI); + // Also zap the blockaddress constant if there are no users remaining, + // otherwise the destination is still marked as having its address taken. + if (BA->use_empty()) + BA->destroyConstant(); + // If we didn't find our destination in the IBI successor list, then we // have undefined behavior. Replace the unconditional branch with an // 'unreachable' instruction. |