[PATCH] D64936: [Local] Zap blockaddress without users in ConstantFoldTerminator.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jul 20 05:25:48 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL366633: [Local] Zap blockaddress without users in ConstantFoldTerminator. (authored by fhahn, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D64936?vs=210624&id=210955#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64936/new/

https://reviews.llvm.org/D64936

Files:
  llvm/trunk/lib/Transforms/Utils/Local.cpp
  llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll


Index: llvm/trunk/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/trunk/lib/Transforms/Utils/Local.cpp
+++ llvm/trunk/lib/Transforms/Utils/Local.cpp
@@ -324,8 +324,14 @@
       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.
Index: llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll
===================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll
+++ llvm/trunk/test/Transforms/SimplifyCFG/dce-cond-after-folding-terminator.ll
@@ -37,10 +37,7 @@
 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]


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D64936.210955.patch
Type: text/x-patch
Size: 1531 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190720/5f28b1fd/attachment.bin>


More information about the llvm-commits mailing list