[llvm] 667598d - Revert "[Clang] Fix nomerge attribute not working with __builtin_trap(), __debugbreak(), __builtin_verbose_trap() (#101549)"

Haowei Wu via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 14:47:24 PDT 2024


Author: Haowei Wu
Date: 2024-08-01T14:46:36-07:00
New Revision: 667598d84b16d1789ce90b231565e9e7bfdbe77d

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

LOG: Revert "[Clang] Fix nomerge attribute not working with __builtin_trap(), __debugbreak(), __builtin_verbose_trap() (#101549)"

This reverts commit 5e84646982d1ec9bc94e48dde4b47f03c044a156, which
broke 'nomerge.ll' test on llvm bots.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGExpr.cpp
    clang/test/CodeGen/attr-nomerge.cpp
    llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
    llvm/test/CodeGen/X86/nomerge.ll

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index a1dce741c78a1..bb671c5ab5813 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -3882,8 +3882,6 @@ llvm::CallInst *CodeGenFunction::EmitTrapCall(llvm::Intrinsic::ID IntrID) {
     TrapCall->addFnAttr(A);
   }
 
-  if (InNoMergeAttributedStmt)
-    TrapCall->addFnAttr(llvm::Attribute::NoMerge);
   return TrapCall;
 }
 

diff  --git a/clang/test/CodeGen/attr-nomerge.cpp b/clang/test/CodeGen/attr-nomerge.cpp
index b643920adde49..7305fb73cf1dc 100644
--- a/clang/test/CodeGen/attr-nomerge.cpp
+++ b/clang/test/CodeGen/attr-nomerge.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -emit-llvm %s -fms-extensions -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -triple x86_64-unknown-linux-gnu -o - | FileCheck %s
 
 class A {
 public:
@@ -42,9 +42,6 @@ void foo(int i, A *ap, B *bp) {
 
   A *newA = new B();
   delete newA;
-  [[clang::nomerge]] __builtin_trap();
-  [[clang::nomerge]] __debugbreak();
-  [[clang::nomerge]] __builtin_verbose_trap("check null", "Argument must not be null.");
 }
 
 int g(int i);
@@ -100,9 +97,6 @@ void something_else_again() {
 // CHECK: load ptr, ptr
 // CHECK: %[[AG:.*]] = load ptr, ptr
 // CHECK-NEXT: call void %[[AG]](ptr {{.*}}) #[[ATTR1]]
-// CHECK: call void @llvm.trap() #[[ATTR0]]
-// CHECK: call void @llvm.debugtrap() #[[ATTR0]]
-// CHECK: call void @llvm.trap() #[[ATTR0]]
 // CHECK: call void  @_ZN1AD1Ev(ptr {{.*}}) #[[ATTR1]]
 
 // CHECK-DAG: attributes #[[ATTR0]] = {{{.*}}nomerge{{.*}}}

diff  --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index a035fee6aafca..9f5e6466309e9 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -7448,8 +7448,6 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
         break;
       default: llvm_unreachable("unknown trap intrinsic");
       }
-      DAG.addNoMergeSiteInfo(DAG.getRoot().getNode(),
-                             I.hasFnAttr(Attribute::NoMerge));
       return;
     }
     TargetLowering::ArgListTy Args;
@@ -7466,7 +7464,7 @@ void SelectionDAGBuilder::visitIntrinsicCall(const CallInst &I,
         DAG.getExternalSymbol(TrapFuncName.data(),
                               TLI.getPointerTy(DAG.getDataLayout())),
         std::move(Args));
-    CLI.NoMerge = I.hasFnAttr(Attribute::NoMerge);
+
     std::pair<SDValue, SDValue> Result = TLI.LowerCallTo(CLI);
     DAG.setRoot(Result.second);
     return;

diff  --git a/llvm/test/CodeGen/X86/nomerge.ll b/llvm/test/CodeGen/X86/nomerge.ll
index d3e6feae87108..efbadf5b6911f 100644
--- a/llvm/test/CodeGen/X86/nomerge.ll
+++ b/llvm/test/CodeGen/X86/nomerge.ll
@@ -62,96 +62,4 @@ if.end:
 
 declare dso_local void @bar()
 
-define void @nomerge_trap(i32 %i) {
-; CHECK-LABEL: nomerge_trap:
-; CHECK:      # %bb.0: # %entry
-; CHECK:      # %bb.1: # %entry
-; CHECK:      # %bb.2: # %if.then
-; CHECK-NEXT: ud2
-; CHECK-NEXT: LBB1_3: # %if.then2
-; CHECK-NEXT: ud2
-; CHECK-NEXT: .LBB1_4: # %if.end3
-; CHECK-NEXT: ud2
-entry:
-  switch i32 %i, label %if.end3 [
-    i32 5, label %if.then
-    i32 7, label %if.then2
-  ]
-
-if.then:
-  tail call void @llvm.trap() #0
-  unreachable
-
-if.then2:
-  tail call void @llvm.trap() #0
-  unreachable
-
-if.end3:
-  tail call void @llvm.trap() #0
-  unreachable
-}
-
-declare dso_local void @llvm.trap()
-
-define void @nomerge_debugtrap(i32 %i) {
-; CHECK-LABEL: nomerge_debugtrap:
-; CHECK:      # %bb.0: # %entry
-; CHECK:      # %bb.1: # %entry
-; CHECK:      # %bb.2: # %if.then
-; CHECK-NEXT: int3
-; CHECK-NEXT: LBB2_3: # %if.then2
-; CHECK-NEXT: int3
-; CHECK-NEXT: .LBB2_4: # %if.end3
-; CHECK-NEXT: int3
-entry:
-  switch i32 %i, label %if.end3 [
-    i32 5, label %if.then
-    i32 7, label %if.then2
-  ]
-
-if.then:
-  tail call void @llvm.debugtrap() #0
-  unreachable
-
-if.then2:
-  tail call void @llvm.debugtrap() #0
-  unreachable
-
-if.end3:
-  tail call void @llvm.debugtrap() #0
-  unreachable
-}
-
-define void @nomerge_named_debugtrap(i32 %i) {
-; CHECK-LABEL: nomerge_named_debugtrap:
-; CHECK:      # %bb.0: # %entry
-; CHECK:      # %bb.1: # %entry
-; CHECK:      # %bb.2: # %if.then
-; CHECK-NEXT: callq trap_func at PLT
-; CHECK-NEXT: LBB3_3: # %if.then2
-; CHECK-NEXT: callq trap_func at PLT
-; CHECK-NEXT: .LBB3_4: # %if.end3
-; CHECK-NEXT: callq trap_func at PLT
-entry:
-  switch i32 %i, label %if.end3 [
-    i32 5, label %if.then
-    i32 7, label %if.then2
-  ]
-
-if.then:
-  tail call void @llvm.debugtrap() #1
-  unreachable
-
-if.then2:
-  tail call void @llvm.debugtrap() #1
-  unreachable
-
-if.end3:
-  tail call void @llvm.debugtrap() #1
-  unreachable
-}
-
-declare dso_local void @llvm.debugtrap()
-
 attributes #0 = { nomerge }
-attributes #1 = { nomerge "trap-func-name"="trap_func" }


        


More information about the llvm-commits mailing list