https://github.com/xlauko updated 
https://github.com/llvm/llvm-project/pull/246016

>From 611d7e7b358c85bdd15872189b922ef97725e8da Mon Sep 17 00:00:00 2001
From: Henrich Lauko <[email protected]>
Date: Thu, 26 Nov 2026 06:20:21 +0000
Subject: [PATCH] [CIR] Mark calls in strictfp functions strictfp

At -O1, ClangIR folded `erf(1.0)` to a constant under
`#pragma STDC FENV_ACCESS ON`, while classic codegen kept the call. The
difference is the call-site `strictfp` attribute. LangRef requires it on
every call in a function that uses constrained FP intrinsics, and LLVM's
libcall folders look at the call, not at the caller. Classic codegen
gets it from IRBuilder's constrained mode. ClangIR marked only the
function.

The CIR `strictfp` function attribute now lowers to the `strictfp`
attribute of `llvm.func` instead of a `passthrough` entry. After the
conversion, every `llvm.call`, `llvm.invoke`, `llvm.inline_asm` and
`llvm.call_intrinsic` in a `strictfp` function gets `strictfp` too, and
every named intrinsic op such as `llvm.intr.fabs` or `llvm.intr.memcpy`
gets `llvm.strictfp`. That includes indirect calls, constrained
intrinsics, and the calls LoweringPrepare and EH lowering create. CIR
itself does not change.

ClangIR also marks the calls in a strictfp global initializer, as
LangRef asks. Classic codegen does not, because it adds `strictfp` back
to such a call only when the enclosing declaration is a strictfp
function. The calls in `_GLOBAL__sub_I_*` stay unmarked until that
function is `strictfp` too.

Assisted-by: Claude Code (Opus 5.5).
---
 .../CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp |  30 +++-
 clang/test/CIR/CodeGen/strictfp-call-site.c   | 134 ++++++++++++++++
 clang/test/CIR/CodeGen/strictfp-call-site.cpp |  89 +++++++++++
 .../no-trapping-math-ssp-buffer-size.cir      |   3 +-
 .../CIR/Lowering/strictfp-call-site-asm.cir   |  32 ++++
 .../test/CIR/Lowering/strictfp-call-site.cir  | 143 ++++++++++++++++++
 clang/test/CIR/Lowering/strictfp.cir          |  29 ----
 7 files changed, 429 insertions(+), 31 deletions(-)
 create mode 100644 clang/test/CIR/CodeGen/strictfp-call-site.c
 create mode 100644 clang/test/CIR/CodeGen/strictfp-call-site.cpp
 create mode 100644 clang/test/CIR/Lowering/strictfp-call-site-asm.cir
 create mode 100644 clang/test/CIR/Lowering/strictfp-call-site.cir
 delete mode 100644 clang/test/CIR/Lowering/strictfp.cir

diff --git a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp 
b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
index 245ce5096d461a..2f822cad078b0a 100644
--- a/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
+++ b/clang/lib/CIR/Lowering/DirectToLLVM/LowerToLLVM.cpp
@@ -3319,6 +3319,9 @@ mlir::LogicalResult 
CIRToLLVMFuncOpLowering::matchAndRewrite(
   if (op->hasAttr(CIRDialect::getOptNoneAttrName()))
     fn.setOptimizeNone(true);
 
+  if (op->hasAttr(CIRDialect::getStrictFPAttrName()))
+    fn.setStrictfp(true);
+
   if (std::optional<cir::UnwindTableKind> uwtableKind = op.getUwtable())
     fn.setUwtableKindAttr(mlir::LLVM::UWTableKindAttr::get(
         fn.getContext(), convertUWTableKind(*uwtableKind)));
@@ -3334,7 +3337,7 @@ mlir::LogicalResult 
CIRToLLVMFuncOpLowering::matchAndRewrite(
   // attributes.
   SmallVector<mlir::Attribute> passthrough;
   for (llvm::StringRef flagAttr :
-       {CIRDialect::getStrictFPAttrName(), CIRDialect::getNoRecurseAttrName(),
+       {CIRDialect::getNoRecurseAttrName(),
         CIRDialect::getMustProgressAttrName(),
         CIRDialect::getNoBuiltinAttrName(), CIRDialect::getNakedAttrName()})
     if (op->hasAttr(flagAttr))
@@ -5259,6 +5262,29 @@ struct GPULaunchFuncOperandLowering : public 
mlir::ConversionPattern {
 };
 } // namespace
 
+/// Marks every call in a `strictfp` function `strictfp`, which LangRef
+/// requires in a function that uses constrained FP intrinsics. The call ops
+/// have an inherent `strictfp` attribute; named intrinsic ops such as
+/// `llvm.intr.memcpy` take the discardable `llvm.strictfp` instead.
+static void markCallsInStrictFPFunctions(mlir::ModuleOp module) {
+  auto unit = mlir::UnitAttr::get(module.getContext());
+  module.walk([&](mlir::LLVM::LLVMFuncOp fn) {
+    if (!fn.getStrictfp())
+      return;
+    fn.walk([&](mlir::Operation *op) {
+      llvm::TypeSwitch<mlir::Operation *>(op)
+          .Case<mlir::LLVM::CallOp, mlir::LLVM::InvokeOp,
+                mlir::LLVM::InlineAsmOp, mlir::LLVM::CallIntrinsicOp>(
+              [](auto call) { call.setStrictfp(true); })
+          .Default([&](mlir::Operation *op) {
+            if (op->hasTrait<mlir::LLVM::IntrinsicOpTrait>())
+              op->setDiscardableAttr(
+                  mlir::LLVM::LLVMDialect::getStrictFPAttrName(), unit);
+          });
+    });
+  });
+}
+
 void ConvertCIRToLLVMPass::runOnOperation() {
   llvm::TimeTraceScope scope("Convert CIR to LLVM Pass");
 
@@ -5361,6 +5387,8 @@ void ConvertCIRToLLVMPass::runOnOperation() {
     return;
   }
 
+  markCallsInStrictFPFunctions(module);
+
   // Drop CIR-native data-layout entries.
   if (auto dlSpec = mlir::dyn_cast_or_null<mlir::DataLayoutSpecAttr>(
           module->getAttr(mlir::DLTIDialect::kDataLayoutAttrName))) {
diff --git a/clang/test/CIR/CodeGen/strictfp-call-site.c 
b/clang/test/CIR/CodeGen/strictfp-call-site.c
new file mode 100644
index 00000000000000..a18bf2ec39aea4
--- /dev/null
+++ b/clang/test/CIR/CodeGen/strictfp-call-site.c
@@ -0,0 +1,134 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-cir %s -o 
%t.cir
+// RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fclangir -emit-llvm %s -o 
%t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefixes=LLVM,LLVMCIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefixes=LLVM,OGCG
+
+// LLVM requires every call in a function that uses constrained FP intrinsics
+// to be strictfp, at the call site or on the callee. CIR keeps strictfp on the
+// function only. The lowering to the LLVM dialect marks the calls in it,
+// including intrinsic calls and the libcalls that LoweringPrepare creates.
+//
+// ClangIR and classic codegen differ only where classic codegen also adds
+// nounwind, which is unrelated to strictfp. The LLVMCIR and OGCG lines cover
+// those calls.
+
+void ext(void);
+float extf(float);
+struct S { int a[32]; };
+
+void plain_direct(void) { ext(); }
+
+// CIR-LABEL: cir.func {{.*}}@plain_direct()
+// CIR:         cir.call @ext() : () -> ()
+
+// LLVM-LABEL: define {{.*}}void @plain_direct()
+// LLVM-SAME:    #[[PLAIN_FN:[0-9]+]]
+// LLVM:         call void @ext(){{$}}
+
+void plain_indirect(void (*fp)(void)) { fp(); }
+
+// LLVM-LABEL: define {{.*}}void @plain_indirect(
+// LLVM-SAME:    #[[PLAIN_FN]]
+// LLVM:         call void %{{.*}}(){{$}}
+
+void plain_copy(struct S *d, struct S *s) { *d = *s; }
+
+// LLVM-LABEL: define {{.*}}void @plain_copy(
+// LLVM-SAME:    #[[PLAIN_FN]]
+// LLVM:         call void @llvm.memcpy.p0.p0.i64({{.*}}, i64 128, i1 
false){{$}}
+
+void plain_trap(void) { __builtin_trap(); }
+
+// LLVM-LABEL: define {{.*}}void @plain_trap()
+// LLVM-SAME:    #[[PLAIN_FN]]
+// LLVM:         call void @llvm.trap(){{$}}
+
+#pragma STDC FENV_ACCESS ON
+
+void strict_direct(void) { ext(); }
+
+// The attribute stays on the function in CIR.
+// CIR-LABEL: cir.func {{.*}}@strict_direct()
+// CIR-SAME:    attributes {{{.*}}strictfp}
+// CIR:         cir.call @ext() : () -> ()
+
+// LLVM-LABEL: define {{.*}}void @strict_direct()
+// LLVM-SAME:    #[[STRICT_FN:[0-9]+]]
+// LLVM:         call void @ext() #[[STRICT_CALL:[0-9]+]]
+
+void strict_indirect(void (*fp)(void)) { fp(); }
+
+// CIR-LABEL: cir.func {{.*}}@strict_indirect(
+// CIR-SAME:    attributes {{{.*}}strictfp}
+// CIR:         cir.call %{{.*}}() : (!cir.ptr<!cir.func<()>>) -> ()
+
+// LLVM-LABEL: define {{.*}}void @strict_indirect(
+// LLVM-SAME:    #[[STRICT_FN]]
+// LLVM:         call void %{{.*}}() #[[STRICT_CALL]]
+
+// A call next to a constrained operation.
+float strict_mixed(float a) { return extf(a + 1.0f); }
+
+// LLVM-LABEL: define {{.*}}float @strict_mixed(
+// LLVM-SAME:    #[[STRICT_FN]]
+// LLVM:         call float @llvm.experimental.constrained.fadd.f32({{.*}}) 
#[[STRICT_CALL]]
+// LLVM:         call float @extf(float {{.*}}) #[[STRICT_CALL]]
+
+// An intrinsic that has no constrained variant.
+float strict_builtin(float a) { return __builtin_fabsf(a); }
+
+// LLVM-LABEL: define {{.*}}float @strict_builtin(
+// LLVM-SAME:    #[[STRICT_FN]]
+// LLVM:         call float @llvm.fabs.f32(float %{{.*}}) #[[STRICT_CALL]]
+
+// An intrinsic that the lowering creates for an operation that is not a call.
+void strict_copy(struct S *d, struct S *s) { *d = *s; }
+
+// CIR-LABEL: cir.func {{.*}}@strict_copy(
+// CIR-SAME:    attributes {{{.*}}strictfp}
+// CIR:         cir.copy
+
+// LLVM-LABEL: define {{.*}}void @strict_copy(
+// LLVM-SAME:    #[[STRICT_FN]]
+// LLVM:         call void @llvm.memcpy.p0.p0.i64({{.*}}, i64 128, i1 false) 
#[[STRICT_CALL]]
+
+void strict_trap(void) { __builtin_trap(); }
+
+// LLVM-LABEL: define {{.*}}void @strict_trap()
+// LLVM-SAME:    #[[STRICT_FN]]
+// LLVM:         call void @llvm.trap() #[[STRICT_CALL]]
+
+// A libcall that LoweringPrepare creates.
+_Complex float strict_complex_mul(_Complex float a, _Complex float b) {
+  return a * b;
+}
+
+// LLVM-LABEL: define {{.*}}<2 x float> @strict_complex_mul(
+// LLVMCIR:      call <2 x float> @__mulsc3({{.*}}) #[[STRICT_CALL]]
+// OGCG:         call <2 x float> @__mulsc3({{.*}}) 
#[[STRICT_NOUNWIND_CALL:[0-9]+]]
+
+void strict_asm(void) { __asm__ volatile("nop"); }
+
+// CIR-LABEL: cir.func {{.*}}@strict_asm()
+// CIR-SAME:    attributes {{{.*}}strictfp}
+// CIR:         cir.asm(x86_att,
+
+// LLVM-LABEL: define {{.*}}void @strict_asm()
+// LLVM-SAME:    #[[STRICT_FN]]
+// LLVMCIR:      call void asm sideeffect "nop", 
"~{dirflag},~{fpsr},~{flags}"() #[[STRICT_CALL]]
+// OGCG:         call void asm sideeffect "nop", 
"~{dirflag},~{fpsr},~{flags}"() #[[STRICT_NOUNWIND_CALL]]
+
+#pragma STDC FENV_ACCESS OFF
+
+// A call to a strictfp function from a function that is not strictfp.
+void plain_calls_strict(void) { strict_direct(); }
+
+// LLVM-LABEL: define {{.*}}void @plain_calls_strict()
+// LLVM-SAME:    #[[PLAIN_FN]]
+// LLVM:         call void @strict_direct(){{$}}
+
+// LLVM-DAG: attributes #[[STRICT_FN]] = { {{.*}}strictfp
+// LLVM-DAG: attributes #[[STRICT_CALL]] = { strictfp }
+// OGCG-DAG: attributes #[[STRICT_NOUNWIND_CALL]] = { nounwind strictfp }
diff --git a/clang/test/CIR/CodeGen/strictfp-call-site.cpp 
b/clang/test/CIR/CodeGen/strictfp-call-site.cpp
new file mode 100644
index 00000000000000..340aac58d0d947
--- /dev/null
+++ b/clang/test/CIR/CodeGen/strictfp-call-site.cpp
@@ -0,0 +1,89 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions \
+// RUN:   -fclangir -emit-llvm %s -o %t-cir.ll
+// RUN: FileCheck --input-file=%t-cir.ll %s -check-prefixes=LLVM,LLVMCIR
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions \
+// RUN:   -emit-llvm %s -o %t.ll
+// RUN: FileCheck --input-file=%t.ll %s -check-prefixes=LLVM,OGCG
+
+// With a strict TU-wide default the global initializer is strictfp too.
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions \
+// RUN:   -ffp-exception-behavior=strict -fclangir -emit-llvm %s -o 
%t-strict-cir.ll
+// RUN: FileCheck --input-file=%t-strict-cir.ll %s \
+// RUN:   -check-prefixes=LLVM-STRICT,LLVMCIR-STRICT
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions \
+// RUN:   -ffp-exception-behavior=strict -emit-llvm %s -o %t-strict.ll
+// RUN: FileCheck --input-file=%t-strict.ll %s \
+// RUN:   -check-prefixes=LLVM-STRICT,OGCG-STRICT
+
+// Calls in a strictfp function are strictfp in LLVM IR, including invokes,
+// intrinsic calls and the calls that EH lowering creates.
+
+float ext();
+struct C { C(); };
+struct D { ~D(); };
+
+float g = ext() + 1.0f;
+
+// LLVM-LABEL: define internal void @__cxx_global_var_init()
+// LLVM:         call noundef float @_Z3extv(){{$}}
+
+// Classic codegen marks a call it emits for a call expression only when the
+// enclosing declaration is a strictfp function, so it leaves this one unmarked
+// beside a constrained intrinsic. ClangIR marks it, as LangRef asks.
+// LLVM-STRICT-LABEL: define internal void @__cxx_global_var_init()
+// LLVM-STRICT-SAME:    #[[INIT_FN:[0-9]+]]
+// LLVMCIR-STRICT:      call noundef float @_Z3extv() #[[STRICT_CALL:[0-9]+]]
+// LLVMCIR-STRICT:      call float 
@llvm.experimental.constrained.fadd.f32({{.*}}) #[[STRICT_CALL]]
+// OGCG-STRICT:         call noundef float @_Z3extv(){{$}}
+// OGCG-STRICT:         call float 
@llvm.experimental.constrained.fadd.f32({{.*}}) #[[STRICT_CALL:[0-9]+]]
+
+C c;
+
+// LLVM-LABEL: define internal void @__cxx_global_var_init.1()
+// LLVM:         call void @_ZN1CC1Ev(ptr {{.*}}@c){{$}}
+
+// The same holds for a construct expression.
+// LLVM-STRICT-LABEL: define internal void @__cxx_global_var_init.1()
+// LLVM-STRICT-SAME:    #[[INIT_FN]]
+// LLVMCIR-STRICT:      call void @_ZN1CC1Ev(ptr {{.*}}@c) #[[STRICT_CALL]]
+// OGCG-STRICT:         call void @_ZN1CC1Ev(ptr {{.*}}@c){{$}}
+
+float plain() {
+  D d;
+  return ext();
+}
+
+// LLVM-LABEL: define {{.*}}float @_Z5plainv()
+// LLVM:         invoke noundef float @_Z3extv(){{$}}
+// LLVM:         call void @_ZN1DD1Ev(ptr {{.*}}) #[[NOUNWIND_CALL:[0-9]+]]
+
+float strict() {
+#pragma STDC FENV_ACCESS ON
+  D d;
+  try {
+    return ext();
+  } catch (...) {
+    return 0;
+  }
+}
+
+// Classic codegen also marks __cxa_begin_catch nounwind and invokes
+// __cxa_end_catch, which is unrelated to strictfp.
+// LLVM-LABEL: define {{.*}}float @_Z6strictv()
+// LLVM-SAME:    #[[STRICT_FN:[0-9]+]]
+// LLVM:         invoke noundef float @_Z3extv() #[[STRICT_CALL:[0-9]+]]
+// LLVMCIR:      call ptr @__cxa_begin_catch(ptr %{{.*}}) #[[STRICT_CALL]]
+// OGCG:         call ptr @__cxa_begin_catch(ptr %{{.*}}) 
#[[STRICT_NOUNWIND_CALL:[0-9]+]]
+// LLVM:         call float 
@llvm.experimental.constrained.sitofp.f32.i32({{.*}}) #[[STRICT_CALL]]
+// LLVM:         {{call|invoke}} void @__cxa_end_catch() #[[STRICT_CALL]]
+// LLVMCIR:      call void @_ZN1DD1Ev(ptr {{.*}}) 
#[[STRICT_NOUNWIND_CALL:[0-9]+]]
+// OGCG:         call void @_ZN1DD1Ev(ptr {{.*}}) #[[STRICT_NOUNWIND_CALL]]
+// LLVM:         call void @llvm.trap() #[[STRICT_CALL]]
+
+// LLVM-DAG: attributes #[[STRICT_FN]] = { {{.*}}strictfp
+// LLVM-DAG: attributes #[[NOUNWIND_CALL]] = { nounwind }
+// LLVM-DAG: attributes #[[STRICT_CALL]] = { strictfp }
+// LLVM-DAG: attributes #[[STRICT_NOUNWIND_CALL]] = { nounwind strictfp }
+
+// LLVM-STRICT-DAG: attributes #[[INIT_FN]] = { {{.*}}strictfp
+// LLVM-STRICT-DAG: attributes #[[STRICT_CALL]] = { strictfp }
diff --git a/clang/test/CIR/Lowering/no-trapping-math-ssp-buffer-size.cir 
b/clang/test/CIR/Lowering/no-trapping-math-ssp-buffer-size.cir
index d3508238c6b136..aeb12ebd3fe387 100644
--- a/clang/test/CIR/Lowering/no-trapping-math-ssp-buffer-size.cir
+++ b/clang/test/CIR/Lowering/no-trapping-math-ssp-buffer-size.cir
@@ -32,7 +32,8 @@ module attributes {
 // MLIR-LABEL: llvm.func @decl_fn()
 // MLIR-SAME:    passthrough = {{\[}}["no-trapping-math", "true"], 
["stack-protector-buffer-size", "16"]]
 // MLIR-LABEL: llvm.func @strictfp_fn()
-// MLIR-SAME:    passthrough = {{\[}}"strictfp", 
["stack-protector-buffer-size", "16"]]
+// MLIR-SAME:    passthrough = {{\[}}["stack-protector-buffer-size", "16"]]
+// MLIR-SAME:    strictfp
 // MLIR-LABEL: llvm.func @runtime_fn()
 // MLIR-NOT:     passthrough
 
diff --git a/clang/test/CIR/Lowering/strictfp-call-site-asm.cir 
b/clang/test/CIR/Lowering/strictfp-call-site-asm.cir
new file mode 100644
index 00000000000000..10d01984e466d7
--- /dev/null
+++ b/clang/test/CIR/Lowering/strictfp-call-site-asm.cir
@@ -0,0 +1,32 @@
+// RUN: cir-translate %s -cir-to-llvmir --disable-cc-lowering | FileCheck %s
+// REQUIRES: target={{x86_64-.*-linux.*}}
+
+// Inline assembly in a `strictfp` function is a `strictfp` call.
+
+module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
+  cir.func @strict_asm() attributes {strictfp} {
+    cir.asm(x86_att,
+      out = [],
+      in = [],
+      in_out = [],
+      {"nop" "~{dirflag},~{fpsr},~{flags}"}) side_effects
+    cir.return
+  }
+
+  // CHECK-LABEL: define void @strict_asm(
+  // CHECK:         call void asm sideeffect "nop", 
"~{dirflag},~{fpsr},~{flags}"() #[[STRICT:[0-9]+]]
+
+  cir.func @plain_asm() {
+    cir.asm(x86_att,
+      out = [],
+      in = [],
+      in_out = [],
+      {"nop" "~{dirflag},~{fpsr},~{flags}"}) side_effects
+    cir.return
+  }
+
+  // CHECK-LABEL: define void @plain_asm(
+  // CHECK:         call void asm sideeffect "nop", 
"~{dirflag},~{fpsr},~{flags}"(){{$}}
+}
+
+// CHECK: attributes #[[STRICT]] = { strictfp }
diff --git a/clang/test/CIR/Lowering/strictfp-call-site.cir 
b/clang/test/CIR/Lowering/strictfp-call-site.cir
new file mode 100644
index 00000000000000..a2104ec1efab7e
--- /dev/null
+++ b/clang/test/CIR/Lowering/strictfp-call-site.cir
@@ -0,0 +1,143 @@
+// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
+// RUN: cir-translate %s -cir-to-llvmir --disable-cc-lowering | FileCheck %s 
-check-prefix=LLVM
+// REQUIRES: target={{x86_64-.*-linux.*}}
+
+// LLVM requires every call in a function that uses constrained FP intrinsics
+// to be `strictfp`, at the call site or on the callee. CIR keeps `strictfp` on
+// the function only. The lowering keeps it on the `llvm.func` and sets it on 
the
+// LLVM dialect's direct and indirect calls, invokes and intrinsic calls.
+
+!s32i = !cir.int<s, 32>
+
+module attributes {cir.triple = "x86_64-unknown-linux-gnu"} {
+  cir.func private @__gxx_personality_v0(...) -> !s32i
+  cir.func private @callee(!s32i) -> !s32i
+
+  cir.func @strict_direct(%arg0: !s32i) -> !s32i attributes {strictfp} {
+    %0 = cir.call @callee(%arg0) : (!s32i) -> !s32i
+    cir.return %0 : !s32i
+  }
+
+  // MLIR-LABEL: llvm.func @strict_direct(
+  // MLIR-SAME:     attributes {{{.*}}strictfp}
+  // MLIR:         llvm.call @callee(%{{.*}}) {strictfp} : (i32) -> i32
+
+  // LLVM-LABEL: define i32 @strict_direct(
+  // LLVM-SAME:     #[[STRICT:[0-9]+]]
+  // LLVM:         call i32 @callee(i32 %{{.*}}) #[[STRICT]]
+
+  cir.func @strict_nothrow(%arg0: !s32i) -> !s32i attributes {strictfp} {
+    %0 = cir.call @callee(%arg0) nothrow : (!s32i) -> !s32i
+    cir.return %0 : !s32i
+  }
+
+  // MLIR-LABEL: llvm.func @strict_nothrow(
+  // MLIR-SAME:     attributes {{{.*}}strictfp}
+  // MLIR:         llvm.call @callee(%{{.*}}) {no_unwind, strictfp} : (i32) -> 
i32
+
+  // LLVM-LABEL: define i32 @strict_nothrow(
+  // LLVM-SAME:     #[[STRICT]]
+  // LLVM:         call i32 @callee(i32 %{{.*}}) #[[STRICT_NOUNWIND:[0-9]+]]
+
+  cir.func @strict_indirect(%fn: !cir.ptr<!cir.func<(!s32i) -> !s32i>>, %arg0: 
!s32i) -> !s32i attributes {strictfp} {
+    %0 = cir.call %fn(%arg0) : (!cir.ptr<!cir.func<(!s32i) -> !s32i>>, !s32i) 
-> !s32i
+    cir.return %0 : !s32i
+  }
+
+  // MLIR-LABEL: llvm.func @strict_indirect(
+  // MLIR-SAME:     attributes {{{.*}}strictfp}
+  // MLIR:         llvm.call %{{.*}}(%{{.*}}) {strictfp} : !llvm.ptr, (i32) -> 
i32
+
+  // LLVM-LABEL: define i32 @strict_indirect(
+  // LLVM-SAME:     #[[STRICT]]
+  // LLVM:         call i32 %{{.*}}(i32 %{{.*}}) #[[STRICT]]
+
+  cir.func @strict_try_call(%arg0: !s32i) personality(@__gxx_personality_v0) 
attributes {strictfp} {
+    %0 = cir.try_call @callee(%arg0) ^normal, ^unwind : (!s32i) -> !s32i
+  ^normal:
+    cir.return
+  ^unwind:
+    %exception_ptr, %type_id = cir.eh.inflight_exception cleanup
+    cir.return
+  }
+
+  // MLIR-LABEL: llvm.func @strict_try_call(
+  // MLIR-SAME:     attributes {{{.*}}strictfp}
+  // MLIR:         llvm.invoke @callee(%{{.*}}) to ^{{.*}} unwind ^{{.*}} 
{strictfp} : (i32) -> i32
+
+  // LLVM-LABEL: define void @strict_try_call(
+  // LLVM-SAME:     #[[STRICT]]
+  // LLVM:         invoke i32 @callee(i32 %{{.*}}) #[[STRICT]]
+  // LLVM-NEXT:      to label %{{.*}} unwind label %{{.*}}
+
+  cir.func @strict_intrinsic() attributes {strictfp} {
+    cir.call_llvm_intrinsic "donothing" : () -> ()
+    cir.return
+  }
+
+  // MLIR-LABEL: llvm.func @strict_intrinsic(
+  // MLIR-SAME:     attributes {{{.*}}strictfp}
+  // MLIR:         llvm.call_intrinsic "llvm.donothing"() {strictfp} : () -> ()
+
+  // LLVM-LABEL: define void @strict_intrinsic(
+  // LLVM-SAME:     #[[STRICT]]
+  // LLVM:         call void @llvm.donothing() #[[STRICT]]
+
+  cir.func @strict_trap() attributes {strictfp} {
+    cir.trap
+  }
+
+  // MLIR-LABEL: llvm.func @strict_trap(
+  // MLIR-SAME:     attributes {{{.*}}strictfp}
+  // MLIR:         llvm.intr.trap {llvm.strictfp}
+
+  // LLVM-LABEL: define void @strict_trap(
+  // LLVM-SAME:     #[[STRICT]]
+  // LLVM:         call void @llvm.trap() #[[STRICT]]
+
+  cir.func @plain_direct(%arg0: !s32i) -> !s32i {
+    %0 = cir.call @callee(%arg0) : (!s32i) -> !s32i
+    cir.return %0 : !s32i
+  }
+
+  // MLIR-LABEL: llvm.func @plain_direct(
+  // MLIR-NOT:      strictfp
+  // MLIR:         llvm.call @callee(%{{.*}}) : (i32) -> i32
+
+  // LLVM-LABEL: define i32 @plain_direct(
+  // LLVM-NOT:      #
+  // LLVM:         call i32 @callee(i32 %{{.*}}){{$}}
+
+  cir.func @plain_indirect(%fn: !cir.ptr<!cir.func<(!s32i) -> !s32i>>, %arg0: 
!s32i) -> !s32i {
+    %0 = cir.call %fn(%arg0) : (!cir.ptr<!cir.func<(!s32i) -> !s32i>>, !s32i) 
-> !s32i
+    cir.return %0 : !s32i
+  }
+
+  // MLIR-LABEL: llvm.func @plain_indirect(
+  // MLIR-NOT:      strictfp
+  // MLIR:         llvm.call %{{.*}}(%{{.*}}) : !llvm.ptr, (i32) -> i32
+
+  // LLVM-LABEL: define i32 @plain_indirect(
+  // LLVM-NOT:      #
+  // LLVM:         call i32 %{{.*}}(i32 %{{.*}}){{$}}
+
+  cir.func @plain_try_call(%arg0: !s32i) personality(@__gxx_personality_v0) {
+    %0 = cir.try_call @callee(%arg0) ^normal, ^unwind : (!s32i) -> !s32i
+  ^normal:
+    cir.return
+  ^unwind:
+    %exception_ptr, %type_id = cir.eh.inflight_exception cleanup
+    cir.return
+  }
+
+  // MLIR-LABEL: llvm.func @plain_try_call(
+  // MLIR-NOT:      strictfp
+  // MLIR:         llvm.invoke @callee(%{{.*}}) to ^{{.*}} unwind ^{{.*}} : 
(i32) -> i32
+
+  // LLVM-LABEL: define void @plain_try_call(
+  // LLVM-NOT:      #
+  // LLVM:         invoke i32 @callee(i32 %{{.*}}){{$}}
+}
+
+// LLVM-DAG: attributes #[[STRICT]] = { strictfp }
+// LLVM-DAG: attributes #[[STRICT_NOUNWIND]] = { nounwind strictfp }
diff --git a/clang/test/CIR/Lowering/strictfp.cir 
b/clang/test/CIR/Lowering/strictfp.cir
deleted file mode 100644
index 7c4abf807776bb..00000000000000
--- a/clang/test/CIR/Lowering/strictfp.cir
+++ /dev/null
@@ -1,29 +0,0 @@
-// RUN: cir-opt %s -cir-to-llvm -o - | FileCheck %s -check-prefix=MLIR
-// RUN: cir-translate %s -cir-to-llvmir --disable-cc-lowering | FileCheck %s 
-check-prefix=LLVM
-// REQUIRES: target={{x86_64-.*-linux.*}}
-
-// Functions tagged with the `strictfp` CIR function attribute should be
-// lowered to `llvm.func` operations whose `passthrough` array contains
-// `"strictfp"`, and then translated to LLVM IR functions carrying the
-// `strictfp` attribute.
-
-module {
-  cir.func @strict_fn() attributes {strictfp} {
-    cir.return
-  }
-
-  cir.func @plain_fn() {
-    cir.return
-  }
-}
-
-// MLIR-LABEL: llvm.func @strict_fn()
-// MLIR-SAME:    passthrough = ["strictfp"]
-// MLIR-LABEL: llvm.func @plain_fn()
-// MLIR-NOT:     passthrough
-// MLIR-NOT:     strictfp
-
-// LLVM:       define void @strict_fn() #[[STRICT:[0-9]+]]
-// LLVM-LABEL: define void @plain_fn()
-// LLVM-NOT:     #[[STRICT]]
-// LLVM:       attributes #[[STRICT]] = {{.*}}strictfp

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

Reply via email to