Author: Andy Kaylor
Date: 2026-08-13T00:12:40Z
New Revision: e37b656cc6a1b5626b7b567001f1af26ce68797e

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

LOG: [CIR] Use CIR integer type for EH personality function signature (#215901)

We had previously been using the MLIR builtin i32 type as the return
type when creating the declaration for exception handling personality
functions. This caused the calling convention lowering to fail because
it wasn't expecting non-CIR types in a CIR function.

This change updates the code that builds the declaration to use the CIR
s32 type. Multiple tests that had been disabling calling convention
lowering because of the above problem can now leave it enabled.

Added: 
    

Modified: 
    clang/lib/CIR/CodeGen/CIRGenException.cpp
    clang/test/CIR/CodeGen/catch-in-loop.cpp
    clang/test/CIR/CodeGen/cleanup-scope-throw-caught.cpp
    clang/test/CIR/CodeGen/ctor-try-body.cpp
    clang/test/CIR/CodeGen/default-func-attrs-invoke.cpp
    clang/test/CIR/CodeGen/invoke-attrs.cpp
    clang/test/CIR/CodeGen/try-catch-all-with-cleanup.cpp
    clang/test/CIR/CodeGen/try-catch-non-trivial-copy.cpp
    clang/test/CIR/CodeGen/try-catch.cpp
    clang/test/CIR/CodeGen/try-no-throwing-calls.cpp
    clang/test/CIR/CodeGenCXX/typeid.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CIR/CodeGen/CIRGenException.cpp 
b/clang/lib/CIR/CodeGen/CIRGenException.cpp
index 6e8bababe82ab..2e3518c2d8bca 100644
--- a/clang/lib/CIR/CodeGen/CIRGenException.cpp
+++ b/clang/lib/CIR/CodeGen/CIRGenException.cpp
@@ -189,7 +189,7 @@ const EHPersonality &EHPersonality::get(CIRGenFunction 
&cgf) {
 static llvm::StringRef getPersonalityFn(CIRGenModule &cgm,
                                         const EHPersonality &personality) {
   // Create the personality function type: i32 (...)
-  mlir::Type i32Ty = cgm.getBuilder().getI32Type();
+  mlir::Type i32Ty = cgm.getBuilder().getSInt32Ty();
   auto funcTy = cir::FuncType::get({}, i32Ty, /*isVarArg=*/true);
 
   cir::FuncOp personalityFn = cgm.createRuntimeFunction(

diff  --git a/clang/test/CIR/CodeGen/catch-in-loop.cpp 
b/clang/test/CIR/CodeGen/catch-in-loop.cpp
index 89ad5fde2eae4..c2d960d477349 100644
--- a/clang/test/CIR/CodeGen/catch-in-loop.cpp
+++ b/clang/test/CIR/CodeGen/catch-in-loop.cpp
@@ -1,8 +1,6 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++14 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++14 
-fcxx-exceptions -fexceptions -fclangir -emit-cir %s -o %t.cir
 // RUN: FileCheck --input-file=%t.cir --check-prefix=CIR %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++14 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-llvm %s -o %t.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++14 
-fcxx-exceptions -fexceptions -fclangir -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll --check-prefix=LLVM %s
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++14 
-fcxx-exceptions -fexceptions -emit-llvm %s -o %t-ogcg.ll
 // RUN: FileCheck --input-file=%t-ogcg.ll --check-prefix=OGCG %s

diff  --git a/clang/test/CIR/CodeGen/cleanup-scope-throw-caught.cpp 
b/clang/test/CIR/CodeGen/cleanup-scope-throw-caught.cpp
index 88a9dcd965ad9..ff313033e9a85 100644
--- a/clang/test/CIR/CodeGen/cleanup-scope-throw-caught.cpp
+++ b/clang/test/CIR/CodeGen/cleanup-scope-throw-caught.cpp
@@ -1,10 +1,8 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-cir %s -o %t.cir
 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
 // RUN: cir-opt -cir-hoist-allocas -cir-flatten-cfg -cir-eh-abi-lowering 
%t.cir -o %t.eh.cir
 // RUN: FileCheck --input-file=%t.eh.cir %s -check-prefix=CIR-EHABI
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-llvm %s -o %t-cir.ll
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-llvm %s -o %t-cir.ll
 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM

diff  --git a/clang/test/CIR/CodeGen/ctor-try-body.cpp 
b/clang/test/CIR/CodeGen/ctor-try-body.cpp
index 9e530c54c58d1..21967ceebfc10 100644
--- a/clang/test/CIR/CodeGen/ctor-try-body.cpp
+++ b/clang/test/CIR/CodeGen/ctor-try-body.cpp
@@ -1,8 +1,6 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fexceptions 
-fcxx-exceptions -fclangir -fno-clangir-call-conv-lowering -emit-cir %s -o 
%t.cir
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fexceptions 
-fcxx-exceptions -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 -fexceptions 
-fcxx-exceptions -fclangir -fno-clangir-call-conv-lowering -emit-llvm %s -o 
%t-cir.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fexceptions 
-fcxx-exceptions -fclangir -emit-llvm %s -o %t-cir.ll
 // RUN: FileCheck --input-file=%t-cir.ll %s --check-prefix=LLVM,LLVMCIR
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fexceptions 
-fcxx-exceptions -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s --check-prefix=LLVM,OGCG

diff  --git a/clang/test/CIR/CodeGen/default-func-attrs-invoke.cpp 
b/clang/test/CIR/CodeGen/default-func-attrs-invoke.cpp
index 548ee0070eb66..0e7dcd9c49d18 100644
--- a/clang/test/CIR/CodeGen/default-func-attrs-invoke.cpp
+++ b/clang/test/CIR/CodeGen/default-func-attrs-invoke.cpp
@@ -1,8 +1,6 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -default-function-attr 
"key=value" -default-function-attr "just_key" -fcxx-exceptions -fexceptions 
-fclangir -fno-clangir-call-conv-lowering -emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -default-function-attr 
"key=value" -default-function-attr "just_key" -fcxx-exceptions -fexceptions 
-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 -default-function-attr 
"key=value" -default-function-attr "just_key" -fcxx-exceptions -fexceptions 
-fclangir -fno-clangir-call-conv-lowering -emit-llvm %s -o %t.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -default-function-attr 
"key=value" -default-function-attr "just_key" -fcxx-exceptions -fexceptions 
-fclangir -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -default-function-attr 
"key=value" -default-function-attr "just_key" -fcxx-exceptions -fexceptions 
-emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM

diff  --git a/clang/test/CIR/CodeGen/invoke-attrs.cpp 
b/clang/test/CIR/CodeGen/invoke-attrs.cpp
index 9e537ad10f3da..aeb2d0cfbc386 100644
--- a/clang/test/CIR/CodeGen/invoke-attrs.cpp
+++ b/clang/test/CIR/CodeGen/invoke-attrs.cpp
@@ -1,10 +1,8 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-cir %s -o %t.cir
 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
 // RUN: cir-opt --cir-flatten-cfg %t.cir -o %t-flat.cir
 // RUN: FileCheck --input-file=%t-flat.cir %s --check-prefix=CIR-FLAT
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-llvm %s -o %t.ll
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=LLVM
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG

diff  --git a/clang/test/CIR/CodeGen/try-catch-all-with-cleanup.cpp 
b/clang/test/CIR/CodeGen/try-catch-all-with-cleanup.cpp
index 95e23435c0a3f..e308d22256063 100644
--- a/clang/test/CIR/CodeGen/try-catch-all-with-cleanup.cpp
+++ b/clang/test/CIR/CodeGen/try-catch-all-with-cleanup.cpp
@@ -1,10 +1,8 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-cir %s -o %t.cir
 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
 // RUN: cir-opt %t.cir -cir-flatten-cfg -o %t-flat.cir
 // RUN: FileCheck --input-file=%t-flat.cir %s -check-prefix=CIR-FLAT
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-llvm %s -o %t-cir.ll
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-llvm %s -o %t-cir.ll
 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG

diff  --git a/clang/test/CIR/CodeGen/try-catch-non-trivial-copy.cpp 
b/clang/test/CIR/CodeGen/try-catch-non-trivial-copy.cpp
index d40eef535f471..9e3f627acbea1 100644
--- a/clang/test/CIR/CodeGen/try-catch-non-trivial-copy.cpp
+++ b/clang/test/CIR/CodeGen/try-catch-non-trivial-copy.cpp
@@ -1,12 +1,10 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions -fclangir -fno-clangir-call-conv-lowering -emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions -fclangir -emit-cir %s -o %t.cir
 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
 // RUN: cir-opt -cir-hoist-allocas -cir-flatten-cfg %t.cir -o %t.flat.cir
 // RUN: FileCheck --input-file=%t.flat.cir %s -check-prefix=CIR-FLAT
 // RUN: cir-opt -cir-hoist-allocas -cir-flatten-cfg -cir-eh-abi-lowering 
%t.cir -o %t.eh.cir
 // RUN: FileCheck --input-file=%t.eh.cir %s -check-prefix=CIR-AFTER-EHABI
-// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions -fclangir -fno-clangir-call-conv-lowering -emit-llvm %s -o 
%t-cir.ll
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions -fclangir -emit-llvm %s -o %t-cir.ll
 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
 // RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions 
-fexceptions -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG

diff  --git a/clang/test/CIR/CodeGen/try-catch.cpp 
b/clang/test/CIR/CodeGen/try-catch.cpp
index f31b0be664fdb..aaf36a47626f3 100644
--- a/clang/test/CIR/CodeGen/try-catch.cpp
+++ b/clang/test/CIR/CodeGen/try-catch.cpp
@@ -1,8 +1,6 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-cir %s -o %t.cir
 // RUN: FileCheck --input-file=%t.cir %s -check-prefix=CIR
-// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-llvm %s -o %t-cir.ll
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-llvm %s -o %t-cir.ll
 // RUN: FileCheck --input-file=%t-cir.ll %s -check-prefix=LLVM
 // RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -emit-llvm %s -o %t.ll
 // RUN: FileCheck --input-file=%t.ll %s -check-prefix=OGCG
@@ -42,6 +40,9 @@ void try_catch_with_empty_catch_all() {
   }
 }
 
+// CIR: cir.func private dso_local @__gxx_personality_v0(...) -> !s32i
+
+// CIR: cir.func {{.*}} @_Z30try_catch_with_empty_catch_allv() 
personality(@__gxx_personality_v0)
 // CIR: %[[A_ADDR:.*]] = cir.alloca "a" {{.*}} init : !cir.ptr<!s32i>
 // CIR: %[[CONST_1:.*]] = cir.const #cir.int<1> : !s32i
 // CIR: cir.store{{.*}} %[[CONST_1]], %[[A_ADDR]] : !s32i, !cir.ptr<!s32i

diff  --git a/clang/test/CIR/CodeGen/try-no-throwing-calls.cpp 
b/clang/test/CIR/CodeGen/try-no-throwing-calls.cpp
index 492045cb451d5..db44c2a4e483c 100644
--- a/clang/test/CIR/CodeGen/try-no-throwing-calls.cpp
+++ b/clang/test/CIR/CodeGen/try-no-throwing-calls.cpp
@@ -1,8 +1,6 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-cir %s -o %t.cir
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-cir %s -o %t.cir
 // RUN: FileCheck --check-prefix=CIR --input-file=%t.cir %s
-// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -fno-clangir-call-conv-lowering 
-emit-llvm %s -o %t-cir.ll
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -fclangir -emit-llvm %s -o %t-cir.ll
 // RUN: FileCheck --check-prefix=LLVM --input-file=%t-cir.ll %s
 // RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-linux-gnu 
-fcxx-exceptions -fexceptions -emit-llvm %s -o %t.ll
 // RUN: FileCheck --check-prefix=OGCG --input-file=%t.ll %s

diff  --git a/clang/test/CIR/CodeGenCXX/typeid.cpp 
b/clang/test/CIR/CodeGenCXX/typeid.cpp
index b5c350f9fd4fb..47d4e57d31347 100644
--- a/clang/test/CIR/CodeGenCXX/typeid.cpp
+++ b/clang/test/CIR/CodeGenCXX/typeid.cpp
@@ -1,9 +1,7 @@
-// TODO(cir): drop -fno-clangir-call-conv-lowering once CallConvLowering
-// supports the builtin i32 in the Itanium EH personality signature.
-// RUN: %clang_cc1 -I%S/Inputs %s -triple x86_64-apple-darwin10 -fclangir 
-fno-clangir-call-conv-lowering -emit-cir -fcxx-exceptions -fexceptions -mmlir 
--mlir-print-ir-before=cir-cxxabi-lowering -o %t.cir 2> %t-before.cir
+// RUN: %clang_cc1 -I%S/Inputs %s -triple x86_64-apple-darwin10 -fclangir 
-emit-cir -fcxx-exceptions -fexceptions -mmlir 
--mlir-print-ir-before=cir-cxxabi-lowering -o %t.cir 2> %t-before.cir
 // RUN: FileCheck %s --input-file=%t-before.cir --check-prefixes=CIR,CIR-BEFORE
 // RUN: FileCheck %s --input-file=%t.cir --check-prefixes=CIR,CIR-AFTER
-// RUN: %clang_cc1 -I%S/Inputs %s -triple x86_64-apple-darwin10 -fclangir 
-fno-clangir-call-conv-lowering -emit-llvm -fcxx-exceptions -fexceptions -o - | 
FileCheck %s --check-prefixes=LLVM
+// RUN: %clang_cc1 -I%S/Inputs %s -triple x86_64-apple-darwin10 -fclangir 
-emit-llvm -fcxx-exceptions -fexceptions -o - | FileCheck %s 
--check-prefixes=LLVM
 // RUN: %clang_cc1 -I%S/Inputs %s -triple x86_64-apple-darwin10 -emit-llvm 
-fcxx-exceptions -fexceptions -o - | FileCheck %s --check-prefixes=LLVM
 #include <typeinfo>
 


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

Reply via email to