[clang] d85df3f - [SystemZ][z/OS] Add support for recognizing z/OS personality function in Clang (#76073)

via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 07:18:11 PST 2024


Author: Yusra Syeda
Date: 2024-01-15T10:18:07-05:00
New Revision: d85df3f2d6e8687c44e6802dcc0e59c14ff32c9b

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

LOG: [SystemZ][z/OS] Add support for recognizing z/OS personality function in Clang (#76073)

This PR adds support makes Clang aware of the name of the personality
function on z/OS.

Co-authored-by: Yusra Syeda <yusra.syeda at ibm.com>

Added: 
    

Modified: 
    clang/lib/CodeGen/CGCleanup.h
    clang/lib/CodeGen/CGException.cpp
    clang/test/CodeGenCXX/personality.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGCleanup.h b/clang/lib/CodeGen/CGCleanup.h
index 079a3e25d6dc78..fcfbf41b0eaff5 100644
--- a/clang/lib/CodeGen/CGCleanup.h
+++ b/clang/lib/CodeGen/CGCleanup.h
@@ -613,6 +613,7 @@ struct EHPersonality {
   static const EHPersonality MSVC_CxxFrameHandler3;
   static const EHPersonality GNU_Wasm_CPlusPlus;
   static const EHPersonality XL_CPlusPlus;
+  static const EHPersonality ZOS_CPlusPlus;
 
   /// Does this personality use landingpads or the family of pad instructions
   /// designed to form funclets?

diff  --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index 56a246eb65e0a8..5a9d06da12de57 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -127,6 +127,8 @@ const EHPersonality
 EHPersonality::GNU_Wasm_CPlusPlus = { "__gxx_wasm_personality_v0", nullptr };
 const EHPersonality EHPersonality::XL_CPlusPlus = {"__xlcxx_personality_v1",
                                                    nullptr};
+const EHPersonality EHPersonality::ZOS_CPlusPlus = {"__zos_cxx_personality_v2",
+                                                    nullptr};
 
 static const EHPersonality &getCPersonality(const TargetInfo &Target,
                                             const LangOptions &L) {
@@ -187,6 +189,8 @@ static const EHPersonality &getCXXPersonality(const TargetInfo &Target,
     return EHPersonality::GNU_CPlusPlus_SEH;
   if (L.hasWasmExceptions())
     return EHPersonality::GNU_Wasm_CPlusPlus;
+  if (T.isOSzOS())
+    return EHPersonality::ZOS_CPlusPlus;
   return EHPersonality::GNU_CPlusPlus;
 }
 

diff  --git a/clang/test/CodeGenCXX/personality.cpp b/clang/test/CodeGenCXX/personality.cpp
index 1c8baa2c412fe8..42ba2c227f028d 100644
--- a/clang/test/CodeGenCXX/personality.cpp
+++ b/clang/test/CodeGenCXX/personality.cpp
@@ -15,6 +15,9 @@
 // RUN: %clang_cc1 -triple powerpc-unknown-aix-xcoff -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-AIX
 // RUN: %clang_cc1 -triple powerpc64-unknown-aix-xcoff -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-AIX
 
+// RUN: %clang_cc1 -triple s390x-unknown-zos -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-ZOS
+// RUN: %clang_cc1 -triple systemz-unknown-zos -fexceptions -fcxx-exceptions -S -emit-llvm %s -o - | FileCheck %s -check-prefix CHECK-ZOS
+
 extern void g();
 
 // CHECK-GNU: personality ptr @__gxx_personality_v0
@@ -26,6 +29,8 @@ extern void g();
 
 // CHECK-AIX: personality ptr @__xlcxx_personality_v1
 
+// CHECK-ZOS: personality ptr @__zos_cxx_personality_v2
+
 void f() {
   try {
     g();


        


More information about the cfe-commits mailing list