[llvm] r369575 - [Attributor] Use existing unreachable instead of introducing new ones

Johannes Doerfert via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 13:56:41 PDT 2019


Author: jdoerfert
Date: Wed Aug 21 13:56:41 2019
New Revision: 369575

URL: http://llvm.org/viewvc/llvm-project?rev=369575&view=rev
Log:
[Attributor] Use existing unreachable instead of introducing new ones

So far we split the unreachable off and placed a new one, this is not
necessary.

Modified:
    llvm/trunk/lib/Transforms/IPO/Attributor.cpp
    llvm/trunk/test/Transforms/FunctionAttrs/liveness.ll

Modified: llvm/trunk/lib/Transforms/IPO/Attributor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Attributor.cpp?rev=369575&r1=369574&r2=369575&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Attributor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Attributor.cpp Wed Aug 21 13:56:41 2019
@@ -1631,6 +1631,9 @@ struct AAIsDeadImpl : public AAIsDead {
       Instruction *I = const_cast<Instruction *>(NRC);
       BasicBlock *BB = I->getParent();
       Instruction *SplitPos = I->getNextNode();
+      // TODO: mark stuff before unreachable instructions as dead.
+      if (isa_and_nonnull<UnreachableInst>(SplitPos))
+        continue;
 
       if (auto *II = dyn_cast<InvokeInst>(I)) {
         // If we keep the invoke the split position is at the beginning of the

Modified: llvm/trunk/test/Transforms/FunctionAttrs/liveness.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/liveness.ll?rev=369575&r1=369574&r2=369575&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/liveness.ll (original)
+++ llvm/trunk/test/Transforms/FunctionAttrs/liveness.ll Wed Aug 21 13:56:41 2019
@@ -408,3 +408,13 @@ define internal i8* @f3(i8* readnone %0)
   %6 = phi i8* [ %4, %3 ], [ @a1, %1 ]
   ret i8* %6
 }
+
+define void @test_unreachable() {
+; CHECK:       define void @test_unreachable()
+; CHECK-NEXT:    call void @test_unreachable()
+; CHECK-NEXT:    unreachable
+; CHECK-NEXT:  }
+  call void @test_unreachable()
+  unreachable
+}
+




More information about the llvm-commits mailing list