llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clangir

Author: Andy Kaylor (andykaylor)

<details>
<summary>Changes</summary>

This adds support for setting the `nounwind` attribute on declarations and call 
sites in CIR.

Currently, we have both `nothrow` and `nounwind` in CIR. I've chosen to use 
`nothrow` in this PR because it was the most common. I plan to combine them, 
using `nounwind` everywhere since that's the LLVM IR spelling, but that's a 
more invasive so I'd like to defer it to a future change.

---

Patch is 81.61 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/187096.diff


53 Files Affected:

- (modified) clang/include/clang/CIR/MissingFeatures.h (-1) 
- (modified) clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp (+5-3) 
- (modified) clang/lib/CIR/CodeGen/CIRGenModule.cpp (+22) 
- (modified) clang/test/CIR/CodeGen/arg-attrs.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/dtors.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/lambda-static-invoker.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/lambda.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/misc-attrs.cpp (+8-8) 
- (modified) clang/test/CIR/CodeGen/noreturn.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/pointer-to-data-member.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/pointer-to-member-func.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/ret-attrs.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGen/side-effect.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGen/ternary.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGenBuiltins/builtin-fcmp-sse.c (+4-4) 
- (modified) clang/test/CIR/CodeGenCUDA/kernel-stub-name.cu (+3-3) 
- (modified) clang/test/CIR/CodeGenCXX/simple-reinterpret-const-cast.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGenHIP/simple.cpp (+8-8) 
- (modified) clang/test/CIR/CodeGenOpenACC/atomic-capture.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/atomic-update.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/atomic-write.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/combined-copyin-copyout-create.c 
(+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/combined.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGenOpenACC/compute-copyin-copyout-create.c 
(+1-1) 
- (modified) 
clang/test/CIR/CodeGenOpenACC/compute-firstprivate-clause-templates.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/compute-private-clause-templates.cpp 
(+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/data-copy-copyin-copyout-create.c 
(+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/data.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/declare-link.cpp (+3-3) 
- (modified) clang/test/CIR/CodeGenOpenACC/enter-data.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/exit-data.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/host_data.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/init.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/kernels.c (+2-2) 
- (modified) clang/test/CIR/CodeGenOpenACC/loop.cpp (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/parallel.c (+2-2) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-anon-ns.cpp (+3-3) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-bind.c (+12-12) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-bind.cpp (+19-19) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-clauses.cpp (+12-12) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-device_type.cpp (+14-14) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-globals.cpp (+4-4) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-globals2.cpp (+4-4) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-locals.cpp (+3-3) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-members.cpp (+8-8) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-ns.cpp (+3-3) 
- (modified) clang/test/CIR/CodeGenOpenACC/routine-templ.cpp (+2-2) 
- (modified) clang/test/CIR/CodeGenOpenACC/serial.c (+2-2) 
- (modified) clang/test/CIR/CodeGenOpenACC/set.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/shutdown.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/update.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenACC/wait.c (+1-1) 
- (modified) clang/test/CIR/CodeGenOpenMP/omp-llvmir.c (+1-1) 


``````````diff
diff --git a/clang/include/clang/CIR/MissingFeatures.h 
b/clang/include/clang/CIR/MissingFeatures.h
index b7b4d73afa0f8..68db08a5580ca 100644
--- a/clang/include/clang/CIR/MissingFeatures.h
+++ b/clang/include/clang/CIR/MissingFeatures.h
@@ -81,7 +81,6 @@ struct MissingFeatures {
   static bool opFuncMultipleReturnVals() { return false; }
   static bool opFuncNakedAttr() { return false; }
   static bool opFuncNoDuplicateAttr() { return false; }
-  static bool opFuncNoUnwind() { return false; }
   static bool opFuncOpenCLKernelMetadata() { return false; }
   static bool opFuncOperandBundles() { return false; }
   static bool opFuncOptNoneAttr() { return false; }
diff --git a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp 
b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
index 1f9f616ecbb58..d7e0f63399744 100644
--- a/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenItaniumCXXABI.cpp
@@ -2059,8 +2059,7 @@ static cir::FuncOp getItaniumDynamicCastFn(CIRGenFunction 
&cgf) {
   mlir::Type rttiPtrTy = cgf.getBuilder().getUInt8PtrTy();
   mlir::Type ptrDiffTy = 
cgf.convertType(cgf.getContext().getPointerDiffType());
 
-  // TODO(cir): mark the function as nowind willreturn readonly.
-  assert(!cir::MissingFeatures::opFuncNoUnwind());
+  // TODO(cir): mark the function as willreturn readonly.
   assert(!cir::MissingFeatures::opFuncWillReturn());
   assert(!cir::MissingFeatures::opFuncReadOnly());
 
@@ -2069,7 +2068,10 @@ static cir::FuncOp 
getItaniumDynamicCastFn(CIRGenFunction &cgf) {
 
   cir::FuncType FTy = cgf.getBuilder().getFuncType(
       {voidPtrTy, rttiPtrTy, rttiPtrTy, ptrDiffTy}, voidPtrTy);
-  return cgf.cgm.createRuntimeFunction(FTy, "__dynamic_cast");
+  cir::FuncOp fn = cgf.cgm.createRuntimeFunction(FTy, "__dynamic_cast");
+  fn->setAttr(cir::CIRDialect::getNoThrowAttrName(),
+              mlir::UnitAttr::get(cgf.getBuilder().getContext()));
+  return fn;
 }
 
 static Address emitDynamicCastToVoid(CIRGenFunction &cgf, mlir::Location loc,
diff --git a/clang/lib/CIR/CodeGen/CIRGenModule.cpp 
b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
index cb931f969a41d..228d625ff4747 100644
--- a/clang/lib/CIR/CodeGen/CIRGenModule.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenModule.cpp
@@ -2430,11 +2430,33 @@ void CIRGenModule::setFunctionAttributes(GlobalDecl 
globalDecl,
   }
 }
 
+/// Determines whether the language options require us to model
+/// unwind exceptions.  We treat -fexceptions as mandating this
+/// except under the fragile ObjC ABI with only ObjC exceptions
+/// enabled.  This means, for example, that C with -fexceptions
+/// enables this.
+static bool hasUnwindExceptions(const LangOptions &langOpts) {
+  // If exceptions are completely disabled, obviously this is false.
+  if (!langOpts.Exceptions)
+    return false;
+  // If C++ exceptions are enabled, this is true.
+  if (langOpts.CXXExceptions)
+    return true;
+  // If ObjC exceptions are enabled, this depends on the ABI.
+  if (langOpts.ObjCExceptions)
+    return langOpts.ObjCRuntime.hasUnwindExceptions();
+  return true;
+}
+
 void CIRGenModule::setCIRFunctionAttributesForDefinition(
     const clang::FunctionDecl *decl, cir::FuncOp f) {
   assert(!cir::MissingFeatures::opFuncUnwindTablesAttr());
   assert(!cir::MissingFeatures::stackProtector());
 
+  if (!hasUnwindExceptions(langOpts))
+    f->setAttr(cir::CIRDialect::getNoThrowAttrName(),
+               mlir::UnitAttr::get(&getMLIRContext()));
+
   std::optional<cir::InlineKind> existingInlineKind = f.getInlineKind();
   bool isNoInline =
       existingInlineKind && *existingInlineKind == cir::InlineKind::NoInline;
diff --git a/clang/test/CIR/CodeGen/arg-attrs.cpp 
b/clang/test/CIR/CodeGen/arg-attrs.cpp
index a66cf661dc66c..27b9522788667 100644
--- a/clang/test/CIR/CodeGen/arg-attrs.cpp
+++ b/clang/test/CIR/CodeGen/arg-attrs.cpp
@@ -15,10 +15,10 @@ struct Struct {
 };
 
 void Struct::this_func(){}
-  // CIR: cir.func {{.*}}@_ZN6Struct9this_funcEv(%{{.*}}: 
!cir.ptr<!rec_Struct> {llvm.align = 4 : i64, llvm.dereferenceable = 20 : i64, 
llvm.nonnull, llvm.noundef} {{.*}}) {
+  // CIR: cir.func {{.*}}@_ZN6Struct9this_funcEv(%{{.*}}: 
!cir.ptr<!rec_Struct> {llvm.align = 4 : i64, llvm.dereferenceable = 20 : i64, 
llvm.nonnull, llvm.noundef} {{.*}}) {{.*}} {
   // BOTH: define {{.*}}void @_ZN6Struct9this_funcEv(ptr noundef nonnull align 
4 dereferenceable(20) %{{.*}})
 void Struct::arg_attr(Struct s, int &i, Incomplete &j){}
-  // CIR: cir.func {{.*}}@_ZN6Struct8arg_attrES_RiR10Incomplete(%{{.*}}: 
!cir.ptr<!rec_Struct> {llvm.align = 4 : i64, llvm.dereferenceable = 20 : i64, 
llvm.nonnull, llvm.noundef} {{.*}}, %{{.*}}: !rec_Struct {{.*}}, %{{.*}}: 
!cir.ptr<!s32i> {llvm.align = 8 : i64, llvm.dereferenceable = 4 : i64, 
llvm.nonnull, llvm.noundef} {{.*}}, %arg3: !cir.ptr<!rec_Incomplete> 
{llvm.align = 8 : i64, llvm.nonnull, llvm.noundef} {{.*}}) {
+  // CIR: cir.func {{.*}}@_ZN6Struct8arg_attrES_RiR10Incomplete(%{{.*}}: 
!cir.ptr<!rec_Struct> {llvm.align = 4 : i64, llvm.dereferenceable = 20 : i64, 
llvm.nonnull, llvm.noundef} {{.*}}, %{{.*}}: !rec_Struct {{.*}}, %{{.*}}: 
!cir.ptr<!s32i> {llvm.align = 8 : i64, llvm.dereferenceable = 4 : i64, 
llvm.nonnull, llvm.noundef} {{.*}}, %arg3: !cir.ptr<!rec_Incomplete> 
{llvm.align = 8 : i64, llvm.nonnull, llvm.noundef} {{.*}}) {{.*}} {
   // LLVM: define {{.*}}void @_ZN6Struct8arg_attrES_RiR10Incomplete(ptr 
noundef nonnull align 4 dereferenceable(20) %{{.*}}, %struct.Struct %{{.*}}, 
ptr noundef nonnull align 8 dereferenceable(4) %{{.*}}, ptr noundef nonnull 
align 8 %{{.*}})
   // OGCG: define {{.*}}void @_ZN6Struct8arg_attrES_RiR10Incomplete(ptr 
noundef nonnull align 4 dereferenceable(20) %{{.*}}, ptr noundef 
byval(%struct.Struct) align 8 %{{.*}}, ptr noundef nonnull align 4 
dereferenceable(4) %{{.*}}, ptr noundef nonnull align 1 %{{.*}})
 
diff --git a/clang/test/CIR/CodeGen/dtors.cpp b/clang/test/CIR/CodeGen/dtors.cpp
index 0e84f4dd6da66..37cb766b1be62 100644
--- a/clang/test/CIR/CodeGen/dtors.cpp
+++ b/clang/test/CIR/CodeGen/dtors.cpp
@@ -340,7 +340,7 @@ int test_temp_in_condition(G &obj) {
   return 0;
 }
 
-// CIR: cir.func {{.*}} @_Z22test_temp_in_conditionR1G(%[[ARG0:.*]]: 
!cir.ptr<!rec_G> {{.*}}) -> (!s32i {{.*}}) {
+// CIR: cir.func {{.*}} @_Z22test_temp_in_conditionR1G(%[[ARG0:.*]]: 
!cir.ptr<!rec_G> {{.*}}) -> (!s32i {{.*}}) {{.*}} {
 // CIR:   %[[OBJ:.*]] = cir.alloca !cir.ptr<!rec_G>, 
!cir.ptr<!cir.ptr<!rec_G>>, ["obj", init, const]
 // CIR:   %[[RET_ADDR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
 // CIR:   cir.store %[[ARG0]], %[[OBJ]]
diff --git a/clang/test/CIR/CodeGen/lambda-static-invoker.cpp 
b/clang/test/CIR/CodeGen/lambda-static-invoker.cpp
index 2b00feccbc79a..04676f7700021 100644
--- a/clang/test/CIR/CodeGen/lambda-static-invoker.cpp
+++ b/clang/test/CIR/CodeGen/lambda-static-invoker.cpp
@@ -66,7 +66,7 @@ int g3() {
 // In OGCG, the _ZZ2g3vENK3$_0clERKi function is emitted after 
_ZZ2g3vEN3$_08__invokeERKi, see below.
 
 // lambda invoker
-// CIR: cir.func no_inline internal private dso_local 
@_ZZ2g3vEN3$_08__invokeERKi(%[[REF_I_ARG:.*]]: !cir.ptr<!s32i> {{.*}}) -> 
(!s32i{{.*}}) {
+// CIR: cir.func no_inline internal private dso_local 
@_ZZ2g3vEN3$_08__invokeERKi(%[[REF_I_ARG:.*]]: !cir.ptr<!s32i> {{.*}}) -> 
(!s32i{{.*}}) {{.*}} {
 // CIR:   %[[REF_I_ALLOCA:.*]] = cir.alloca {{.*}} ["i", init, const]
 // CIR:   %[[RETVAL:.*]] = cir.alloca {{.*}} ["__retval"]
 // CIR:   %[[LAM_ALLOCA:.*]] = cir.alloca ![[REC_LAM_G3]], 
!cir.ptr<![[REC_LAM_G3]]>, ["unused.capture"]
diff --git a/clang/test/CIR/CodeGen/lambda.cpp 
b/clang/test/CIR/CodeGen/lambda.cpp
index 6dc5e16d79e98..eae6dfa0d2bca 100644
--- a/clang/test/CIR/CodeGen/lambda.cpp
+++ b/clang/test/CIR/CodeGen/lambda.cpp
@@ -157,7 +157,7 @@ auto g() {
   };
 }
 
-// CIR: cir.func {{.*}} @_Z1gv() -> ![[REC_LAM_G:.*]] {
+// CIR: cir.func {{.*}} @_Z1gv() -> ![[REC_LAM_G:.*]] attributes {nothrow} {
 // CIR:   %[[RETVAL:.*]] = cir.alloca ![[REC_LAM_G]], 
!cir.ptr<![[REC_LAM_G]]>, ["__retval"]
 // CIR:   %[[I_ADDR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init]
 // CIR:   %[[TWELVE:.*]] = cir.const #cir.int<12> : !s32i
@@ -199,7 +199,7 @@ auto g2() {
 }
 
 // Should be same as above because of NRVO
-// CIR: cir.func {{.*}} @_Z2g2v() -> ![[REC_LAM_G2:.*]] {
+// CIR: cir.func {{.*}} @_Z2g2v() -> ![[REC_LAM_G2:.*]] attributes {nothrow} {
 // CIR:   %[[RETVAL:.*]] = cir.alloca ![[REC_LAM_G2]], 
!cir.ptr<![[REC_LAM_G2]]>, ["__retval", init]
 // CIR:   %[[I_ADDR:.*]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["i", init]
 // CIR:   %[[TWELVE:.*]] = cir.const #cir.int<12> : !s32i
diff --git a/clang/test/CIR/CodeGen/misc-attrs.cpp 
b/clang/test/CIR/CodeGen/misc-attrs.cpp
index 5a6686c5df788..4cfddc7c25666 100644
--- a/clang/test/CIR/CodeGen/misc-attrs.cpp
+++ b/clang/test/CIR/CodeGen/misc-attrs.cpp
@@ -6,47 +6,47 @@
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
 
 extern "C" {
-  // CIR: cir.func{{.*}}@returns_twice() attributes {returns_twice} {
+  // CIR: cir.func{{.*}}@returns_twice() attributes {nothrow, returns_twice} {
   // LLVM: Function Attrs:{{.*}}returns_twice
   // LLVM-NEXT: define{{.*}}@returns_twice() #[[RT_ATTR:.*]] {
   __attribute__((returns_twice))
   void returns_twice() {}
-  // CIR: cir.func{{.*}}@cold() attributes {cold} {
+  // CIR: cir.func{{.*}}@cold() attributes {cold, nothrow} {
   // LLVM: Function Attrs:{{.*}}cold
   // LLVM-NEXT: define{{.*}}@cold() #[[COLD_ATTR:.*]] {
   __attribute__((cold))
   void cold() {}
-  // CIR: cir.func{{.*}}@hot() attributes {hot} {
+  // CIR: cir.func{{.*}}@hot() attributes {hot, nothrow} {
   // LLVM: Function Attrs:{{.*}}hot
   // LLVM-NEXT: define{{.*}}@hot() #[[HOT_ATTR:.*]] {
   __attribute__((hot))
   void hot() {}
-  // CIR: cir.func{{.*}}@nodupes() attributes {noduplicate} {
+  // CIR: cir.func{{.*}}@nodupes() attributes {noduplicate, nothrow} {
   // LLVM: Function Attrs:{{.*}}noduplicate
   // LLVM-NEXT: define{{.*}}@nodupes() #[[ND_ATTR:.*]] {
   __attribute__((noduplicate))
   void nodupes() {}
-  // CIR: cir.func{{.*}}@convergent() attributes {convergent} {
+  // CIR: cir.func{{.*}}@convergent() attributes {convergent, nothrow} {
   // LLVM: Function Attrs:{{.*}}convergent
   // LLVM-NEXT: define{{.*}}@convergent() #[[CONV_ATTR:.*]] {
   __attribute__((convergent))
   void convergent() {}
 
-  // CIR: cir.func{{.*}}@no_caller_saved_registers() attributes 
{no_caller_saved_registers} {
+  // CIR: cir.func{{.*}}@no_caller_saved_registers() attributes 
{no_caller_saved_registers, nothrow} {
   // LLVM: Function Attrs:
   // LLVM-NOT: no_caller_saved_registers
   // LLVM-NEXT: define{{.*}}@no_caller_saved_registers() #[[NCSR_ATTR:.*]] {
   __attribute__((no_caller_saved_registers))
   void no_caller_saved_registers() {}
 
-  // CIR: cir.func{{.*}}@leaf() attributes {nocallback} {
+  // CIR: cir.func{{.*}}@leaf() attributes {nocallback, nothrow} {
   // LLVM: Function Attrs:
   // LLVM-NOT: leaf
   // LLVM-NEXT: define{{.*}}@leaf() #[[LEAF_ATTR:.*]] {
   __attribute__((leaf))
   void leaf() {}
 
-  // CIR: cir.func{{.*}}@modular_format({{.*}}) attributes {modular_format = 
"kprintf,1,2,someIdent,someStr,aspect,aspect2"} {
+  // CIR: cir.func{{.*}}@modular_format({{.*}}) attributes {modular_format = 
"kprintf,1,2,someIdent,someStr,aspect,aspect2", nothrow} {
   // LLVM: Function Attrs:
   // LLVM-NOT:modular_format
   // LLVM-NEXT: define{{.*}}@modular_format({{.*}}) #[[MOD_FORMAT_ATTR:.*]] {
diff --git a/clang/test/CIR/CodeGen/noreturn.cpp 
b/clang/test/CIR/CodeGen/noreturn.cpp
index 840f883062e7c..f55628ba08e03 100644
--- a/clang/test/CIR/CodeGen/noreturn.cpp
+++ b/clang/test/CIR/CodeGen/noreturn.cpp
@@ -6,7 +6,7 @@
 // RUN: FileCheck --input-file=%t.ll %s -check-prefixes=LLVM,OGCG
 
 extern "C" {
-// CIR: cir.func {{.*}} @bar() -> !s32i attributes {noreturn} {
+// CIR: cir.func {{.*}} @bar() -> !s32i attributes {noreturn, nothrow} {
 // LLVM: Function Attrs:{{.*}} noreturn
 // LLVM-NEXT: define {{.*}} i32 @bar() #[[BAR_FOO_ATTR:.*]] {
 __attribute((noreturn))
@@ -17,7 +17,7 @@ int bar() { }
 // lowering puts the trap decl at the end, so it isn't here to worry about.
 // OGCG: declare void @llvm.trap
 
-// CIR: cir.func {{.*}} @foo() -> !s32i attributes {noreturn} {
+// CIR: cir.func {{.*}} @foo() -> !s32i attributes {noreturn, nothrow} {
 // LLVM: Function Attrs:{{.*}} noreturn
 // LLVM-NEXT: define {{.*}} i32 @foo() #[[BAR_FOO_ATTR]] {
 [[noreturn]]
diff --git a/clang/test/CIR/CodeGen/pointer-to-data-member.cpp 
b/clang/test/CIR/CodeGen/pointer-to-data-member.cpp
index 78af6cf5bb8e6..3d88b989d23cb 100644
--- a/clang/test/CIR/CodeGen/pointer-to-data-member.cpp
+++ b/clang/test/CIR/CodeGen/pointer-to-data-member.cpp
@@ -52,14 +52,14 @@ int Point::*pt_member_nested_region = test1();
 
 // Checks for test1()
 
-// CIR-BEFORE: cir.func {{.*}} @_Z5test1v() -> !cir.data_member<!s32i in 
!rec_Point> {
+// CIR-BEFORE: cir.func {{.*}} @_Z5test1v() -> !cir.data_member<!s32i in 
!rec_Point> attributes {nothrow} {
 // CIR-BEFORE:   %[[RETVAL:.*]] = cir.alloca !cir.data_member<!s32i in 
!rec_Point>, !cir.ptr<!cir.data_member<!s32i in !rec_Point>>, ["__retval"]
 // CIR-BEFORE:   %[[MEMBER:.*]] = cir.const #cir.data_member<1> : 
!cir.data_member<!s32i in !rec_Point>
 // CIR-BEFORE:   cir.store %[[MEMBER]], %[[RETVAL]] : !cir.data_member<!s32i 
in !rec_Point>, !cir.ptr<!cir.data_member<!s32i in !rec_Point>>
 // CIR-BEFORE:   %[[RET:.*]] = cir.load %[[RETVAL]] : 
!cir.ptr<!cir.data_member<!s32i in !rec_Point>>, !cir.data_member<!s32i in 
!rec_Point>
 // CIR-BEFORE:   cir.return %[[RET]] : !cir.data_member<!s32i in !rec_Point>
 
-// CIR-AFTER: cir.func {{.*}} @_Z5test1v() -> !s64i {
+// CIR-AFTER: cir.func {{.*}} @_Z5test1v() -> !s64i attributes {nothrow} {
 // CIR-AFTER:   %[[RETVAL:.*]] = cir.alloca !s64i, !cir.ptr<!s64i>, 
["__retval"]
 // CIR-AFTER:   %[[OFFSET:.*]] = cir.const #cir.int<4> : !s64i
 // CIR-AFTER:   cir.store %[[OFFSET]], %[[RETVAL]] : !s64i, !cir.ptr<!s64i>
diff --git a/clang/test/CIR/CodeGen/pointer-to-member-func.cpp 
b/clang/test/CIR/CodeGen/pointer-to-member-func.cpp
index 80cda3b6452a4..540ecd93674bd 100644
--- a/clang/test/CIR/CodeGen/pointer-to-member-func.cpp
+++ b/clang/test/CIR/CodeGen/pointer-to-member-func.cpp
@@ -45,7 +45,7 @@ auto make_non_virtual() -> void (Foo::*)(int) {
 // CIR-BEFORE:   %[[RET:.*]] = cir.load %[[RETVAL]]
 // CIR-BEFORE:   cir.return %[[RET]] : 
!cir.method<!cir.func<(!cir.ptr<!rec_Foo>, !s32i)> in !rec_Foo>
 
-// CIR-AFTER: cir.func {{.*}} @_Z16make_non_virtualv() -> !rec_anon_struct {
+// CIR-AFTER: cir.func {{.*}} @_Z16make_non_virtualv() -> !rec_anon_struct 
attributes {nothrow} {
 // CIR-AFTER:   %[[RETVAL:.*]] = cir.alloca !rec_anon_struct, 
!cir.ptr<!rec_anon_struct>, ["__retval"]
 // CIR-AFTER:   %[[METHOD_PTR:.*]] = cir.get_global @[[NONVIRT_RET]] : 
!cir.ptr<!rec_anon_struct>
 // CIR-AFTER:   cir.copy %[[METHOD_PTR]] to %[[RETVAL]] : 
!cir.ptr<!rec_anon_struct>
diff --git a/clang/test/CIR/CodeGen/ret-attrs.cpp 
b/clang/test/CIR/CodeGen/ret-attrs.cpp
index 771d45ef28f97..9ef836791fea5 100644
--- a/clang/test/CIR/CodeGen/ret-attrs.cpp
+++ b/clang/test/CIR/CodeGen/ret-attrs.cpp
@@ -16,7 +16,7 @@ struct Struct{};
 using MemPtrTy = void (Struct::*)();
 
 MemPtrTy not_noundef_memptr(MemPtrTy t){}
-// CIR: cir.func no_inline dso_local 
@_Z18not_noundef_memptrM6StructFvvE({{.*}}) -> !rec_anon_struct {
+// CIR: cir.func no_inline dso_local 
@_Z18not_noundef_memptrM6StructFvvE({{.*}}) -> !rec_anon_struct attributes 
{nothrow} {
 // LLVM: define dso_local { i64, i64 } 
@_Z18not_noundef_memptrM6StructFvvE({{.*}})
 
 void not_noundef_void(){}
diff --git a/clang/test/CIR/CodeGen/side-effect.cpp 
b/clang/test/CIR/CodeGen/side-effect.cpp
index 870e8d8d58ed1..0a47e1493a747 100644
--- a/clang/test/CIR/CodeGen/side-effect.cpp
+++ b/clang/test/CIR/CodeGen/side-effect.cpp
@@ -8,7 +8,7 @@ extern "C" {
 
 // FIXME: We should figure out how to better print this on functions in the
 // future.
-// CIR: cir.func{{.*}}@pure_func() -> !s32i side_effect(pure) {
+// CIR: cir.func{{.*}}@pure_func() -> !s32i side_effect(pure) attributes 
{nothrow} {
 // LLVM: Function Attrs: {{.*}}nounwind{{.*}}willreturn{{.*}}memory(read)
 // LLVM: define{{.*}} @pure_func() #{{.*}} {
 // OGCG: Function Attrs: {{.*}}nounwind{{.*}}willreturn{{.*}}memory(read)
@@ -16,7 +16,7 @@ extern "C" {
 __attribute__((pure))
 int pure_func() { return 2;}
 
-// CIR: cir.func{{.*}}@const_func() -> !s32i side_effect(const) {
+// CIR: cir.func{{.*}}@const_func() -> !s32i side_effect(const) attributes 
{nothrow} {
 // LLVM: Function Attrs: {{.*}}nounwind{{.*}}willreturn{{.*}}memory(none)
 // LLVM: define{{.*}} @const_func() #{{.*}} {
 // OGCG: Function Attrs: {{.*}}nounwind{{.*}}willreturn{{.*}}memory(none)
diff --git a/clang/test/CIR/CodeGen/ternary.cpp 
b/clang/test/CIR/CodeGen/ternary.cpp
index 7e62c8b30c3bf..c4eaa1f43ea77 100644
--- a/clang/test/CIR/CodeGen/ternary.cpp
+++ b/clang/test/CIR/CodeGen/ternary.cpp
@@ -10,7 +10,7 @@ int x(int y) {
 }
 
 // CIR-LABEL: cir.func{{.*}} @_Z1xi(
-// CIR-SAME: %[[ARG0:.*]]: !s32i {{.*}}) -> (!s32i{{.*}}) {
+// CIR-SAME: %[[ARG0:.*]]: !s32i {{.*}}) -> (!s32i{{.*}}) attributes {nothrow} 
{
 // CIR: [[Y:%.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["y", init]
 // CIR: [[RETVAL:%.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
 // CIR: cir.store %[[ARG0]], [[Y]] : !s32i, !cir.ptr<!s32i>
@@ -52,7 +52,7 @@ int foo(int a, int b) {
 }
 
 // CIR-LABEL: cir.func{{.*}} @_Z3fooii(
-// CIR-SAME: %[[ARG0:.*]]: !s32i {{.*}}, %[[ARG1:.*]]: !s32i {{.*}}) -> 
(!s32i{{.*}}) {
+// CIR-SAME: %[[ARG0:.*]]: !s32i {{.*}}, %[[ARG1:.*]]: !s32i {{.*}}) -> 
(!s32i{{.*}}) attributes {nothrow} {
 // CIR: [[A:%.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["a", init]
 // CIR: [[B:%.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["b", init]
 // CIR: [[RETVAL:%.+]] = cir.alloca !s32i, !cir.ptr<!s32i>, ["__retval"]
diff --git a/clang/test/CIR/CodeGenBuiltins/builtin-fcmp-sse.c 
b/clang/test/CIR/CodeGenBuiltins/builtin-fcmp-sse.c
index aa7f8d7c6a950..cfca2a79fdce9 100644
--- a/clang/test/CIR/CodeGenBuiltins/builtin-fcmp-sse.c
+++ b/clang/test/CIR/CodeGenBuiltins/builtin-fcmp-sse.c
@@ -10,7 +10,7 @@ typedef double __m128d __attribute__((__vector_size__(16), 
__aligned__(16)));
 
 __m128 test_cmpnleps(__m128 A, __m128 B) {
   // CIR-LABEL:   cir.func no_inline dso_local @test_cmpnleps(
-  // CIR:           %[[ARG0:.*]]: !cir.vector<4 x !cir.float> {{.*}}, 
%[[ARG1:.*]]: !cir.vector<4 x !cir.float> {{.*}}) -> !cir.vector<4 x 
!cir.float> {
+  // CIR:           %[[ARG0:.*]]: !cir.vector<4 x !cir.float> {{.*}}, 
%[[ARG1:.*]]: !cir.vector<4 x !cir.float> {{.*}}) -> !cir.vector<4 x 
!cir.float> {{.*}}{
   // CIR:           %[[ALLOCA_0:.*]] = cir.alloca !cir.vector<4 x !cir.float>, 
!cir.ptr<!cir.vector<4 x !cir.float>>, ["A", init] {alignment = 16 : i64}
   // CIR:           %[[ALLOCA_1:.*]] = cir.alloca !cir.vector<4 x !cir.float>, 
!cir.ptr<!cir.vector<4 x !cir.float>>, ["B", init] {alignment = 16 : i64}
   // CIR:           %[[ALLOCA_2:.*]] = cir.alloca !cir.vector<4 x !cir.float>, 
!cir.ptr<!cir.vector<4 x !cir.float>>, ["__retval"] {alignment = 16 : i64}
@@ -61,7 +61,7 @@ __m128 test_cmpnleps(__m128 A, __m128 B) {
 
 __m128d test_cmpnlepd(__m128d A, __m128d B) {
   // CIR-LABEL:   cir.func no_inline dso_local @test_cmpnlepd(
-  // CIR:           %[[ARG0:.*]]: !cir.vector<2 x !cir.double> {{.*}}, 
%[[ARG1:.*]]: !cir.vector<2 x !cir.double> {{.*}}) -> !cir.vector<2 x 
!cir.double> {
+  // CIR:           %[[ARG0:.*]]: !cir.vector<2 x !cir.double> {{.*}}, 
%[[ARG1:.*]]: !cir.vector<2 x !cir.double> {{.*}}) -> !cir.vector<2 x 
!cir.double> {{.*}}{
   // CIR:           %[[ALLOCA_0:.*]] = cir.alloca !cir.vector<2 x 
!cir.double>, !cir.ptr<!cir.vector<2 x !cir.double>>, ["A", init] {alignment = 
16 : i64} 
   // CIR:           %[[ALLOCA_1:.*]] = cir.alloca !cir.vector<2 x 
!cir.double>, !cir.ptr<!cir.vector<2 x !cir.double>>, ["B", init] {alignment = 
16 : i64} 
   // CIR:           %[[ALLOCA_2:.*]] = cir.alloca !cir.vector<2 x 
!cir.double>, !cir.ptr<!cir.vector<2 x !cir.double>>, ["__retval"] {alignment = 
16 : i64} 
@@ -112,7 +112,7 @@ __m128d test_cmpnlepd(__m128d A, __m128d B) {
 
 __m128 test_cmpnltps(__m128 A, __m128 B) {
   // CIR-LABEL:   cir.func no_inline dso_local @test_cmpnltps(
-  // CIR:           %[[ARG0:.*]]: !cir.vector<4 x !cir.float> {{.*}}, 
%[[ARG1:.*]]: !cir.vector<4 x !cir.float> {{.*}}) -> !cir.vector<4 x 
!cir.float> {
+  // CIR:           %[[ARG0:.*]]: !cir.vector<4 x !cir.float> {{.*}}, 
%[[ARG1:.*]]: !cir.vector<4 x !cir.float> {{.*}}) -> !ci...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/187096
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to