[llvm] r366633 - [Local] Zap blockaddress without users in ConstantFoldTerminator.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 20 05:25:47 PDT 2019
Author: fhahn
Date: Sat Jul 20 05:25:47 2019
New Revision: 366633
URL: http://llvm.org/viewvc/llvm-project?rev=366633&view=rev
Log:
[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
Modified:
llvm/trunk/lib/Transforms/Utils/Local.cpp
llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll
Modified: llvm/trunk/lib/Transforms/Utils/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/Local.cpp?rev=366633&r1=366632&r2=366633&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp Sat Jul 20 05:25:47 2019
@@ -324,8 +324,14 @@ bool llvm::ConstantFoldTerminator(BasicB
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.
Modified: llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll?rev=366633&r1=366632&r2=366633&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll (original)
+++ llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll Sat Jul 20 05:25:47 2019
@@ -37,10 +37,7 @@ define void @test_indirectbr(i32 %x) {
entry:
; CHECK-LABEL: @test_indirectbr(
; CHECK-NEXT: entry:
-; Ideally this should now check:
-; CHK-NEXT: ret void
-; But that doesn't happen yet. Instead:
-; CHECK-NEXT: br label %L1
+; CHECK-NEXT: ret void
%label = bitcast i8* blockaddress(@test_indirectbr, %L1) to i8*
indirectbr i8* %label, [label %L1, label %L2]
More information about the llvm-commits
mailing list