[llvm] fbcefff - Revert "[SimplifyCFG] When eliminating `unreachable` landing pads, mark `call`s as `nounwind`"

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 12 14:19:07 PST 2023


Author: Roman Lebedev
Date: 2023-01-13T01:18:56+03:00
New Revision: fbcefff9d0a3f5e97270ef8e7b8e0f2afc33dc1c

URL: https://github.com/llvm/llvm-project/commit/fbcefff9d0a3f5e97270ef8e7b8e0f2afc33dc1c
DIFF: https://github.com/llvm/llvm-project/commit/fbcefff9d0a3f5e97270ef8e7b8e0f2afc33dc1c.diff

LOG: Revert "[SimplifyCFG] When eliminating `unreachable` landing pads, mark `call`s as `nounwind`"

The bool is in the wrong place and might get implicitly converted from
the previous second argument - a pointer. Thinking about it more,
it's not really the best place for that functionality anyways,
only a single caller needs that.

This reverts commit 3c5b1f2d94d021005ce3769a4402d4a4ae843989.

Added: 
    

Modified: 
    llvm/include/llvm/Transforms/Utils/Local.h
    llvm/lib/Transforms/Utils/Local.cpp
    llvm/lib/Transforms/Utils/SimplifyCFG.cpp
    llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll
    llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
    llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll
    llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll
    llvm/test/Transforms/SimplifyCFG/X86/empty-cleanuppad.ll
    llvm/test/Transforms/SimplifyCFG/empty-catchpad.ll
    llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
    llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll
    llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll
    llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/Transforms/Utils/Local.h b/llvm/include/llvm/Transforms/Utils/Local.h
index d59c5e0033f5f..1ad1e7b948c16 100644
--- a/llvm/include/llvm/Transforms/Utils/Local.h
+++ b/llvm/include/llvm/Transforms/Utils/Local.h
@@ -360,12 +360,7 @@ BasicBlock *changeToInvokeAndSplitBasicBlock(CallInst *CI,
 ///
 /// \param BB  Block whose terminator will be replaced.  Its terminator must
 ///            have an unwind successor.
-/// \param WouldUnwindBeUB  What is the behaviour should the call actually
-///                         unwind? For example, if the original landing pad
-///                         unconditionally ended with `unreachable`,
-///                         then the unwind would be UB.
-void removeUnwindEdge(BasicBlock *BB, bool WouldUnwindBeUB = false,
-                      DomTreeUpdater *DTU = nullptr);
+void removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU = nullptr);
 
 /// Remove all blocks that can not be reached from the function's entry.
 ///

diff  --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 569eee3a39d6c..d5d0232d7c1e8 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -2557,14 +2557,11 @@ static bool markAliveBlocks(Function &F,
   return Changed;
 }
 
-void llvm::removeUnwindEdge(BasicBlock *BB, bool WouldUnwindBeUB,
-                            DomTreeUpdater *DTU) {
+void llvm::removeUnwindEdge(BasicBlock *BB, DomTreeUpdater *DTU) {
   Instruction *TI = BB->getTerminator();
 
   if (auto *II = dyn_cast<InvokeInst>(TI)) {
-    CallInst *CI = changeToCall(II, DTU);
-    if (WouldUnwindBeUB && !CI->doesNotThrow())
-      CI->setDoesNotThrow();
+    changeToCall(II, DTU);
     return;
   }
 

diff  --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
index 1ce412a4f5dca..870dc2b16a092 100644
--- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -5184,7 +5184,7 @@ bool SimplifyCFGOpt::simplifyUnreachable(UnreachableInst *UI) {
           DTU->applyUpdates(Updates);
           Updates.clear();
         }
-        removeUnwindEdge(TI->getParent(), /*WouldUnwindBeUB=*/true, DTU);
+        removeUnwindEdge(TI->getParent(), DTU);
         Changed = true;
       }
     } else if (auto *CSI = dyn_cast<CatchSwitchInst>(TI)) {

diff  --git a/llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll b/llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll
index bc5118cb39e83..d7368efa1eae6 100644
--- a/llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll
+++ b/llvm/test/Transforms/SimplifyCFG/2011-09-05-TrivialLPad.ll
@@ -7,7 +7,7 @@ declare void @bar()
 define i32 @foo() personality ptr @__gxx_personality_v0 {
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @bar() #[[ATTR0:[0-9]+]]
+; CHECK-NEXT:    call void @bar()
 ; CHECK-NEXT:    ret i32 0
 ;
 entry:
@@ -24,6 +24,3 @@ lpad:
 }
 
 declare i32 @__gxx_personality_v0(i32, i64, ptr, ptr)
-;.
-; CHECK: attributes #[[ATTR0]] = { nounwind }
-;.

diff  --git a/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll b/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
index 7fe32dfc244d7..94d1fa54159d7 100644
--- a/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
+++ b/llvm/test/Transforms/SimplifyCFG/UnreachableEliminate.ll
@@ -20,7 +20,7 @@ F:
 define void @test2() personality ptr @__gxx_personality_v0 {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @test2() #[[ATTR3:[0-9]+]]
+; CHECK-NEXT:    call void @test2()
 ; CHECK-NEXT:    ret void
 ;
 entry:
@@ -570,5 +570,4 @@ attributes #0 = { null_pointer_is_valid }
 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }
 ; CHECK: attributes #[[ATTR1:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
 ; CHECK: attributes #[[ATTR2:[0-9]+]] = { null_pointer_is_valid }
-; CHECK: attributes #[[ATTR3]] = { nounwind }
 ;.

diff  --git a/llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll b/llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll
index 321df6211f71e..dacd2ddc506a9 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/2010-03-30-InvokeCrash.ll
@@ -9,7 +9,7 @@ declare void @bar(i32)
 define void @foo() personality ptr @__gxx_personality_v0 {
 ; CHECK-LABEL: @foo(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @bar(i32 undef) #[[ATTR0:[0-9]+]]
+; CHECK-NEXT:    call void @bar(i32 undef)
 ; CHECK-NEXT:    ret void
 ;
 entry:
@@ -26,6 +26,3 @@ u:                                                ; preds = %entry
 }
 
 declare i32 @__gxx_personality_v0(...)
-;.
-; CHECK: attributes #[[ATTR0]] = { nounwind }
-;.

diff  --git a/llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll b/llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll
index 6cbc1cbf7465c..da5c976873d72 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/bug-25299.ll
@@ -9,10 +9,10 @@ target triple = "x86_64-unknown-linux-gnu"
 define void @f(i1 %B) personality i1 undef {
 ; CHECK-LABEL: @f(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @g() #[[ATTR0:[0-9]+]]
+; CHECK-NEXT:    call void @g()
 ; CHECK-NEXT:    br label [[CONTINUE:%.*]]
 ; CHECK:       continue:
-; CHECK-NEXT:    call void @g() #[[ATTR0]]
+; CHECK-NEXT:    call void @g()
 ; CHECK-NEXT:    br label [[CONTINUE]]
 ;
 entry:
@@ -42,6 +42,3 @@ cleanup2:                                         ; preds = %continue
 }
 
 declare void @g()
-;.
-; CHECK: attributes #[[ATTR0]] = { nounwind }
-;.

diff  --git a/llvm/test/Transforms/SimplifyCFG/X86/empty-cleanuppad.ll b/llvm/test/Transforms/SimplifyCFG/X86/empty-cleanuppad.ll
index e6fdcba655b21..7e86b342ede22 100644
--- a/llvm/test/Transforms/SimplifyCFG/X86/empty-cleanuppad.ll
+++ b/llvm/test/Transforms/SimplifyCFG/X86/empty-cleanuppad.ll
@@ -20,7 +20,7 @@ target triple = "x86_64-pc-windows-msvc18.0.0"
 define void @f1() personality ptr @__CxxFrameHandler3 {
 ; CHECK-LABEL: @f1(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @g() #[[ATTR1:[0-9]+]]
+; CHECK-NEXT:    call void @g()
 ; CHECK-NEXT:    ret void
 ;
 entry:
@@ -189,7 +189,7 @@ ehcleanup.1:
 define void @f4() personality ptr @__CxxFrameHandler3 {
 ; CHECK-LABEL: @f4(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @g() #[[ATTR1]]
+; CHECK-NEXT:    call void @g()
 ; CHECK-NEXT:    invoke void @g()
 ; CHECK-NEXT:    to label [[TRY_CONT:%.*]] unwind label [[CATCH_DISPATCH:%.*]]
 ; CHECK:       catch.dispatch:
@@ -473,7 +473,7 @@ try.cont:
 define void @f10(i32 %V) personality ptr @__CxxFrameHandler3 {
 ; CHECK-LABEL: @f10(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @g() #[[ATTR1]]
+; CHECK-NEXT:    call void @g()
 ; CHECK-NEXT:    unreachable
 ;
 entry:
@@ -559,5 +559,4 @@ declare void @llvm.lifetime.start.p0(i64, ptr nocapture)
 declare void @llvm.lifetime.end.p0(i64, ptr nocapture)
 ;.
 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
-; CHECK: attributes #[[ATTR1]] = { nounwind }
 ;.

diff  --git a/llvm/test/Transforms/SimplifyCFG/empty-catchpad.ll b/llvm/test/Transforms/SimplifyCFG/empty-catchpad.ll
index e86425b9f25b0..767817bf1c5d7 100644
--- a/llvm/test/Transforms/SimplifyCFG/empty-catchpad.ll
+++ b/llvm/test/Transforms/SimplifyCFG/empty-catchpad.ll
@@ -40,7 +40,7 @@ exit:
 define void @test2() personality ptr @ProcessCLRException {
 ; CHECK-LABEL: @test2(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @f() #[[ATTR0:[0-9]+]]
+; CHECK-NEXT:    call void @f()
 ; CHECK-NEXT:    invoke void @f()
 ; CHECK-NEXT:    to label [[VIA_CATCHSWITCH:%.*]] unwind label [[CLEANUP_INNER:%.*]]
 ; CHECK:       cleanup.inner:
@@ -155,5 +155,5 @@ exit:
   ret void
 }
 ;.
-; CHECK: attributes #[[ATTR0]] = { nounwind }
+; CHECK: attributes #[[ATTR0:[0-9]+]] = { nounwind }
 ;.

diff  --git a/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll b/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
index 7f47132f12d5f..32ec9b23ad2fe 100644
--- a/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
+++ b/llvm/test/Transforms/SimplifyCFG/invoke_unwind.ll
@@ -7,7 +7,7 @@ declare void @bar()
 ; instructions to call instructions if the handler just rethrows the exception.
 define i32 @test1() personality ptr @__gxx_personality_v0 {
 ; CHECK-LABEL: @test1(
-; CHECK-NEXT:    call void @bar() #[[ATTR0:[0-9]+]], !prof [[PROF0:![0-9]+]]
+; CHECK-NEXT:    call void @bar(), !prof [[PROF0:![0-9]+]]
 ; CHECK-NEXT:    ret i32 0
 ;
   invoke void @bar( )
@@ -23,7 +23,7 @@ Rethrow:
 
 define i32 @test2() personality ptr @__gxx_personality_v0 {
 ; CHECK-LABEL: @test2(
-; CHECK-NEXT:    call void @bar() #[[ATTR0]] [ "foo"(i32 100) ]
+; CHECK-NEXT:    call void @bar() [ "foo"(i32 100) ]
 ; CHECK-NEXT:    ret i32 0
 ;
   invoke void @bar( ) [ "foo"(i32 100) ]
@@ -46,10 +46,10 @@ define i64 @test3(i1 %cond) personality ptr @__gxx_personality_v0 {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    br i1 [[COND:%.*]], label [[BR1:%.*]], label [[BR2:%.*]]
 ; CHECK:       br1:
-; CHECK-NEXT:    [[CALL1:%.*]] = call i64 @dummy1() #[[ATTR0]]
+; CHECK-NEXT:    [[CALL1:%.*]] = call i64 @dummy1()
 ; CHECK-NEXT:    br label [[INVOKE_CONT:%.*]]
 ; CHECK:       br2:
-; CHECK-NEXT:    [[CALL2:%.*]] = call i64 @dummy2() #[[ATTR0]]
+; CHECK-NEXT:    [[CALL2:%.*]] = call i64 @dummy2()
 ; CHECK-NEXT:    br label [[INVOKE_CONT]]
 ; CHECK:       invoke.cont:
 ; CHECK-NEXT:    [[C:%.*]] = phi i64 [ [[CALL1]], [[BR1]] ], [ [[CALL2]], [[BR2]] ]
@@ -88,7 +88,5 @@ lpad2:
 
 declare i32 @__gxx_personality_v0(...)
 ;.
-; CHECK: attributes #[[ATTR0]] = { nounwind }
-;.
 ; CHECK: [[PROF0]] = !{!"branch_weights", i32 371}
 ;.

diff  --git a/llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll b/llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll
index d9d845a66d7a6..ff031e95bc042 100644
--- a/llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll
+++ b/llvm/test/Transforms/SimplifyCFG/invoke_unwind_lifetime.ll
@@ -28,10 +28,10 @@ define void @caller(i1 %c) personality ptr @__gxx_personality_v0 {
 ; CHECK-NEXT:    call void @escape(ptr [[I6]])
 ; CHECK-NEXT:    br i1 [[C:%.*]], label [[V0:%.*]], label [[V1:%.*]]
 ; CHECK:       v0:
-; CHECK-NEXT:    call void @throwing_callee_foo() #[[ATTR1:[0-9]+]]
+; CHECK-NEXT:    call void @throwing_callee_foo()
 ; CHECK-NEXT:    unreachable
 ; CHECK:       v1:
-; CHECK-NEXT:    call void @throwing_callee_bar() #[[ATTR1]]
+; CHECK-NEXT:    call void @throwing_callee_bar()
 ; CHECK-NEXT:    unreachable
 ;
 entry:
@@ -82,5 +82,4 @@ end:
 }
 ;.
 ; CHECK: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
-; CHECK: attributes #[[ATTR1]] = { nounwind }
 ;.

diff  --git a/llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll b/llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll
index 1bb405b9af020..0174eb149581c 100644
--- a/llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll
+++ b/llvm/test/Transforms/SimplifyCFG/lifetime-landingpad.ll
@@ -6,7 +6,7 @@ define void @foo() personality ptr @__gxx_personality_v0 {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:    [[A:%.*]] = alloca i8, align 1
 ; CHECK-NEXT:    call void @llvm.lifetime.start.p0(i64 1, ptr nonnull [[A]]) #[[ATTR1:[0-9]+]]
-; CHECK-NEXT:    call void @bar() #[[ATTR1]]
+; CHECK-NEXT:    call void @bar()
 ; CHECK-NEXT:    call void @llvm.lifetime.end.p0(i64 1, ptr nonnull [[A]]) #[[ATTR1]]
 ; CHECK-NEXT:    ret void
 ;

diff  --git a/llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll b/llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll
index 0d495f95afe6e..9828db2a69853 100644
--- a/llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll
+++ b/llvm/test/Transforms/SimplifyCFG/wineh-unreachable.ll
@@ -7,7 +7,7 @@ declare void @f()
 define void @test1() personality ptr @Personality {
 ; CHECK-LABEL: @test1(
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:    call void @f() #[[ATTR0:[0-9]+]]
+; CHECK-NEXT:    call void @f()
 ; CHECK-NEXT:    ret void
 ;
 entry:
@@ -61,7 +61,7 @@ define void @test3() personality ptr @Personality {
 ; CHECK-NEXT:    to label [[EXIT:%.*]] unwind label [[CLEANUP_PAD:%.*]]
 ; CHECK:       cleanup.pad:
 ; CHECK-NEXT:    [[CLEANUP:%.*]] = cleanuppad within none []
-; CHECK-NEXT:    call void @f() #[[ATTR0]]
+; CHECK-NEXT:    call void @f()
 ; CHECK-NEXT:    unreachable
 ; CHECK:       exit:
 ; CHECK-NEXT:    ret void
@@ -238,6 +238,3 @@ catch.body2:
 exit:
   ret void
 }
-;.
-; CHECK: attributes #[[ATTR0]] = { nounwind }
-;.


        


More information about the llvm-commits mailing list