Skip to content

Commit

Permalink
[SystemZ][z/OS] Add support for recognizing z/OS personality function…
Browse files Browse the repository at this point in the history
… 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@ibm.com>
  • Loading branch information
ysyeda and Yusra Syeda committed Jan 15, 2024
1 parent 48e5b5e commit d85df3f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGCleanup.h
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/CodeGen/CGException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down
5 changes: 5 additions & 0 deletions clang/test/CodeGenCXX/personality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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();
Expand Down

0 comments on commit d85df3f

Please sign in to comment.