[clang] [SystemZ][z/OS] Replace characters that are not supported by ASCII to EBCDIC conversion (PR #72906)
https://github.com/perry-ca approved this pull request. LGTM https://github.com/llvm/llvm-project/pull/72906 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] This change adds support for the PPA2 section in zOS (PR #68926)
@@ -976,6 +976,46 @@ void CodeGenModule::Release() { Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity(); getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth); + if (getTriple().isOSzOS()) { +getModule().addModuleFlag(llvm::Module::Warning, + "zos_product_major_version", + uint32_t(CLANG_VERSION_MAJOR)); +getModule().addModuleFlag(llvm::Module::Warning, + "zos_product_minor_version", + uint32_t(CLANG_VERSION_MINOR)); +getModule().addModuleFlag(llvm::Module::Warning, "zos_product_patchlevel", + uint32_t(CLANG_VERSION_PATCHLEVEL)); +std::string ProductId; +#ifdef CLANG_VENDOR +ProductId = #CLANG_VENDOR; +#else +ProductId = "clang"; +#endif +// Remove - from Product Id, which makes it consistent with legacy. +std::size_t DashFound = ProductId.find("-"); +if (DashFound != std::string::npos) + ProductId.erase(ProductId.begin() + DashFound); perry-ca wrote: The proper product id contains the dash. The only place we don't include the dash is in the PPA2 timestamp string. This is to be compat with XL. We would like all uses of CLANG_VENDOR to use the proper product id (except for this one use in PPA2). https://github.com/llvm/llvm-project/pull/68926 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[lld] [clang-tools-extra] [compiler-rt] [libcxxabi] [flang] [libunwind] [lldb] [libclc] [llvm] [clang] [libc] [libcxx] [builtins] Generate __multc3 for z/OS (PR #77554)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/77554 >From 7ba4d61bd2beda03ba0fcefc9ca5c1ff08ffd48e Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 9 Jan 2024 20:59:28 -0600 Subject: [PATCH 1/3] Generate __multc3 for z/OS --- compiler-rt/lib/builtins/divtc3.c| 3 --- compiler-rt/lib/builtins/fp_lib.h| 8 ++-- compiler-rt/lib/builtins/int_types.h | 6 -- compiler-rt/lib/builtins/multc3.c| 4 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index e970cef574b21d..6ec9c5f17d4b68 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,6 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_TF_MODE) // Returns: the quotient of (a + ib) / (c + id) @@ -52,5 +51,3 @@ COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { } return z; } - -#endif diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index af406e760497a4..a293788fc68f56 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -188,6 +188,8 @@ static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { #undef Word_HiMask #undef Word_LoMask #undef Word_FullMask +#else +typedef long double fp_t; #endif // defined(CRT_HAS_TF_MODE) #else #error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined. @@ -374,10 +376,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { #endif } -#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +#elif defined(QUAD_PRECISION) // The generic implementation only works for ieee754 floating point. For other // floating point types, continue to rely on the libm implementation for now. -#if defined(CRT_HAS_IEEE_TF) +#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF) static __inline tf_float __compiler_rt_logbtf(tf_float x) { return __compiler_rt_logbX(x); } @@ -405,6 +407,8 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_logbl crt_logbl #define __compiler_rt_scalbnl crt_scalbnl #define __compiler_rt_fmaxl crt_fmaxl +#define crt_fabstf crt_fabsl +#define crt_copysigntf crt_copysignl #else #error Unsupported TF mode type #endif diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index 7624c728061518..ebbc63af598b76 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -189,8 +189,10 @@ typedef long double tf_float; #define CRT_LDBL_IEEE_F128 #endif #define TF_C(x) x##L -#elif __LDBL_MANT_DIG__ == 113 -// Use long double instead of __float128 if it matches the IEEE 128-bit format. +#elif __LDBL_MANT_DIG__ == 113 || \ +(__FLT_RADIX__ == 16 && __LDBL_MANT_DIG__ == 28) +// Use long double instead of __float128 if it matches the IEEE 128-bit format +// or the IBM hexadecimal format. #define CRT_LDBL_128BIT #define CRT_HAS_F128 #define CRT_HAS_IEEE_TF diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c index f20e53ccbf233b..21c522d0330b7f 100644 --- a/compiler-rt/lib/builtins/multc3.c +++ b/compiler-rt/lib/builtins/multc3.c @@ -15,8 +15,6 @@ #include "int_lib.h" #include "int_math.h" -#if defined(CRT_HAS_TF_MODE) - // Returns: the product of a + ib and c + id COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { @@ -66,5 +64,3 @@ COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { } return z; } - -#endif >From 81b814ccc0b216eb9464c9fa5d4d28b0511c2338 Mon Sep 17 00:00:00 2001 From: Sean Perry <39927768+perry...@users.noreply.github.com> Date: Tue, 9 Jan 2024 23:49:29 -0500 Subject: [PATCH 2/3] formatting update --- compiler-rt/lib/builtins/divtc3.c | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index 6ec9c5f17d4b68..7d3185c9d71fbb 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,6 @@ #define QUAD_PRECISION #include "fp_lib.h" - // Returns: the quotient of (a + ib) / (c + id) COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { >From 2cb932ab37caf472aa296f5d7c811feada8464f0 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 10 Jan 2024 16:03:48 -0600 Subject: [PATCH 3/3] only define CRT_HAS_F128 & CRT_HAS_IEEE_TF for IEEE --- compiler-rt/lib/builtins/int_types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index ebbc63af598b76..9ceced37a997f4 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -194,8 +194,10 @@ typedef long double tf_float; // Use long double instead of __float128 if it matches the IEEE 128-
[clang-tools-extra] [compiler-rt] [flang] [libcxxabi] [llvm] [lldb] [libunwind] [libclc] [lld] [libc] [clang] [libcxx] [builtins] Generate __multc3 for z/OS (PR #77554)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/77554 >From 7ba4d61bd2beda03ba0fcefc9ca5c1ff08ffd48e Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 9 Jan 2024 20:59:28 -0600 Subject: [PATCH 1/4] Generate __multc3 for z/OS --- compiler-rt/lib/builtins/divtc3.c| 3 --- compiler-rt/lib/builtins/fp_lib.h| 8 ++-- compiler-rt/lib/builtins/int_types.h | 6 -- compiler-rt/lib/builtins/multc3.c| 4 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index e970cef574b21d..6ec9c5f17d4b68 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,6 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_TF_MODE) // Returns: the quotient of (a + ib) / (c + id) @@ -52,5 +51,3 @@ COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { } return z; } - -#endif diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index af406e760497a4..a293788fc68f56 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -188,6 +188,8 @@ static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { #undef Word_HiMask #undef Word_LoMask #undef Word_FullMask +#else +typedef long double fp_t; #endif // defined(CRT_HAS_TF_MODE) #else #error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined. @@ -374,10 +376,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { #endif } -#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +#elif defined(QUAD_PRECISION) // The generic implementation only works for ieee754 floating point. For other // floating point types, continue to rely on the libm implementation for now. -#if defined(CRT_HAS_IEEE_TF) +#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF) static __inline tf_float __compiler_rt_logbtf(tf_float x) { return __compiler_rt_logbX(x); } @@ -405,6 +407,8 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_logbl crt_logbl #define __compiler_rt_scalbnl crt_scalbnl #define __compiler_rt_fmaxl crt_fmaxl +#define crt_fabstf crt_fabsl +#define crt_copysigntf crt_copysignl #else #error Unsupported TF mode type #endif diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index 7624c728061518..ebbc63af598b76 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -189,8 +189,10 @@ typedef long double tf_float; #define CRT_LDBL_IEEE_F128 #endif #define TF_C(x) x##L -#elif __LDBL_MANT_DIG__ == 113 -// Use long double instead of __float128 if it matches the IEEE 128-bit format. +#elif __LDBL_MANT_DIG__ == 113 || \ +(__FLT_RADIX__ == 16 && __LDBL_MANT_DIG__ == 28) +// Use long double instead of __float128 if it matches the IEEE 128-bit format +// or the IBM hexadecimal format. #define CRT_LDBL_128BIT #define CRT_HAS_F128 #define CRT_HAS_IEEE_TF diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c index f20e53ccbf233b..21c522d0330b7f 100644 --- a/compiler-rt/lib/builtins/multc3.c +++ b/compiler-rt/lib/builtins/multc3.c @@ -15,8 +15,6 @@ #include "int_lib.h" #include "int_math.h" -#if defined(CRT_HAS_TF_MODE) - // Returns: the product of a + ib and c + id COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { @@ -66,5 +64,3 @@ COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { } return z; } - -#endif >From 81b814ccc0b216eb9464c9fa5d4d28b0511c2338 Mon Sep 17 00:00:00 2001 From: Sean Perry <39927768+perry...@users.noreply.github.com> Date: Tue, 9 Jan 2024 23:49:29 -0500 Subject: [PATCH 2/4] formatting update --- compiler-rt/lib/builtins/divtc3.c | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index 6ec9c5f17d4b68..7d3185c9d71fbb 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,6 @@ #define QUAD_PRECISION #include "fp_lib.h" - // Returns: the quotient of (a + ib) / (c + id) COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { >From 2cb932ab37caf472aa296f5d7c811feada8464f0 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 10 Jan 2024 16:03:48 -0600 Subject: [PATCH 3/4] only define CRT_HAS_F128 & CRT_HAS_IEEE_TF for IEEE --- compiler-rt/lib/builtins/int_types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index ebbc63af598b76..9ceced37a997f4 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -194,8 +194,10 @@ typedef long double tf_float; // Use long double instead of __float128 if it matches the IEEE 128-
[clang-tools-extra] [compiler-rt] [flang] [libcxxabi] [llvm] [lldb] [libunwind] [libclc] [lld] [libc] [clang] [libcxx] [builtins] Generate __multc3 for z/OS (PR #77554)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/77554 >From 7ba4d61bd2beda03ba0fcefc9ca5c1ff08ffd48e Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 9 Jan 2024 20:59:28 -0600 Subject: [PATCH 1/5] Generate __multc3 for z/OS --- compiler-rt/lib/builtins/divtc3.c| 3 --- compiler-rt/lib/builtins/fp_lib.h| 8 ++-- compiler-rt/lib/builtins/int_types.h | 6 -- compiler-rt/lib/builtins/multc3.c| 4 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index e970cef574b21d..6ec9c5f17d4b68 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,6 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_TF_MODE) // Returns: the quotient of (a + ib) / (c + id) @@ -52,5 +51,3 @@ COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { } return z; } - -#endif diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index af406e760497a4..a293788fc68f56 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -188,6 +188,8 @@ static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { #undef Word_HiMask #undef Word_LoMask #undef Word_FullMask +#else +typedef long double fp_t; #endif // defined(CRT_HAS_TF_MODE) #else #error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined. @@ -374,10 +376,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { #endif } -#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +#elif defined(QUAD_PRECISION) // The generic implementation only works for ieee754 floating point. For other // floating point types, continue to rely on the libm implementation for now. -#if defined(CRT_HAS_IEEE_TF) +#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF) static __inline tf_float __compiler_rt_logbtf(tf_float x) { return __compiler_rt_logbX(x); } @@ -405,6 +407,8 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_logbl crt_logbl #define __compiler_rt_scalbnl crt_scalbnl #define __compiler_rt_fmaxl crt_fmaxl +#define crt_fabstf crt_fabsl +#define crt_copysigntf crt_copysignl #else #error Unsupported TF mode type #endif diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index 7624c728061518..ebbc63af598b76 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -189,8 +189,10 @@ typedef long double tf_float; #define CRT_LDBL_IEEE_F128 #endif #define TF_C(x) x##L -#elif __LDBL_MANT_DIG__ == 113 -// Use long double instead of __float128 if it matches the IEEE 128-bit format. +#elif __LDBL_MANT_DIG__ == 113 || \ +(__FLT_RADIX__ == 16 && __LDBL_MANT_DIG__ == 28) +// Use long double instead of __float128 if it matches the IEEE 128-bit format +// or the IBM hexadecimal format. #define CRT_LDBL_128BIT #define CRT_HAS_F128 #define CRT_HAS_IEEE_TF diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c index f20e53ccbf233b..21c522d0330b7f 100644 --- a/compiler-rt/lib/builtins/multc3.c +++ b/compiler-rt/lib/builtins/multc3.c @@ -15,8 +15,6 @@ #include "int_lib.h" #include "int_math.h" -#if defined(CRT_HAS_TF_MODE) - // Returns: the product of a + ib and c + id COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { @@ -66,5 +64,3 @@ COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { } return z; } - -#endif >From 81b814ccc0b216eb9464c9fa5d4d28b0511c2338 Mon Sep 17 00:00:00 2001 From: Sean Perry <39927768+perry...@users.noreply.github.com> Date: Tue, 9 Jan 2024 23:49:29 -0500 Subject: [PATCH 2/5] formatting update --- compiler-rt/lib/builtins/divtc3.c | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index 6ec9c5f17d4b68..7d3185c9d71fbb 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,6 @@ #define QUAD_PRECISION #include "fp_lib.h" - // Returns: the quotient of (a + ib) / (c + id) COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { >From 2cb932ab37caf472aa296f5d7c811feada8464f0 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 10 Jan 2024 16:03:48 -0600 Subject: [PATCH 3/5] only define CRT_HAS_F128 & CRT_HAS_IEEE_TF for IEEE --- compiler-rt/lib/builtins/int_types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index ebbc63af598b76..9ceced37a997f4 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -194,8 +194,10 @@ typedef long double tf_float; // Use long double instead of __float128 if it matches the IEEE 128-
[clang-tools-extra] [mlir] [clang] [llvm] [compiler-rt] [clang] Fix a bug with qualified name lookup into current instantiation (PR #73018)
perry-ca wrote: Was this PR meant to change the behaviour for c++11/14? https://github.com/llvm/llvm-project/pull/73018 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[flang] [libc] [libcxx] [llvm] [clang] [lldb] [lld] [clang-tools-extra] [libcxxabi] [libunwind] [libclc] [compiler-rt] [builtins] Generate __multc3 for z/OS (PR #77554)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/77554 >From 7ba4d61bd2beda03ba0fcefc9ca5c1ff08ffd48e Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 9 Jan 2024 20:59:28 -0600 Subject: [PATCH 1/6] Generate __multc3 for z/OS --- compiler-rt/lib/builtins/divtc3.c| 3 --- compiler-rt/lib/builtins/fp_lib.h| 8 ++-- compiler-rt/lib/builtins/int_types.h | 6 -- compiler-rt/lib/builtins/multc3.c| 4 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index e970cef574b21d..6ec9c5f17d4b68 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,6 @@ #define QUAD_PRECISION #include "fp_lib.h" -#if defined(CRT_HAS_TF_MODE) // Returns: the quotient of (a + ib) / (c + id) @@ -52,5 +51,3 @@ COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { } return z; } - -#endif diff --git a/compiler-rt/lib/builtins/fp_lib.h b/compiler-rt/lib/builtins/fp_lib.h index af406e760497a4..a293788fc68f56 100644 --- a/compiler-rt/lib/builtins/fp_lib.h +++ b/compiler-rt/lib/builtins/fp_lib.h @@ -188,6 +188,8 @@ static __inline void wideMultiply(rep_t a, rep_t b, rep_t *hi, rep_t *lo) { #undef Word_HiMask #undef Word_LoMask #undef Word_FullMask +#else +typedef long double fp_t; #endif // defined(CRT_HAS_TF_MODE) #else #error SINGLE_PRECISION, DOUBLE_PRECISION or QUAD_PRECISION must be defined. @@ -374,10 +376,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { #endif } -#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +#elif defined(QUAD_PRECISION) // The generic implementation only works for ieee754 floating point. For other // floating point types, continue to rely on the libm implementation for now. -#if defined(CRT_HAS_IEEE_TF) +#if defined(CRT_HAS_TF_MODE) && defined(CRT_HAS_IEEE_TF) static __inline tf_float __compiler_rt_logbtf(tf_float x) { return __compiler_rt_logbX(x); } @@ -405,6 +407,8 @@ static __inline tf_float __compiler_rt_fmaxtf(tf_float x, tf_float y) { #define __compiler_rt_logbl crt_logbl #define __compiler_rt_scalbnl crt_scalbnl #define __compiler_rt_fmaxl crt_fmaxl +#define crt_fabstf crt_fabsl +#define crt_copysigntf crt_copysignl #else #error Unsupported TF mode type #endif diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index 7624c728061518..ebbc63af598b76 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -189,8 +189,10 @@ typedef long double tf_float; #define CRT_LDBL_IEEE_F128 #endif #define TF_C(x) x##L -#elif __LDBL_MANT_DIG__ == 113 -// Use long double instead of __float128 if it matches the IEEE 128-bit format. +#elif __LDBL_MANT_DIG__ == 113 || \ +(__FLT_RADIX__ == 16 && __LDBL_MANT_DIG__ == 28) +// Use long double instead of __float128 if it matches the IEEE 128-bit format +// or the IBM hexadecimal format. #define CRT_LDBL_128BIT #define CRT_HAS_F128 #define CRT_HAS_IEEE_TF diff --git a/compiler-rt/lib/builtins/multc3.c b/compiler-rt/lib/builtins/multc3.c index f20e53ccbf233b..21c522d0330b7f 100644 --- a/compiler-rt/lib/builtins/multc3.c +++ b/compiler-rt/lib/builtins/multc3.c @@ -15,8 +15,6 @@ #include "int_lib.h" #include "int_math.h" -#if defined(CRT_HAS_TF_MODE) - // Returns: the product of a + ib and c + id COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { @@ -66,5 +64,3 @@ COMPILER_RT_ABI Qcomplex __multc3(fp_t a, fp_t b, fp_t c, fp_t d) { } return z; } - -#endif >From 81b814ccc0b216eb9464c9fa5d4d28b0511c2338 Mon Sep 17 00:00:00 2001 From: Sean Perry <39927768+perry...@users.noreply.github.com> Date: Tue, 9 Jan 2024 23:49:29 -0500 Subject: [PATCH 2/6] formatting update --- compiler-rt/lib/builtins/divtc3.c | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler-rt/lib/builtins/divtc3.c b/compiler-rt/lib/builtins/divtc3.c index 6ec9c5f17d4b68..7d3185c9d71fbb 100644 --- a/compiler-rt/lib/builtins/divtc3.c +++ b/compiler-rt/lib/builtins/divtc3.c @@ -13,7 +13,6 @@ #define QUAD_PRECISION #include "fp_lib.h" - // Returns: the quotient of (a + ib) / (c + id) COMPILER_RT_ABI Qcomplex __divtc3(fp_t __a, fp_t __b, fp_t __c, fp_t __d) { >From 2cb932ab37caf472aa296f5d7c811feada8464f0 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 10 Jan 2024 16:03:48 -0600 Subject: [PATCH 3/6] only define CRT_HAS_F128 & CRT_HAS_IEEE_TF for IEEE --- compiler-rt/lib/builtins/int_types.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler-rt/lib/builtins/int_types.h b/compiler-rt/lib/builtins/int_types.h index ebbc63af598b76..9ceced37a997f4 100644 --- a/compiler-rt/lib/builtins/int_types.h +++ b/compiler-rt/lib/builtins/int_types.h @@ -194,8 +194,10 @@ typedef long double tf_float; // Use long double instead of __float128 if it matches the IEEE 128-
[compiler-rt] [libcxxabi] [lld] [lldb] [clang] [llvm] [libc] [libclc] [libunwind] [libcxx] [clang-tools-extra] [flang] [builtins] Generate __multc3 for z/OS (PR #77554)
perry-ca wrote: Thanks. I don't have write access yet. Would you be able to merge this. https://github.com/llvm/llvm-project/pull/77554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxxabi] [clang-tools-extra] [flang] [lldb] [libcxx] [clang] [libclc] [libunwind] [libc] [llvm] [compiler-rt] [lld] [builtins] Generate __multc3 for z/OS (PR #77554)
@@ -374,10 +376,10 @@ static __inline fp_t __compiler_rt_fmax(fp_t x, fp_t y) { #endif } -#elif defined(QUAD_PRECISION) && defined(CRT_HAS_TF_MODE) +#elif defined(QUAD_PRECISION) perry-ca wrote: I've put up #77981 for review. https://github.com/llvm/llvm-project/pull/77554 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/107613 An example of this is the -mpure-code option. Without a config file being used, an error message will print `-mpure-code`. But if a config file is used, the error message will print `-mexecute-only`. >From 27f31954976948e4e0d194db5da6bc550b4c2200 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 10:54:07 -0500 Subject: [PATCH] clone the alias option too --- clang/lib/Driver/Driver.cpp | 11 +++ clang/test/Driver/arm-execute-only.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b3783e20eabba..e4604f4e3ea753 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,17 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, Copy->setOwnsValues(Opt->getOwnsValues()); Opt->setOwnsValues(false); Args.append(Copy); + if (Opt->getAlias()) { +const Arg *Alias = Opt->getAlias(); +unsigned Index = Args.MakeIndex(Alias->getSpelling()); +auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), + Index, BaseArg); +AliasCopy->getValues() = Alias->getValues(); +AliasCopy->setOwnsValues(false); +if (Alias->isClaimed()) + AliasCopy->claim(); +Copy->setAlias(std::move(AliasCopy)); + } } bool Driver::readConfigFile(StringRef FileName, diff --git a/clang/test/Driver/arm-execute-only.c b/clang/test/Driver/arm-execute-only.c index a9bf1656fd27e5..d654ec364a87f5 100644 --- a/clang/test/Driver/arm-execute-only.c +++ b/clang/test/Driver/arm-execute-only.c @@ -19,6 +19,9 @@ // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt %s 2>&1 \ // RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT +// RUN: echo "-DABC" > %t.cfg +// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt --config %t.cfg %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT // CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified with '-mno-movt' // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv6-m -mexecute-only -fropi %s 2>&1 \ ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/107613 >From 27f31954976948e4e0d194db5da6bc550b4c2200 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 10:54:07 -0500 Subject: [PATCH 1/2] clone the alias option too --- clang/lib/Driver/Driver.cpp | 11 +++ clang/test/Driver/arm-execute-only.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b3783e20eabba..e4604f4e3ea753 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,17 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, Copy->setOwnsValues(Opt->getOwnsValues()); Opt->setOwnsValues(false); Args.append(Copy); + if (Opt->getAlias()) { +const Arg *Alias = Opt->getAlias(); +unsigned Index = Args.MakeIndex(Alias->getSpelling()); +auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), + Index, BaseArg); +AliasCopy->getValues() = Alias->getValues(); +AliasCopy->setOwnsValues(false); +if (Alias->isClaimed()) + AliasCopy->claim(); +Copy->setAlias(std::move(AliasCopy)); + } } bool Driver::readConfigFile(StringRef FileName, diff --git a/clang/test/Driver/arm-execute-only.c b/clang/test/Driver/arm-execute-only.c index a9bf1656fd27e5..d654ec364a87f5 100644 --- a/clang/test/Driver/arm-execute-only.c +++ b/clang/test/Driver/arm-execute-only.c @@ -19,6 +19,9 @@ // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt %s 2>&1 \ // RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT +// RUN: echo "-DABC" > %t.cfg +// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt --config %t.cfg %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT // CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified with '-mno-movt' // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv6-m -mexecute-only -fropi %s 2>&1 \ >From 261e525859295294075bb77a1aa3bd6778d87d68 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 12:37:51 -0500 Subject: [PATCH 2/2] fix formatting --- clang/lib/Driver/Driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e4604f4e3ea753..5e2675db6535f1 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1001,8 +1001,8 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, if (Opt->getAlias()) { const Arg *Alias = Opt->getAlias(); unsigned Index = Args.MakeIndex(Alias->getSpelling()); -auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), - Index, BaseArg); +auto AliasCopy = std::make_unique( +Alias->getOption(), Args.getArgString(Index), Index, BaseArg); AliasCopy->getValues() = Alias->getValues(); AliasCopy->setOwnsValues(false); if (Alias->isClaimed()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/107613 >From 27f31954976948e4e0d194db5da6bc550b4c2200 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 10:54:07 -0500 Subject: [PATCH 1/2] clone the alias option too --- clang/lib/Driver/Driver.cpp | 11 +++ clang/test/Driver/arm-execute-only.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b3783e20eabba..e4604f4e3ea753 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,17 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, Copy->setOwnsValues(Opt->getOwnsValues()); Opt->setOwnsValues(false); Args.append(Copy); + if (Opt->getAlias()) { +const Arg *Alias = Opt->getAlias(); +unsigned Index = Args.MakeIndex(Alias->getSpelling()); +auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), + Index, BaseArg); +AliasCopy->getValues() = Alias->getValues(); +AliasCopy->setOwnsValues(false); +if (Alias->isClaimed()) + AliasCopy->claim(); +Copy->setAlias(std::move(AliasCopy)); + } } bool Driver::readConfigFile(StringRef FileName, diff --git a/clang/test/Driver/arm-execute-only.c b/clang/test/Driver/arm-execute-only.c index a9bf1656fd27e5..d654ec364a87f5 100644 --- a/clang/test/Driver/arm-execute-only.c +++ b/clang/test/Driver/arm-execute-only.c @@ -19,6 +19,9 @@ // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt %s 2>&1 \ // RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT +// RUN: echo "-DABC" > %t.cfg +// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt --config %t.cfg %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT // CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified with '-mno-movt' // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv6-m -mexecute-only -fropi %s 2>&1 \ >From 261e525859295294075bb77a1aa3bd6778d87d68 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 12:37:51 -0500 Subject: [PATCH 2/2] fix formatting --- clang/lib/Driver/Driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e4604f4e3ea753..5e2675db6535f1 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1001,8 +1001,8 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, if (Opt->getAlias()) { const Arg *Alias = Opt->getAlias(); unsigned Index = Args.MakeIndex(Alias->getSpelling()); -auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), - Index, BaseArg); +auto AliasCopy = std::make_unique( +Alias->getOption(), Args.getArgString(Index), Index, BaseArg); AliasCopy->getValues() = Alias->getValues(); AliasCopy->setOwnsValues(false); if (Alias->isClaimed()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
perry-ca wrote: @redstar @abhina-sree Could you review this. Thanks https://github.com/llvm/llvm-project/pull/107613 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/107613 >From 27f31954976948e4e0d194db5da6bc550b4c2200 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 10:54:07 -0500 Subject: [PATCH 1/2] clone the alias option too --- clang/lib/Driver/Driver.cpp | 11 +++ clang/test/Driver/arm-execute-only.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b3783e20eabba..e4604f4e3ea753 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,17 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, Copy->setOwnsValues(Opt->getOwnsValues()); Opt->setOwnsValues(false); Args.append(Copy); + if (Opt->getAlias()) { +const Arg *Alias = Opt->getAlias(); +unsigned Index = Args.MakeIndex(Alias->getSpelling()); +auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), + Index, BaseArg); +AliasCopy->getValues() = Alias->getValues(); +AliasCopy->setOwnsValues(false); +if (Alias->isClaimed()) + AliasCopy->claim(); +Copy->setAlias(std::move(AliasCopy)); + } } bool Driver::readConfigFile(StringRef FileName, diff --git a/clang/test/Driver/arm-execute-only.c b/clang/test/Driver/arm-execute-only.c index a9bf1656fd27e5..d654ec364a87f5 100644 --- a/clang/test/Driver/arm-execute-only.c +++ b/clang/test/Driver/arm-execute-only.c @@ -19,6 +19,9 @@ // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt %s 2>&1 \ // RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT +// RUN: echo "-DABC" > %t.cfg +// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt --config %t.cfg %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT // CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified with '-mno-movt' // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv6-m -mexecute-only -fropi %s 2>&1 \ >From 261e525859295294075bb77a1aa3bd6778d87d68 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 12:37:51 -0500 Subject: [PATCH 2/2] fix formatting --- clang/lib/Driver/Driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e4604f4e3ea753..5e2675db6535f1 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1001,8 +1001,8 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, if (Opt->getAlias()) { const Arg *Alias = Opt->getAlias(); unsigned Index = Args.MakeIndex(Alias->getSpelling()); -auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), - Index, BaseArg); +auto AliasCopy = std::make_unique( +Alias->getOption(), Args.getArgString(Index), Index, BaseArg); AliasCopy->getValues() = Alias->getValues(); AliasCopy->setOwnsValues(false); if (Alias->isClaimed()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/107613 >From 27f31954976948e4e0d194db5da6bc550b4c2200 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 10:54:07 -0500 Subject: [PATCH 1/3] clone the alias option too --- clang/lib/Driver/Driver.cpp | 11 +++ clang/test/Driver/arm-execute-only.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b3783e20eabba..e4604f4e3ea753 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,17 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, Copy->setOwnsValues(Opt->getOwnsValues()); Opt->setOwnsValues(false); Args.append(Copy); + if (Opt->getAlias()) { +const Arg *Alias = Opt->getAlias(); +unsigned Index = Args.MakeIndex(Alias->getSpelling()); +auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), + Index, BaseArg); +AliasCopy->getValues() = Alias->getValues(); +AliasCopy->setOwnsValues(false); +if (Alias->isClaimed()) + AliasCopy->claim(); +Copy->setAlias(std::move(AliasCopy)); + } } bool Driver::readConfigFile(StringRef FileName, diff --git a/clang/test/Driver/arm-execute-only.c b/clang/test/Driver/arm-execute-only.c index a9bf1656fd27e5..d654ec364a87f5 100644 --- a/clang/test/Driver/arm-execute-only.c +++ b/clang/test/Driver/arm-execute-only.c @@ -19,6 +19,9 @@ // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt %s 2>&1 \ // RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT +// RUN: echo "-DABC" > %t.cfg +// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt --config %t.cfg %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT // CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified with '-mno-movt' // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv6-m -mexecute-only -fropi %s 2>&1 \ >From 261e525859295294075bb77a1aa3bd6778d87d68 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 12:37:51 -0500 Subject: [PATCH 2/3] fix formatting --- clang/lib/Driver/Driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e4604f4e3ea753..5e2675db6535f1 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1001,8 +1001,8 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, if (Opt->getAlias()) { const Arg *Alias = Opt->getAlias(); unsigned Index = Args.MakeIndex(Alias->getSpelling()); -auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), - Index, BaseArg); +auto AliasCopy = std::make_unique( +Alias->getOption(), Args.getArgString(Index), Index, BaseArg); AliasCopy->getValues() = Alias->getValues(); AliasCopy->setOwnsValues(false); if (Alias->isClaimed()) >From 12690d76b5b6906ad84bbf46d774c3c193faeb1b Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Mon, 9 Sep 2024 15:46:34 -0500 Subject: [PATCH 3/3] Don't pass base arg to alias ctor --- clang/lib/Driver/Driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index ec681943e16fa1..cbafa787354d40 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1002,7 +1002,7 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, const Arg *Alias = Opt->getAlias(); unsigned Index = Args.MakeIndex(Alias->getSpelling()); auto AliasCopy = std::make_unique( -Alias->getOption(), Args.getArgString(Index), Index, BaseArg); +Alias->getOption(), Args.getArgString(Index), Index); AliasCopy->getValues() = Alias->getValues(); AliasCopy->setOwnsValues(false); if (Alias->isClaimed()) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/107613 >From 27f31954976948e4e0d194db5da6bc550b4c2200 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 10:54:07 -0500 Subject: [PATCH 1/4] clone the alias option too --- clang/lib/Driver/Driver.cpp | 11 +++ clang/test/Driver/arm-execute-only.c | 3 +++ 2 files changed, 14 insertions(+) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 5b3783e20eabba..e4604f4e3ea753 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,17 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, Copy->setOwnsValues(Opt->getOwnsValues()); Opt->setOwnsValues(false); Args.append(Copy); + if (Opt->getAlias()) { +const Arg *Alias = Opt->getAlias(); +unsigned Index = Args.MakeIndex(Alias->getSpelling()); +auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), + Index, BaseArg); +AliasCopy->getValues() = Alias->getValues(); +AliasCopy->setOwnsValues(false); +if (Alias->isClaimed()) + AliasCopy->claim(); +Copy->setAlias(std::move(AliasCopy)); + } } bool Driver::readConfigFile(StringRef FileName, diff --git a/clang/test/Driver/arm-execute-only.c b/clang/test/Driver/arm-execute-only.c index a9bf1656fd27e5..d654ec364a87f5 100644 --- a/clang/test/Driver/arm-execute-only.c +++ b/clang/test/Driver/arm-execute-only.c @@ -19,6 +19,9 @@ // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt %s 2>&1 \ // RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT +// RUN: echo "-DABC" > %t.cfg +// RUN: not %clang -### --target=arm-arm-none-eabi -march=armv8-m.main -mpure-code -mno-movt --config %t.cfg %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-PURE-CODE-NO-MOVT // CHECK-PURE-CODE-NO-MOVT: error: option '-mpure-code' cannot be specified with '-mno-movt' // RUN: not %clang -### --target=arm-arm-none-eabi -march=armv6-m -mexecute-only -fropi %s 2>&1 \ >From 261e525859295294075bb77a1aa3bd6778d87d68 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 6 Sep 2024 12:37:51 -0500 Subject: [PATCH 2/4] fix formatting --- clang/lib/Driver/Driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e4604f4e3ea753..5e2675db6535f1 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1001,8 +1001,8 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, if (Opt->getAlias()) { const Arg *Alias = Opt->getAlias(); unsigned Index = Args.MakeIndex(Alias->getSpelling()); -auto AliasCopy = std::make_unique(Alias->getOption(), Args.getArgString(Index), - Index, BaseArg); +auto AliasCopy = std::make_unique( +Alias->getOption(), Args.getArgString(Index), Index, BaseArg); AliasCopy->getValues() = Alias->getValues(); AliasCopy->setOwnsValues(false); if (Alias->isClaimed()) >From 12690d76b5b6906ad84bbf46d774c3c193faeb1b Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Mon, 9 Sep 2024 15:46:34 -0500 Subject: [PATCH 3/4] Don't pass base arg to alias ctor --- clang/lib/Driver/Driver.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index ec681943e16fa1..cbafa787354d40 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1002,7 +1002,7 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, const Arg *Alias = Opt->getAlias(); unsigned Index = Args.MakeIndex(Alias->getSpelling()); auto AliasCopy = std::make_unique( -Alias->getOption(), Args.getArgString(Index), Index, BaseArg); +Alias->getOption(), Args.getArgString(Index), Index); AliasCopy->getValues() = Alias->getValues(); AliasCopy->setOwnsValues(false); if (Alias->isClaimed()) >From 790ad1f6f050964b7b1aa5c4b9163743c50ff992 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Mon, 9 Sep 2024 15:54:54 -0500 Subject: [PATCH 4/4] new formatting --- clang/lib/Driver/Driver.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index cbafa787354d40..c97c68d6f0425d 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1001,8 +1001,8 @@ static void appendOneArg(InputArgList &Args, const Arg *Opt, if (Opt->getAlias()) { const Arg *Alias = Opt->getAlias(); unsigned Index = Args.MakeIndex(Alias->getSpelling()); -auto AliasCopy = std::make_unique( -Alias->getOption(), Args.getArgString(Index), Index); +auto AliasCopy = std::make_unique(Alias->getOption(), + Args.getArgString(Index), Index); AliasCopy->getValues() = Alias->getValues();
[clang] Mark tests as unsupported when targeting z/OS (PR #107916)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/107916 Set up these tests so these are marked as unsupported when targeting z/OS. Most would already be unsupported if you ran lit on z/OS. However, they also need to be unsupported if the default triple is z/OS. >From 3cf2e2b99cf3d96e1fe691d93e5d46334a784567 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Mon, 9 Sep 2024 16:04:49 -0500 Subject: [PATCH] Mark tests as unsupported when targeting z/OS --- clang/test/Analysis/ctu-on-demand-parsing.c | 1 + clang/test/Analysis/ctu-on-demand-parsing.cpp | 1 + clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm | 5 +++-- clang/test/Driver/hipstdpar.c | 1 + clang/test/Driver/lld-repro.c | 2 +- clang/test/OpenMP/lit.local.cfg | 4 6 files changed, 11 insertions(+), 3 deletions(-) diff --git a/clang/test/Analysis/ctu-on-demand-parsing.c b/clang/test/Analysis/ctu-on-demand-parsing.c index 72288def61b13e..17ade150ded5e3 100644 --- a/clang/test/Analysis/ctu-on-demand-parsing.c +++ b/clang/test/Analysis/ctu-on-demand-parsing.c @@ -24,6 +24,7 @@ // // FIXME: Path handling should work on all platforms. // REQUIRES: system-linux +// UNSUPPORTED: target={{.*}}-zos{{.*}} void clang_analyzer_eval(int); diff --git a/clang/test/Analysis/ctu-on-demand-parsing.cpp b/clang/test/Analysis/ctu-on-demand-parsing.cpp index d28d3c22c69b07..0c0128faefaead 100644 --- a/clang/test/Analysis/ctu-on-demand-parsing.cpp +++ b/clang/test/Analysis/ctu-on-demand-parsing.cpp @@ -35,6 +35,7 @@ // // FIXME: Path handling should work on all platforms. // REQUIRES: system-linux +// UNSUPPORTED: target={{.*}}-zos{{.*}} #include "ctu-hdr.h" diff --git a/clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm b/clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm index 9956348f87ff4e..ad5a3e14a81dbe 100644 --- a/clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm +++ b/clang/test/CodeGenCXX/pr59765-modules-global-ctor-dtor.cppm @@ -1,9 +1,10 @@ // https://github.com/llvm/llvm-project/issues/59765 // FIXME: Since the signature of the constructors/destructors is // different in different targets. The current CHECK can't work -// well when targeting or running on AIX and z/OS. +// well when targeting AIX and z/OS. // It would be better to add the corresponding test for other test. -// UNSUPPORTED: system-zos, system-aix +// UNSUPPORTED: system-aix +// UNSUPPORTED: target={{.*}}-zos{{.*}} // // RUN: rm -rf %t // RUN: mkdir %t diff --git a/clang/test/Driver/hipstdpar.c b/clang/test/Driver/hipstdpar.c index 2f48bf6b5cf1eb..32e040ef70d754 100644 --- a/clang/test/Driver/hipstdpar.c +++ b/clang/test/Driver/hipstdpar.c @@ -1,6 +1,7 @@ // REQUIRES: x86-registered-target // REQUIRES: amdgpu-registered-target // REQUIRES: system-linux +// UNSUPPORTED: target={{.*}}-zos{{.*}} // XFAIL: target={{.*}}hexagon{{.*}} // XFAIL: target={{.*}}-scei{{.*}} // XFAIL: target={{.*}}-sie{{.*}} diff --git a/clang/test/Driver/lld-repro.c b/clang/test/Driver/lld-repro.c index 61904c0e6df306..0e6340865b7382 100644 --- a/clang/test/Driver/lld-repro.c +++ b/clang/test/Driver/lld-repro.c @@ -1,5 +1,5 @@ // REQUIRES: lld -// UNSUPPORTED: target={{.*-(ps4|ps5)}} +// UNSUPPORTED: target={{.*-(ps4|ps5)}}, target={{.*}}-zos{{.*}} // RUN: echo "-nostartfiles -nostdlib -fuse-ld=lld -gen-reproducer=error -fcrash-diagnostics-dir=%t" \ // RUN: | sed -e 's/\\//g' > %t.rsp diff --git a/clang/test/OpenMP/lit.local.cfg b/clang/test/OpenMP/lit.local.cfg index 58ee923cb7ec5b..93adc6734d1a24 100644 --- a/clang/test/OpenMP/lit.local.cfg +++ b/clang/test/OpenMP/lit.local.cfg @@ -1,5 +1,9 @@ # -*- Python -*- vim: set ft=python ts=4 sw=4 expandtab tw=79: +import re from lit.llvm.subst import ToolSubst fc = ToolSubst("FileCheck", unresolved="fatal") config.substitutions.insert(0, (fc.regex, "FileCheck --allow-unused-prefixes")) + +if re.match(r".*-zos", config.target_triple): +config.unsupported = True ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] __ptr32 support for z/OS in Clang (PR #96063)
@@ -7097,10 +7098,14 @@ static bool handleMSPointerTypeQualifierAttr(TypeProcessingState &State, else if (Attrs[attr::UPtr]) ASIdx = LangAS::ptr32_uptr; } else if (PtrWidth == 64 && Attrs[attr::Ptr32]) { -if (Attrs[attr::UPtr]) +if (Triple.isOSzOS()) { perry-ca wrote: ```suggestion if (Attrs[attr::UPtr] || Triple.isOSzOS()) ASIdx = LangAS::ptr32_uptr; else ASIdx = LangAS::ptr32_sptr; ``` This is simpler. https://github.com/llvm/llvm-project/pull/96063 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] __ptr32 support for z/OS in Clang (PR #96063)
@@ -0,0 +1,84 @@ +// RUN: %clang_cc1 -triple s390x-ibm-zos -fzos-extensions -emit-llvm -O2 < %s | FileCheck %s --check-prefix=X64 perry-ca wrote: Does this test need to be some complicated? https://github.com/llvm/llvm-project/pull/96063 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH 1/2] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Dr
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH 1/3] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Dr
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: I removed the additional use of CLANG_SYSTEMZ_DEFAULT_ARCH and left that for a separate discussion. The only code clean up left here is the elimination of the `CPU` member that wasn't used. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH 1/4] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Dr
[clang] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/89854 The default arch level on z/OS is arch10. Update the code so z/OS has arch10 without changing the default for zLinux. >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f07..f06fbec1d02f91 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562bf..004c5c95c00cff 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8ad..45fb7e447b6429 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb8114..7baeffc00053a7 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c20..438dab8765bc34 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChai
[clang] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: > We are trying to remove such cmake variables in favor of configuration file. I'm not sure which configuration file(s) you are referring to. I assume you mean the cache files in clang/cmake/caches. If so, I don't think we want to put it there because `CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH` is a value defined for all the builds. It's not a value controlling how the build is done and we aren't trying to override the value of `CLANG_SYSTEMZ_DEFAULT_ARCH` for a particular build configuration. I might need to explain some more. If the user compiles with `-target=s390x-unknown-linux` then the default arch is arch8/z10. If the user compiles with `-target=s390x-ibm-zos` then the default arch is arch10/zEC12. The arch value is determined at runtime when clang is run. I could see us using a cache file to override the value of `CLANG_SYSTEMZ_DEFAULT_ARCH` if both values weren't needed by the compiler at the same time. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Perry/headers add zos support (PR #89995)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/89995 Update the wrappers for the C std headers so that they always forward to the z/OS system headers. >From 3c947fb397b8d5fa3744aa9eb130eac4894bd300 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 24 Apr 2024 15:54:39 -0500 Subject: [PATCH 1/3] Add support for z/OS to C std,etc wrapper headers --- clang/lib/Headers/CMakeLists.txt | 19 +-- clang/lib/Headers/builtins.h | 3 +++ clang/lib/Headers/float.h | 5 + clang/lib/Headers/inttypes.h | 4 clang/lib/Headers/iso646.h| 4 clang/lib/Headers/limits.h| 5 + clang/lib/Headers/stdalign.h | 5 + clang/lib/Headers/stdarg.h| 14 +- clang/lib/Headers/stdbool.h | 5 + clang/lib/Headers/stddef.h| 12 clang/lib/Headers/stdint.h| 5 + clang/lib/Headers/stdnoreturn.h | 6 ++ clang/lib/Headers/varargs.h | 6 +- clang/lib/Headers/zos_wrappers/builtins.h | 18 ++ 14 files changed, 107 insertions(+), 4 deletions(-) create mode 100644 clang/lib/Headers/zos_wrappers/builtins.h diff --git a/clang/lib/Headers/CMakeLists.txt b/clang/lib/Headers/CMakeLists.txt index e6ae4e19e81db9..3416811e39de27 100644 --- a/clang/lib/Headers/CMakeLists.txt +++ b/clang/lib/Headers/CMakeLists.txt @@ -335,6 +335,10 @@ set(llvm_libc_wrapper_files llvm_libc_wrappers/time.h ) +set(zos_wrapper_files + zos_wrappers/builtins.h +) + include(GetClangResourceDir) get_clang_resource_dir(output_dir PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. SUBDIR include) set(out_files) @@ -370,7 +374,7 @@ endfunction(clang_generate_header) # Copy header files from the source directory to the build directory foreach( f ${files} ${cuda_wrapper_files} ${cuda_wrapper_bits_files} - ${ppc_wrapper_files} ${openmp_wrapper_files} ${hlsl_files} + ${ppc_wrapper_files} ${openmp_wrapper_files} ${zos_wrapper_files} ${hlsl_files} ${llvm_libc_wrapper_files}) copy_header_to_output_dir(${CMAKE_CURRENT_SOURCE_DIR} ${f}) endforeach( f ) @@ -487,7 +491,7 @@ add_header_target("mips-resource-headers" "${mips_msa_files}") add_header_target("ppc-resource-headers" "${ppc_files};${ppc_wrapper_files}") add_header_target("ppc-htm-resource-headers" "${ppc_htm_files}") add_header_target("riscv-resource-headers" "${riscv_files};${riscv_generated_files}") -add_header_target("systemz-resource-headers" "${systemz_files}") +add_header_target("systemz-resource-headers" "${systemz_files};${zos_wrapper_files}") add_header_target("ve-resource-headers" "${ve_files}") add_header_target("webassembly-resource-headers" "${webassembly_files}") add_header_target("x86-resource-headers" "${x86_files}") @@ -538,6 +542,11 @@ install( DESTINATION ${header_install_dir}/openmp_wrappers COMPONENT clang-resource-headers) +install( + FILES ${zos_wrapper_files} + DESTINATION ${header_install_dir}/zos_wrappers + COMPONENT clang-resource-headers) + # # Install rules for separate header lists install( @@ -642,6 +651,12 @@ install( EXCLUDE_FROM_ALL COMPONENT systemz-resource-headers) +install( + FILES ${zos_wrapper_files} + DESTINATION ${header_install_dir}/zos_wrappers + EXCLUDE_FROM_ALL + COMPONENT systemz-resource-headers) + install( FILES ${ve_files} DESTINATION ${header_install_dir} diff --git a/clang/lib/Headers/builtins.h b/clang/lib/Headers/builtins.h index 65095861ca9b1c..1e534e632c8ead 100644 --- a/clang/lib/Headers/builtins.h +++ b/clang/lib/Headers/builtins.h @@ -13,4 +13,7 @@ #ifndef __BUILTINS_H #define __BUILTINS_H +#if defined(__MVS__) && __has_include_next() +#include_next +#endif /* __MVS__ */ #endif /* __BUILTINS_H */ diff --git a/clang/lib/Headers/float.h b/clang/lib/Headers/float.h index 0e73bca0a2d6e4..642c8f06cc9386 100644 --- a/clang/lib/Headers/float.h +++ b/clang/lib/Headers/float.h @@ -10,6 +10,10 @@ #ifndef __CLANG_FLOAT_H #define __CLANG_FLOAT_H +#if defined(__MVS__) && __has_include_next() +#include_next +#else + /* If we're on MinGW, fall back to the system's float.h, which might have * additional definitions provided for Windows. * For more details see http://msdn.microsoft.com/en-us/library/y0ybw9fy.aspx @@ -165,4 +169,5 @@ # define FLT16_TRUE_MIN__FLT16_TRUE_MIN__ #endif /* __STDC_WANT_IEC_60559_TYPES_EXT__ */ +#endif /* __MVS__ */ #endif /* __CLANG_FLOAT_H */ diff --git a/clang/lib/Headers/inttypes.h b/clang/lib/Headers/inttypes.h index 1c894c4aca4975..5150d22f8b2e4e 100644 --- a/clang/lib/Headers/inttypes.h +++ b/clang/lib/Headers/inttypes.h @@ -13,6 +13,9 @@ #if !defined(_AIX) || !defined(_STD_TYPES_T) #define __CLANG_INTTYPES_H #endif +#if defined(__MVS__) && __has_include_next() +#include_nex
[clang] [llvm] [z/OS] treat text files as text files so auto-conversion is done (PR #90128)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/90128 To support auto-conversion on z/OS text files need to be opened as text files. These changes will fix a number of LIT failures due to text files not being converted to the internal code page. - update a number of tools so they open the text files as text files - add support in the cat.py to open a text file as a text file (Windows will continue to treat all files as binary so new lines are handled correctly) - add env var definitions to enable auto-conversion in the lit config file. >From 3c434710f062c011ade4030b0d79254ee5c6a1df Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Thu, 25 Apr 2024 15:58:05 -0500 Subject: [PATCH] treat text files as text files so autoconversion is done --- clang/tools/clang-format/ClangFormat.cpp| 7 --- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp | 3 ++- llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp | 9 ++--- llvm/tools/yaml2obj/yaml2obj.cpp| 2 +- llvm/utils/lit/lit/builtin_commands/cat.py | 18 -- llvm/utils/lit/lit/llvm/config.py | 7 +++ 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index feb733fe3c9e0b..01f7c6047726e2 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -413,8 +413,9 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) { // On Windows, overwriting a file with an open file mapping doesn't work, // so read the whole file into memory when formatting in-place. ErrorOr> CodeOrErr = - !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) -: MemoryBuffer::getFileOrSTDIN(FileName); + !OutputXML && Inplace + ? MemoryBuffer::getFileAsStream(FileName) + : MemoryBuffer::getFileOrSTDIN(FileName, /*IsText=*/true); if (std::error_code EC = CodeOrErr.getError()) { errs() << EC.message() << "\n"; return true; @@ -558,7 +559,7 @@ static int dumpConfig() { // Read in the code in case the filename alone isn't enough to detect the // language. ErrorOr> CodeOrErr = -MemoryBuffer::getFileOrSTDIN(FileNames[0]); +MemoryBuffer::getFileOrSTDIN(FileNames[0], /*IsText=*/true); if (std::error_code EC = CodeOrErr.getError()) { llvm::errs() << EC.message() << "\n"; return 1; diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp index c3015d895230ea..40ee59c014b09f 100644 --- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -95,7 +95,8 @@ static std::vector getSearchPaths(opt::InputArgList *Args, // Opens a file. Path has to be resolved already. (used for def file) std::unique_ptr openFile(const Twine &Path) { - ErrorOr> MB = MemoryBuffer::getFile(Path); + ErrorOr> MB = + MemoryBuffer::getFile(Path, /*IsText=*/true); if (std::error_code EC = MB.getError()) { llvm::errs() << "cannot open file " << Path << ": " << EC.message() << "\n"; diff --git a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp index 6a5646965df2cf..c5ccd64f116539 100644 --- a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp +++ b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp @@ -144,15 +144,18 @@ int main(int argc, const char *argv[]) { cl::HideUnrelatedOptions({&CXXMapCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "LLVM C++ mangled name remapper\n"); - auto OldSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(OldSymbolFile); + auto OldSymbolBufOrError = + MemoryBuffer::getFileOrSTDIN(OldSymbolFile, /*IsText=*/true); if (!OldSymbolBufOrError) exitWithErrorCode(OldSymbolBufOrError.getError(), OldSymbolFile); - auto NewSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(NewSymbolFile); + auto NewSymbolBufOrError = + MemoryBuffer::getFileOrSTDIN(NewSymbolFile, /*IsText=*/true); if (!NewSymbolBufOrError) exitWithErrorCode(NewSymbolBufOrError.getError(), NewSymbolFile); - auto RemappingBufOrError = MemoryBuffer::getFileOrSTDIN(RemappingFile); + auto RemappingBufOrError = + MemoryBuffer::getFileOrSTDIN(RemappingFile, /*IsText=*/true); if (!RemappingBufOrError) exitWithErrorCode(RemappingBufOrError.getError(), RemappingFile); diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index b7f5356e22a9e6..4a060e1aad427f 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -130,7 +130,7 @@ int main(int argc, char **argv) { } ErrorOr> Buf = - MemoryBuffer::getFileOrSTDIN(Input); + MemoryBuffer::getFileOrSTDIN(Input, /*IsText=*/true); if (!Buf) return 1; diff --git a/llvm/utils/lit/lit/builtin_commands/cat.py b/llvm/utils/lit/lit/builtin_commands/cat.py index 37f55c
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] add support for z/OS system headers to clang std header wrappers (PR #89995)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/89995 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [z/OS] treat text files as text files so auto-conversion is done (PR #90128)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/90128 >From 2d7034366547b176f89b076eb60bcb44424fae11 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Thu, 25 Apr 2024 15:58:05 -0500 Subject: [PATCH] treat text files as text files so autoconversion is done --- clang/tools/clang-format/ClangFormat.cpp| 7 --- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp | 3 ++- llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp | 9 ++--- llvm/tools/yaml2obj/yaml2obj.cpp| 2 +- llvm/utils/lit/lit/builtin_commands/cat.py | 18 -- llvm/utils/lit/lit/llvm/config.py | 7 +++ 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index feb733fe3c9e0b..01f7c6047726e2 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -413,8 +413,9 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) { // On Windows, overwriting a file with an open file mapping doesn't work, // so read the whole file into memory when formatting in-place. ErrorOr> CodeOrErr = - !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) -: MemoryBuffer::getFileOrSTDIN(FileName); + !OutputXML && Inplace + ? MemoryBuffer::getFileAsStream(FileName) + : MemoryBuffer::getFileOrSTDIN(FileName, /*IsText=*/true); if (std::error_code EC = CodeOrErr.getError()) { errs() << EC.message() << "\n"; return true; @@ -558,7 +559,7 @@ static int dumpConfig() { // Read in the code in case the filename alone isn't enough to detect the // language. ErrorOr> CodeOrErr = -MemoryBuffer::getFileOrSTDIN(FileNames[0]); +MemoryBuffer::getFileOrSTDIN(FileNames[0], /*IsText=*/true); if (std::error_code EC = CodeOrErr.getError()) { llvm::errs() << EC.message() << "\n"; return 1; diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp index c3015d895230ea..40ee59c014b09f 100644 --- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -95,7 +95,8 @@ static std::vector getSearchPaths(opt::InputArgList *Args, // Opens a file. Path has to be resolved already. (used for def file) std::unique_ptr openFile(const Twine &Path) { - ErrorOr> MB = MemoryBuffer::getFile(Path); + ErrorOr> MB = + MemoryBuffer::getFile(Path, /*IsText=*/true); if (std::error_code EC = MB.getError()) { llvm::errs() << "cannot open file " << Path << ": " << EC.message() << "\n"; diff --git a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp index 6a5646965df2cf..c5ccd64f116539 100644 --- a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp +++ b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp @@ -144,15 +144,18 @@ int main(int argc, const char *argv[]) { cl::HideUnrelatedOptions({&CXXMapCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "LLVM C++ mangled name remapper\n"); - auto OldSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(OldSymbolFile); + auto OldSymbolBufOrError = + MemoryBuffer::getFileOrSTDIN(OldSymbolFile, /*IsText=*/true); if (!OldSymbolBufOrError) exitWithErrorCode(OldSymbolBufOrError.getError(), OldSymbolFile); - auto NewSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(NewSymbolFile); + auto NewSymbolBufOrError = + MemoryBuffer::getFileOrSTDIN(NewSymbolFile, /*IsText=*/true); if (!NewSymbolBufOrError) exitWithErrorCode(NewSymbolBufOrError.getError(), NewSymbolFile); - auto RemappingBufOrError = MemoryBuffer::getFileOrSTDIN(RemappingFile); + auto RemappingBufOrError = + MemoryBuffer::getFileOrSTDIN(RemappingFile, /*IsText=*/true); if (!RemappingBufOrError) exitWithErrorCode(RemappingBufOrError.getError(), RemappingFile); diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index b7f5356e22a9e6..4a060e1aad427f 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -130,7 +130,7 @@ int main(int argc, char **argv) { } ErrorOr> Buf = - MemoryBuffer::getFileOrSTDIN(Input); + MemoryBuffer::getFileOrSTDIN(Input, /*IsText=*/true); if (!Buf) return 1; diff --git a/llvm/utils/lit/lit/builtin_commands/cat.py b/llvm/utils/lit/lit/builtin_commands/cat.py index 37f55c0aef210b..6fb2152ef9332d 100644 --- a/llvm/utils/lit/lit/builtin_commands/cat.py +++ b/llvm/utils/lit/lit/builtin_commands/cat.py @@ -55,10 +55,24 @@ def main(argv): msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) for filename in filenames: try: -fileToCat = open(filename, "rb") -contents = fileToCat.read() +contents = None +is_text = False +try: +if sys.platform != "win32": +
[clang] [llvm] [z/OS] treat text files as text files so auto-conversion is done (PR #90128)
perry-ca wrote: > LGTM, but check why the following test in checks failed: `FAIL: BOLT :: > RISCV/unnamed-sym-no-entry.c` Looks unrelated. I'm kicking off another build. https://github.com/llvm/llvm-project/pull/90128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [z/OS] treat text files as text files so auto-conversion is done (PR #90128)
perry-ca wrote: Failed at `FAIL: BOLT :: RISCV/fake-label-no-entry.c` this time. I'll give it a day or so and try again. https://github.com/llvm/llvm-project/pull/90128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [z/OS] treat text files as text files so auto-conversion is done (PR #90128)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/90128 >From bf3ed6819301d9fcc7e001b9e6676d5f4ce66c4d Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Thu, 25 Apr 2024 15:58:05 -0500 Subject: [PATCH] treat text files as text files so autoconversion is done --- clang/tools/clang-format/ClangFormat.cpp| 7 --- llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp | 3 ++- llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp | 9 ++--- llvm/tools/yaml2obj/yaml2obj.cpp| 2 +- llvm/utils/lit/lit/builtin_commands/cat.py | 18 -- llvm/utils/lit/lit/llvm/config.py | 7 +++ 6 files changed, 36 insertions(+), 10 deletions(-) diff --git a/clang/tools/clang-format/ClangFormat.cpp b/clang/tools/clang-format/ClangFormat.cpp index feb733fe3c9e0b..01f7c6047726e2 100644 --- a/clang/tools/clang-format/ClangFormat.cpp +++ b/clang/tools/clang-format/ClangFormat.cpp @@ -413,8 +413,9 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) { // On Windows, overwriting a file with an open file mapping doesn't work, // so read the whole file into memory when formatting in-place. ErrorOr> CodeOrErr = - !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) -: MemoryBuffer::getFileOrSTDIN(FileName); + !OutputXML && Inplace + ? MemoryBuffer::getFileAsStream(FileName) + : MemoryBuffer::getFileOrSTDIN(FileName, /*IsText=*/true); if (std::error_code EC = CodeOrErr.getError()) { errs() << EC.message() << "\n"; return true; @@ -558,7 +559,7 @@ static int dumpConfig() { // Read in the code in case the filename alone isn't enough to detect the // language. ErrorOr> CodeOrErr = -MemoryBuffer::getFileOrSTDIN(FileNames[0]); +MemoryBuffer::getFileOrSTDIN(FileNames[0], /*IsText=*/true); if (std::error_code EC = CodeOrErr.getError()) { llvm::errs() << EC.message() << "\n"; return 1; diff --git a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp index c3015d895230ea..40ee59c014b09f 100644 --- a/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp +++ b/llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp @@ -95,7 +95,8 @@ static std::vector getSearchPaths(opt::InputArgList *Args, // Opens a file. Path has to be resolved already. (used for def file) std::unique_ptr openFile(const Twine &Path) { - ErrorOr> MB = MemoryBuffer::getFile(Path); + ErrorOr> MB = + MemoryBuffer::getFile(Path, /*IsText=*/true); if (std::error_code EC = MB.getError()) { llvm::errs() << "cannot open file " << Path << ": " << EC.message() << "\n"; diff --git a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp index 6a5646965df2cf..c5ccd64f116539 100644 --- a/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp +++ b/llvm/tools/llvm-cxxmap/llvm-cxxmap.cpp @@ -144,15 +144,18 @@ int main(int argc, const char *argv[]) { cl::HideUnrelatedOptions({&CXXMapCategory, &getColorCategory()}); cl::ParseCommandLineOptions(argc, argv, "LLVM C++ mangled name remapper\n"); - auto OldSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(OldSymbolFile); + auto OldSymbolBufOrError = + MemoryBuffer::getFileOrSTDIN(OldSymbolFile, /*IsText=*/true); if (!OldSymbolBufOrError) exitWithErrorCode(OldSymbolBufOrError.getError(), OldSymbolFile); - auto NewSymbolBufOrError = MemoryBuffer::getFileOrSTDIN(NewSymbolFile); + auto NewSymbolBufOrError = + MemoryBuffer::getFileOrSTDIN(NewSymbolFile, /*IsText=*/true); if (!NewSymbolBufOrError) exitWithErrorCode(NewSymbolBufOrError.getError(), NewSymbolFile); - auto RemappingBufOrError = MemoryBuffer::getFileOrSTDIN(RemappingFile); + auto RemappingBufOrError = + MemoryBuffer::getFileOrSTDIN(RemappingFile, /*IsText=*/true); if (!RemappingBufOrError) exitWithErrorCode(RemappingBufOrError.getError(), RemappingFile); diff --git a/llvm/tools/yaml2obj/yaml2obj.cpp b/llvm/tools/yaml2obj/yaml2obj.cpp index b7f5356e22a9e6..4a060e1aad427f 100644 --- a/llvm/tools/yaml2obj/yaml2obj.cpp +++ b/llvm/tools/yaml2obj/yaml2obj.cpp @@ -130,7 +130,7 @@ int main(int argc, char **argv) { } ErrorOr> Buf = - MemoryBuffer::getFileOrSTDIN(Input); + MemoryBuffer::getFileOrSTDIN(Input, /*IsText=*/true); if (!Buf) return 1; diff --git a/llvm/utils/lit/lit/builtin_commands/cat.py b/llvm/utils/lit/lit/builtin_commands/cat.py index 37f55c0aef210b..6fb2152ef9332d 100644 --- a/llvm/utils/lit/lit/builtin_commands/cat.py +++ b/llvm/utils/lit/lit/builtin_commands/cat.py @@ -55,10 +55,24 @@ def main(argv): msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY) for filename in filenames: try: -fileToCat = open(filename, "rb") -contents = fileToCat.read() +contents = None +is_text = False +try: +if sys.platform != "win32": +
[clang] [llvm] [z/OS] treat text files as text files so auto-conversion is done (PR #90128)
@@ -413,8 +413,9 @@ static bool format(StringRef FileName, bool ErrorOnIncompleteFormat = false) { // On Windows, overwriting a file with an open file mapping doesn't work, // so read the whole file into memory when formatting in-place. ErrorOr> CodeOrErr = - !OutputXML && Inplace ? MemoryBuffer::getFileAsStream(FileName) -: MemoryBuffer::getFileOrSTDIN(FileName); + !OutputXML && Inplace + ? MemoryBuffer::getFileAsStream(FileName) + : MemoryBuffer::getFileOrSTDIN(FileName, /*IsText=*/true); perry-ca wrote: I don't believe this will be a problem for Windows. This is a common problem that we have fixed in a few places already. I don't have a Windows platform to confirm. Would you or someone else be able to verify? https://github.com/llvm/llvm-project/pull/90128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [z/OS] treat text files as text files so auto-conversion is done (PR #90128)
perry-ca wrote: > We don't normally commit in clang-format with a unit test I assume you mean "without a unit test". In this case the unit test is the existing test cases. Some fail on z/OS because the files are not read in as text. It's not really possible to detect this issue on other platforms. I can't think of a new unit test that wouldn't duplicate what we already have. https://github.com/llvm/llvm-project/pull/90128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: ping @MaskRay. Thanks https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [z/OS] treat text files as text files so auto-conversion is done (PR #90128)
perry-ca wrote: @owenca @mydeveloperday Thanks for testing on Windows and taking the time to review the PR. https://github.com/llvm/llvm-project/pull/90128 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: @MaskRay Got it. The problem with that solution is that if you use --target you won't get the correct arch. This would be a problem for any cross compilation. For example, say you cross compile from zLinux (which wouldn't have the config file), the arch would be arch8. And if you cross compiled from z/OS (with the config file) to zLinux then the default arch would be arch10. Both of these would be incorrect. We also use the config files for installation specific information. It is common for users to have their own config files. If we require that the option be in the config file then we would be creating a very error prone situation. We need to be able to change the arch default based on the target triple. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Mark test cases as unsupported on z/OS (PR #90990)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/90990 These test cases are testing features not available when either targeting the s390x-ibm-zos target or use tools/features not available on the z/OS operating system. In a couple cases the lit test had a number of subtests with one or two that aren't supported on z/OS. Rather than mark the entire test as unsupported I split out the unsupported tests into a separate test case. >From 725745ad596972d64a256c6360ac21389ed684a0 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Thu, 2 May 2024 15:09:51 -0500 Subject: [PATCH 1/2] Mark test cases as unsupported on z/OS --- clang/test/CodeGen/ffp-contract-option.c| 1 + clang/test/CodeGen/ffp-model.c | 1 + clang/test/CodeGen/fp-matrix-pragma.c | 1 + clang/test/Modules/cstd.m | 1 + clang/test/Modules/merge-objc-protocol-visibility.m | 2 +- 5 files changed, 5 insertions(+), 1 deletion(-) diff --git a/clang/test/CodeGen/ffp-contract-option.c b/clang/test/CodeGen/ffp-contract-option.c index cd777ac9b43c68..2a6443032a4e64 100644 --- a/clang/test/CodeGen/ffp-contract-option.c +++ b/clang/test/CodeGen/ffp-contract-option.c @@ -1,4 +1,5 @@ // REQUIRES: x86-registered-target +// UNSUPPORTED: target={{.*}}-zos{{.*}} // RUN: %clang_cc1 -triple=x86_64 %s -emit-llvm -o - \ // RUN:| FileCheck --check-prefixes CHECK,CHECK-DEFAULT %s diff --git a/clang/test/CodeGen/ffp-model.c b/clang/test/CodeGen/ffp-model.c index 780603284a99f7..4ed9b9dc0a780c 100644 --- a/clang/test/CodeGen/ffp-model.c +++ b/clang/test/CodeGen/ffp-model.c @@ -1,4 +1,5 @@ // REQUIRES: x86-registered-target +// UNSUPPORTED: target={{.*}}-zos{{.*}} // RUN: %clang -S -emit-llvm -fenable-matrix -ffp-model=fast %s -o - \ // RUN: | FileCheck %s --check-prefixes=CHECK,CHECK-FAST diff --git a/clang/test/CodeGen/fp-matrix-pragma.c b/clang/test/CodeGen/fp-matrix-pragma.c index 45ad6e657daf17..5c9909bf60e0ff 100644 --- a/clang/test/CodeGen/fp-matrix-pragma.c +++ b/clang/test/CodeGen/fp-matrix-pragma.c @@ -1,4 +1,5 @@ // RUN: %clang -emit-llvm -S -fenable-matrix -mllvm -disable-llvm-optzns %s -o - | FileCheck %s +// UNSUPPORTED: target={{.*}}-zos{{.*}} typedef float fx2x2_t __attribute__((matrix_type(2, 2))); typedef int ix2x2_t __attribute__((matrix_type(2, 2))); diff --git a/clang/test/Modules/cstd.m b/clang/test/Modules/cstd.m index 6b81b9013e9da5..2155037400bd9d 100644 --- a/clang/test/Modules/cstd.m +++ b/clang/test/Modules/cstd.m @@ -1,5 +1,6 @@ // RUN: rm -rf %t // RUN: %clang_cc1 -fsyntax-only -internal-isystem %S/Inputs/System/usr/include -fmodules -fimplicit-module-maps -fbuiltin-headers-in-system-modules -fmodules-cache-path=%t -D__need_wint_t -Werror=implicit-function-declaration %s +// UNSUPPORTED: target={{.*}}-zos{{.*}} @import uses_other_constants; const double other_value = DBL_MAX; diff --git a/clang/test/Modules/merge-objc-protocol-visibility.m b/clang/test/Modules/merge-objc-protocol-visibility.m index f5f048b369022f..074c3b1ca66814 100644 --- a/clang/test/Modules/merge-objc-protocol-visibility.m +++ b/clang/test/Modules/merge-objc-protocol-visibility.m @@ -1,4 +1,4 @@ -// UNSUPPORTED: target={{.*}}-aix{{.*}} +// UNSUPPORTED: target={{.*}}-aix{{.*}}, target={{.*}}-zos{{.*}} // RUN: rm -rf %t // RUN: split-file %s %t // RUN: %clang_cc1 -emit-llvm -o %t/test.bc -F%t/Frameworks %t/test.m -Werror=objc-method-access -DHIDDEN_FIRST=1 \ >From 5b1a68aaf23d716e3ba8e315c19516c98ca89a14 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 3 May 2024 12:59:53 -0500 Subject: [PATCH 2/2] mark tests as unsupported on z/os --- clang/test/AST/Interp/cxx23.cpp | 1 + .../Driver/clang-offload-bundler-asserts-on.c| 2 +- .../Driver/clang-offload-bundler-standardize.c | 2 +- clang/test/Driver/clang-offload-bundler-zlib.c | 2 +- clang/test/Driver/clang-offload-bundler-zstd.c | 2 +- clang/test/Driver/clang-offload-bundler.c| 2 +- clang/test/Driver/std-trigraph-override.c| 7 +++ clang/test/Driver/std.c | 4 clang/test/FixIt/fixit-c++2a-tls.cpp | 16 clang/test/FixIt/fixit-c++2a.cpp | 4 clang/test/Interpreter/const.cpp | 2 +- clang/test/Lexer/unicode.c | 1 + clang/test/PCH/chain-openmp-threadprivate.cpp| 1 + clang/test/Sema/thread_local.c | 1 + llvm/test/MC/AsmParser/layout-interdependency.s | 1 + llvm/test/Object/archive-big-extract.test| 1 + llvm/test/Object/archive-extract.test| 1 + 17 files changed, 36 insertions(+), 14 deletions(-) create mode 100644 clang/test/Driver/std-trigraph-override.c create mode 100644 clang/test/FixIt/fixit-c++2a-tls.cpp diff --git a/clang/test/AST/Interp/cxx23.cpp b/clang/test/AST/Interp/cxx23.cpp index d1ec93e99803e5..2a5092c27afa1c 100644 --- a/clang/test/A
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: ping @MaskRay ^^^ https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/89854 >From 85da4a229ddeeb6c86ecfb0ba19ac921494a2b40 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 23 Apr 2024 20:16:15 -0500 Subject: [PATCH 1/2] Set the default arch for z/OS to be arch10 --- clang/CMakeLists.txt | 2 ++ clang/include/clang/Config/config.h.cmake| 3 +++ clang/lib/Basic/Targets/SystemZ.h| 7 +++ clang/lib/Driver/ToolChains/Arch/SystemZ.cpp | 5 - clang/lib/Driver/ToolChains/Arch/SystemZ.h | 3 ++- clang/lib/Driver/ToolChains/CommonArgs.cpp | 2 +- clang/lib/Driver/ToolChains/Gnu.cpp | 3 ++- clang/test/Preprocessor/predefined-arch-macros.c | 16 8 files changed, 33 insertions(+), 8 deletions(-) diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f092766fa19f0..f06fbec1d02f9 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -270,6 +270,8 @@ set(CLANG_DEFAULT_OPENMP_RUNTIME "libomp" CACHE STRING set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch") +set(CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "zEC12" CACHE STRING "SystemZ z/OS Default Arch") + set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING "Vendor-specific text for showing with version information.") diff --git a/clang/include/clang/Config/config.h.cmake b/clang/include/clang/Config/config.h.cmake index 27ed69e21562b..004c5c95c00cf 100644 --- a/clang/include/clang/Config/config.h.cmake +++ b/clang/include/clang/Config/config.h.cmake @@ -32,6 +32,9 @@ /* Default architecture for SystemZ. */ #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}" +/* Default architecture for SystemZ for z/OS. */ +#define CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH "${CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH}" + /* Multilib basename for libdir. */ #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}" diff --git a/clang/lib/Basic/Targets/SystemZ.h b/clang/lib/Basic/Targets/SystemZ.h index 8e302acd51b8a..45fb7e447b642 100644 --- a/clang/lib/Basic/Targets/SystemZ.h +++ b/clang/lib/Basic/Targets/SystemZ.h @@ -24,7 +24,6 @@ namespace targets { class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { static const char *const GCCRegNames[]; - std::string CPU; int ISARevision; bool HasTransactionalExecution; bool HasVector; @@ -33,7 +32,8 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { public: SystemZTargetInfo(const llvm::Triple &Triple, const TargetOptions &) - : TargetInfo(Triple), CPU("z10"), ISARevision(8), + : TargetInfo(Triple), +ISARevision(getISARevision(Triple.isOSzOS() ? "zEC12" : "z10")), HasTransactionalExecution(false), HasVector(false), SoftFloat(false), UnalignedSymbols(false) { IntMaxType = SignedLong; @@ -140,8 +140,7 @@ class LLVM_LIBRARY_VISIBILITY SystemZTargetInfo : public TargetInfo { } bool setCPU(const std::string &Name) override { -CPU = Name; -ISARevision = getISARevision(CPU); +ISARevision = getISARevision(Name); return ISARevision != -1; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp index 2213f431eb811..7baeffc00053a 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.cpp @@ -34,7 +34,8 @@ systemz::FloatABI systemz::getSystemZFloatABI(const Driver &D, return ABI; } -std::string systemz::getSystemZTargetCPU(const ArgList &Args) { +std::string systemz::getSystemZTargetCPU(const Driver &, const ArgList &Args, + const llvm::Triple &T) { if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) { llvm::StringRef CPUName = A->getValue(); @@ -48,6 +49,8 @@ std::string systemz::getSystemZTargetCPU(const ArgList &Args) { return std::string(CPUName); } + if (T.isOSzOS()) +return CLANG_SYSTEMZ_ZOS_DEFAULT_ARCH; return CLANG_SYSTEMZ_DEFAULT_ARCH; } diff --git a/clang/lib/Driver/ToolChains/Arch/SystemZ.h b/clang/lib/Driver/ToolChains/Arch/SystemZ.h index 1e42b68a8f3c2..438dab8765bc3 100644 --- a/clang/lib/Driver/ToolChains/Arch/SystemZ.h +++ b/clang/lib/Driver/ToolChains/Arch/SystemZ.h @@ -27,7 +27,8 @@ enum class FloatABI { FloatABI getSystemZFloatABI(const Driver &D, const llvm::opt::ArgList &Args); -std::string getSystemZTargetCPU(const llvm::opt::ArgList &Args); +std::string getSystemZTargetCPU(const Driver &D, const llvm::opt::ArgList &Args, +const llvm::Triple &T); void getSystemZTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args, std::vector &Features); diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index b65b96db16bd7..73f5abfaafcba 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Dr
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: I removed the ability to make z/OS default arch configurable at build time. We don't really need it and this makes the code simpler. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
perry-ca wrote: @MaskRay no worries. This brittle test issue was a reason I trying to keep the default for zLinux unchanged by this. I have posted a new commit that eliminates the cmake variable for z/OS. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
@@ -11,6 +11,8 @@ // //===--===// +#include "clang/Config/config.h" perry-ca wrote: This is needed for the change in SystemZ.h to replace the hard coded `"z10"` string with the CLANG_SYSTEMZ_DEFAULT_ARCH cmake variable. This applies to the other comment too. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Set the default arch for z/OS to be arch10 (PR #89854)
@@ -11,6 +11,8 @@ // //===--===// +#include "clang/Config/config.h" perry-ca wrote: That was my preference too except clang/Config/config.h has a clause that it can only be included once and will generate an error if it is included a second time. https://github.com/llvm/llvm-project/pull/89854 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
perry-ca wrote: @mgorny could you review this too. Thanks. https://github.com/llvm/llvm-project/pull/107613 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang: Remove requires system-linux from some driver tests (PR #111976)
https://github.com/perry-ca approved this pull request. LGTM. Thanks Matt. https://github.com/llvm/llvm-project/pull/111976 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (PR #111723)
@@ -324,6 +330,17 @@ ErrorOr RealFileSystem::status(const Twine &Path) { ErrorOr> RealFileSystem::openFileForRead(const Twine &Name) { + SmallString<256> RealName, Storage; perry-ca wrote: Can you put this code into a static function or even a private member function so you can avoid the duplication of code. https://github.com/llvm/llvm-project/pull/111723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (PR #111723)
@@ -117,8 +117,12 @@ FileSystem::~FileSystem() = default; ErrorOr> FileSystem::getBufferForFile(const llvm::Twine &Name, int64_t FileSize, - bool RequiresNullTerminator, bool IsVolatile) { - auto F = openFileForRead(Name); + bool RequiresNullTerminator, bool IsVolatile, + bool IsText) { + auto openFileFunctionPointer = &FileSystem::openFileForRead; + if (!IsText) +openFileFunctionPointer = &FileSystem::openFileForReadBinary; perry-ca wrote: ```suggestion auto F = IsText ?openFileForRead(Name) : openFileForReadBinary(Name); ``` https://github.com/llvm/llvm-project/pull/111723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (PR #111723)
@@ -302,6 +305,17 @@ class RealFileSystem : public FileSystem { return Storage; } + ErrorOr> openFileForRead(const Twine &Name, perry-ca wrote: np. I was misreading the diff. I didn't see it was a private member function. It looked like a file scope function. I was thinking file scope static, not static member. https://github.com/llvm/llvm-project/pull/111723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Add new openFileForReadBinary function, and pass IsText parameter to getBufferForFile (PR #111723)
@@ -302,6 +305,17 @@ class RealFileSystem : public FileSystem { return Storage; } + ErrorOr> openFileForRead(const Twine &Name, perry-ca wrote: Thanks, Could you mark this as static. https://github.com/llvm/llvm-project/pull/111723 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] clang: Fix hipstdpar test relying on default target (PR #111975)
https://github.com/perry-ca approved this pull request. This works on z/OS. Thanks for fixing it. https://github.com/llvm/llvm-project/pull/111975 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add z/OS customization file (PR #111182)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/82 On z/OS, the location of the system libraries and side decks (aka equivalent to libc, etc) are not in a predefined location. The system does have a default location but sysadmins can change this and frequently do. See the -mzos-hlq* options we have for z/OS. To avoid every user needing to specify these -mzos-hlq* options, we added support for a system install default config file that is always read independent of the usual config file. The compiler will read this customization config file before reading the usual config files. The customization file is called clang.cfg and is located in: - the etc dir within the compiler installation dir. - or specified by the CLANG_CONFIG_PATH env var. This env var can either be a directory or the fill path name of the file. >From 360bab981d8ec36e17aa4fbadbb4feef42c5d135 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 4 Oct 2024 10:09:32 -0500 Subject: [PATCH] Add z/OS customization file --- clang/include/clang/Driver/Driver.h | 5 +++ clang/lib/Driver/Driver.cpp | 33 +++ clang/test/Driver/Inputs/config-zos/clang.cfg | 1 + clang/test/Driver/Inputs/config-zos/def.cfg | 1 + .../test/Driver/Inputs/config-zos/tst/def.cfg | 1 + clang/test/Driver/config-zos.c| 17 ++ clang/test/Driver/config-zos1.c | 23 + 7 files changed, 81 insertions(+) create mode 100644 clang/test/Driver/Inputs/config-zos/clang.cfg create mode 100644 clang/test/Driver/Inputs/config-zos/def.cfg create mode 100644 clang/test/Driver/Inputs/config-zos/tst/def.cfg create mode 100644 clang/test/Driver/config-zos.c create mode 100644 clang/test/Driver/config-zos1.c diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 9177d56718ee77..5466659044ba22 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -738,6 +738,11 @@ class Driver { /// \returns true if error occurred. bool loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx); + /// Tries to load options from customization file. + /// + /// \returns true if error occurred. + bool loadZOSCustomizationFile(llvm::cl::ExpansionContext &); + /// Read options from the specified file. /// /// \param [in] FileName File to read. diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e9bf60d5e2ee46..dcf01cc2c29ee8 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,34 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // } +bool Driver::loadZOSCustomizationFile(llvm::cl::ExpansionContext &ExpCtx) { + if (IsCLMode() || IsDXCMode() || IsFlangMode()) +return false; + + SmallString<128> CustomizationFile; + StringRef PathLIBEnv = StringRef(getenv("CLANG_CONFIG_PATH")).trim(); + // If the env var is a directory then append "/clang.cfg" and treat + // that as the config file. Otherwise treat the env var as the + // config file. + if (!PathLIBEnv.empty()) { +llvm::sys::path::append(CustomizationFile, PathLIBEnv); +if (llvm::sys::fs::is_directory(PathLIBEnv)) + llvm::sys::path::append(CustomizationFile, "/clang.cfg"); +if (llvm::sys::fs::is_regular_file(CustomizationFile)) + return readConfigFile(CustomizationFile, ExpCtx); +Diag(diag::err_drv_config_file_not_found) << CustomizationFile; +return true; + } + + SmallString<128> BaseDir(llvm::sys::path::parent_path(Dir)); + llvm::sys::path::append(CustomizationFile, BaseDir + "/etc/clang.cfg"); + if (llvm::sys::fs::is_regular_file(CustomizationFile)) +return readConfigFile(CustomizationFile, ExpCtx); + + // If no customization file, just return + return false; +} + static void appendOneArg(InputArgList &Args, const Arg *Opt, const Arg *BaseArg) { // The args for config files or /clang: flags belong to different InputArgList @@ -1179,6 +1207,11 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { assert(!Triple.empty()); } + // On z/OS, start by loading the customization file before loading + // the usual default config file(s). + if (llvm::Triple(Triple).isOSzOS() && loadZOSCustomizationFile(ExpCtx)) +return true; + // Search for config files in the following order: // 1. -.cfg using real driver mode //(e.g. i386-pc-linux-gnu-clang++.cfg). diff --git a/clang/test/Driver/Inputs/config-zos/clang.cfg b/clang/test/Driver/Inputs/config-zos/clang.cfg new file mode 100644 index 00..43a5dbfaa61826 --- /dev/null +++ b/clang/test/Driver/Inputs/config-zos/clang.cfg @@ -0,0 +1 @@ +-DABC=123 diff --git a/clang/test/Driver/Inputs/config-zos/def.cfg b/clang/test/Driver/Inputs/config-zos/def.cfg new file mode 100644 index 00..156f9c85fb4f2e --- /dev/null +++ b/clang/test/Driver/Inputs/co
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add z/OS customization file (PR #111182)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/82 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Use the XL pragma pack semantics on z/OS (PR #111053)
https://github.com/perry-ca closed https://github.com/llvm/llvm-project/pull/111053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Use the XL pragma pack semantics on z/OS (PR #111053)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/111053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add z/OS customization file (PR #111182)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/82 >From 360bab981d8ec36e17aa4fbadbb4feef42c5d135 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 4 Oct 2024 10:09:32 -0500 Subject: [PATCH 1/2] Add z/OS customization file --- clang/include/clang/Driver/Driver.h | 5 +++ clang/lib/Driver/Driver.cpp | 33 +++ clang/test/Driver/Inputs/config-zos/clang.cfg | 1 + clang/test/Driver/Inputs/config-zos/def.cfg | 1 + .../test/Driver/Inputs/config-zos/tst/def.cfg | 1 + clang/test/Driver/config-zos.c| 17 ++ clang/test/Driver/config-zos1.c | 23 + 7 files changed, 81 insertions(+) create mode 100644 clang/test/Driver/Inputs/config-zos/clang.cfg create mode 100644 clang/test/Driver/Inputs/config-zos/def.cfg create mode 100644 clang/test/Driver/Inputs/config-zos/tst/def.cfg create mode 100644 clang/test/Driver/config-zos.c create mode 100644 clang/test/Driver/config-zos1.c diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 9177d56718ee77..5466659044ba22 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -738,6 +738,11 @@ class Driver { /// \returns true if error occurred. bool loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx); + /// Tries to load options from customization file. + /// + /// \returns true if error occurred. + bool loadZOSCustomizationFile(llvm::cl::ExpansionContext &); + /// Read options from the specified file. /// /// \param [in] FileName File to read. diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e9bf60d5e2ee46..dcf01cc2c29ee8 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,34 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // } +bool Driver::loadZOSCustomizationFile(llvm::cl::ExpansionContext &ExpCtx) { + if (IsCLMode() || IsDXCMode() || IsFlangMode()) +return false; + + SmallString<128> CustomizationFile; + StringRef PathLIBEnv = StringRef(getenv("CLANG_CONFIG_PATH")).trim(); + // If the env var is a directory then append "/clang.cfg" and treat + // that as the config file. Otherwise treat the env var as the + // config file. + if (!PathLIBEnv.empty()) { +llvm::sys::path::append(CustomizationFile, PathLIBEnv); +if (llvm::sys::fs::is_directory(PathLIBEnv)) + llvm::sys::path::append(CustomizationFile, "/clang.cfg"); +if (llvm::sys::fs::is_regular_file(CustomizationFile)) + return readConfigFile(CustomizationFile, ExpCtx); +Diag(diag::err_drv_config_file_not_found) << CustomizationFile; +return true; + } + + SmallString<128> BaseDir(llvm::sys::path::parent_path(Dir)); + llvm::sys::path::append(CustomizationFile, BaseDir + "/etc/clang.cfg"); + if (llvm::sys::fs::is_regular_file(CustomizationFile)) +return readConfigFile(CustomizationFile, ExpCtx); + + // If no customization file, just return + return false; +} + static void appendOneArg(InputArgList &Args, const Arg *Opt, const Arg *BaseArg) { // The args for config files or /clang: flags belong to different InputArgList @@ -1179,6 +1207,11 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { assert(!Triple.empty()); } + // On z/OS, start by loading the customization file before loading + // the usual default config file(s). + if (llvm::Triple(Triple).isOSzOS() && loadZOSCustomizationFile(ExpCtx)) +return true; + // Search for config files in the following order: // 1. -.cfg using real driver mode //(e.g. i386-pc-linux-gnu-clang++.cfg). diff --git a/clang/test/Driver/Inputs/config-zos/clang.cfg b/clang/test/Driver/Inputs/config-zos/clang.cfg new file mode 100644 index 00..43a5dbfaa61826 --- /dev/null +++ b/clang/test/Driver/Inputs/config-zos/clang.cfg @@ -0,0 +1 @@ +-DABC=123 diff --git a/clang/test/Driver/Inputs/config-zos/def.cfg b/clang/test/Driver/Inputs/config-zos/def.cfg new file mode 100644 index 00..156f9c85fb4f2e --- /dev/null +++ b/clang/test/Driver/Inputs/config-zos/def.cfg @@ -0,0 +1 @@ +-DDEF=456 diff --git a/clang/test/Driver/Inputs/config-zos/tst/def.cfg b/clang/test/Driver/Inputs/config-zos/tst/def.cfg new file mode 100644 index 00..156f9c85fb4f2e --- /dev/null +++ b/clang/test/Driver/Inputs/config-zos/tst/def.cfg @@ -0,0 +1 @@ +-DDEF=456 diff --git a/clang/test/Driver/config-zos.c b/clang/test/Driver/config-zos.c new file mode 100644 index 00..8de02ec101b914 --- /dev/null +++ b/clang/test/Driver/config-zos.c @@ -0,0 +1,17 @@ +// REQUIRES: shell +// REQUIRES: systemz-registered-target + +// RUN: unset CLANG_NO_DEFAULT_CONFIG +// RUN: rm -rf %t && mkdir %t + +// RUN: mkdir -p %t/testbin +// RUN: mkdir -p %t/etc +// RUN: ln -s %clang %t/testbin/clang +// RUN: echo "-DXYZ=789" >%t/etc/clang.cfg +
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/111035 >From e8d355c9cd165e0a255bbbfb5b0126cf7b1461a6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 2 Oct 2024 12:56:43 -0500 Subject: [PATCH 1/7] initial work for pragma export & _Export keyword --- clang/include/clang/AST/ASTConsumer.h | 3 + clang/include/clang/Basic/Attr.td | 6 + clang/include/clang/Basic/AttrDocs.td | 21 ++ .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Basic/TokenKinds.def | 5 + clang/include/clang/Parse/Parser.h| 13 ++ clang/include/clang/Sema/DeclSpec.h | 31 ++- clang/include/clang/Sema/Sema.h | 30 +++ clang/lib/CodeGen/BackendConsumer.h | 1 + clang/lib/CodeGen/CodeGenAction.cpp | 4 + clang/lib/CodeGen/CodeGenModule.cpp | 15 ++ clang/lib/CodeGen/CodeGenModule.h | 2 + clang/lib/CodeGen/ModuleBuilder.cpp | 6 +- clang/lib/Driver/ToolChains/ZOS.cpp | 12 +- clang/lib/Parse/ParseDecl.cpp | 18 ++ clang/lib/Parse/ParseDeclCXX.cpp | 6 + clang/lib/Parse/ParsePragma.cpp | 208 ++ clang/lib/Parse/Parser.cpp| 3 + clang/lib/Sema/DeclSpec.cpp | 6 + clang/lib/Sema/Sema.cpp | 21 ++ clang/lib/Sema/SemaAttr.cpp | 162 ++ clang/lib/Sema/SemaDecl.cpp | 13 ++ clang/test/CodeGen/attr-export-failing.cpp| 4 + clang/test/CodeGen/attr-export.cpp| 51 + clang/test/CodeGen/pragma-export.c| 39 clang/test/CodeGen/pragma-export.cpp | 82 +++ clang/test/CodeGen/zos-pragmas.c | 11 + clang/test/CodeGen/zos-pragmas.cpp| 11 + 28 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGen/attr-export-failing.cpp create mode 100644 clang/test/CodeGen/attr-export.cpp create mode 100644 clang/test/CodeGen/pragma-export.c create mode 100644 clang/test/CodeGen/pragma-export.cpp create mode 100644 clang/test/CodeGen/zos-pragmas.c create mode 100644 clang/test/CodeGen/zos-pragmas.cpp diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 447f2592d23595..b15d53e700c679 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -108,6 +108,9 @@ class ASTConsumer { /// completed. virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} + /// CompletePragmaExport - complete #pragma export statements. + virtual void CompletePragmaExport(Decl *D) {} + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fbcbf0ed416416..884c4147cf1285 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4520,6 +4520,12 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def zOSExport : InheritableAttr { + let Spellings = [CustomKeyword<"_Export">]; + let Subjects = SubjectList<[Function, Var, CXXRecord]>; + let Documentation = [zOSExportDocs]; +} + def UnsafeBufferUsage : InheritableAttr { let Spellings = [Clang<"unsafe_buffer_usage">]; let Subjects = SubjectList<[Function, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 53d88482698f00..bf56fa6ad7162f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -6863,6 +6863,27 @@ attribute requires a string literal argument to identify the handle being releas }]; } +def zOSExportDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the _Export keyword with a function name or external variable to declare +that it is to be exported (made available to other modules). You must define +the object name in the same translation unit in which you use the _Export +keyword. For example: + +.. code-block:: c + + int _Export anthony(float); + +This statement exports the function anthony, if you define the function in the +translation unit. The _Export keyword must immediately precede the object name. +If you apply the _Export keyword to a class, the compiler automatically exports +all static data members and member functions of the class. However, if you want +it to apply to individual class members, then you must apply it to each member +that can be referenced. + }]; +} + def UnsafeBufferUsageDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 64e6d0407b0ce3..09842ed02efd4b 100644 --- a/c
[clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)
perry-ca wrote: > > sorry this is same as #107906 (with a bigger impact radius, as you're also > > changing getBufferForFile) and doesn't address any of the issues mention > > about explaining the semantics of `IsText` or justification for changing > > the core VFS interfaces, for an operation that's can solely be performed on > > physical fileystem. > > @perry-ca raised some concerns in #109664 about this functionality > > requiring some context awareness, I don't think any of those is addressed > > by this patch either. Pretty much all of the callers apart from ASTReader > > is just using `IsText = true`. > > To give some context, the problem we are trying to solve initially is that > file opened by `#embed` should not be utf-8 converted. Correct. The overall/original problem is that we have many places where text files were being read as binary files. Adding the IsText parameter to the openFileForRead() function just like we have in the getFileOrStdin() group of functions solves that problem. It tells the compiler to read files that should be text as text and binary as binary. https://github.com/llvm/llvm-project/pull/110661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/111035 >From e8d355c9cd165e0a255bbbfb5b0126cf7b1461a6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 2 Oct 2024 12:56:43 -0500 Subject: [PATCH 1/5] initial work for pragma export & _Export keyword --- clang/include/clang/AST/ASTConsumer.h | 3 + clang/include/clang/Basic/Attr.td | 6 + clang/include/clang/Basic/AttrDocs.td | 21 ++ .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Basic/TokenKinds.def | 5 + clang/include/clang/Parse/Parser.h| 13 ++ clang/include/clang/Sema/DeclSpec.h | 31 ++- clang/include/clang/Sema/Sema.h | 30 +++ clang/lib/CodeGen/BackendConsumer.h | 1 + clang/lib/CodeGen/CodeGenAction.cpp | 4 + clang/lib/CodeGen/CodeGenModule.cpp | 15 ++ clang/lib/CodeGen/CodeGenModule.h | 2 + clang/lib/CodeGen/ModuleBuilder.cpp | 6 +- clang/lib/Driver/ToolChains/ZOS.cpp | 12 +- clang/lib/Parse/ParseDecl.cpp | 18 ++ clang/lib/Parse/ParseDeclCXX.cpp | 6 + clang/lib/Parse/ParsePragma.cpp | 208 ++ clang/lib/Parse/Parser.cpp| 3 + clang/lib/Sema/DeclSpec.cpp | 6 + clang/lib/Sema/Sema.cpp | 21 ++ clang/lib/Sema/SemaAttr.cpp | 162 ++ clang/lib/Sema/SemaDecl.cpp | 13 ++ clang/test/CodeGen/attr-export-failing.cpp| 4 + clang/test/CodeGen/attr-export.cpp| 51 + clang/test/CodeGen/pragma-export.c| 39 clang/test/CodeGen/pragma-export.cpp | 82 +++ clang/test/CodeGen/zos-pragmas.c | 11 + clang/test/CodeGen/zos-pragmas.cpp| 11 + 28 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGen/attr-export-failing.cpp create mode 100644 clang/test/CodeGen/attr-export.cpp create mode 100644 clang/test/CodeGen/pragma-export.c create mode 100644 clang/test/CodeGen/pragma-export.cpp create mode 100644 clang/test/CodeGen/zos-pragmas.c create mode 100644 clang/test/CodeGen/zos-pragmas.cpp diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 447f2592d23595..b15d53e700c679 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -108,6 +108,9 @@ class ASTConsumer { /// completed. virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} + /// CompletePragmaExport - complete #pragma export statements. + virtual void CompletePragmaExport(Decl *D) {} + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fbcbf0ed416416..884c4147cf1285 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4520,6 +4520,12 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def zOSExport : InheritableAttr { + let Spellings = [CustomKeyword<"_Export">]; + let Subjects = SubjectList<[Function, Var, CXXRecord]>; + let Documentation = [zOSExportDocs]; +} + def UnsafeBufferUsage : InheritableAttr { let Spellings = [Clang<"unsafe_buffer_usage">]; let Subjects = SubjectList<[Function, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 53d88482698f00..bf56fa6ad7162f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -6863,6 +6863,27 @@ attribute requires a string literal argument to identify the handle being releas }]; } +def zOSExportDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the _Export keyword with a function name or external variable to declare +that it is to be exported (made available to other modules). You must define +the object name in the same translation unit in which you use the _Export +keyword. For example: + +.. code-block:: c + + int _Export anthony(float); + +This statement exports the function anthony, if you define the function in the +translation unit. The _Export keyword must immediately precede the object name. +If you apply the _Export keyword to a class, the compiler automatically exports +all static data members and member functions of the class. However, if you want +it to apply to individual class members, then you must apply it to each member +that can be referenced. + }]; +} + def UnsafeBufferUsageDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 64e6d0407b0ce3..09842ed02efd4b 100644 --- a/c
[clang] Use the XL pragma pack semantics on z/OS (PR #111053)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/111053 - set the default on z/OS to use the XL pragma semantics - add in additional pragma pack values such as twobyte & reset supported by XL on z/OS >From 8f5b11f92dec5072d50a7930fa501c9039b6af26 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Thu, 3 Oct 2024 13:46:37 -0500 Subject: [PATCH] initial upstream --- clang/lib/Driver/ToolChains/ZOS.cpp | 4 clang/lib/Parse/ParsePragma.cpp | 26 + clang/test/Driver/zos-pragma-pack.c | 8 +++ clang/test/SemaCXX/pragma-pack-packed-2.cpp | 12 ++ 4 files changed, 50 insertions(+) create mode 100644 clang/test/Driver/zos-pragma-pack.c create mode 100644 clang/test/SemaCXX/pragma-pack-packed-2.cpp diff --git a/clang/lib/Driver/ToolChains/ZOS.cpp b/clang/lib/Driver/ToolChains/ZOS.cpp index 074e0556ecd2ad..c5ad3ef1b00f1d 100644 --- a/clang/lib/Driver/ToolChains/ZOS.cpp +++ b/clang/lib/Driver/ToolChains/ZOS.cpp @@ -37,6 +37,10 @@ void ZOS::addClangTargetOptions(const ArgList &DriverArgs, options::OPT_fno_aligned_allocation)) CC1Args.push_back("-faligned-alloc-unavailable"); + if (DriverArgs.hasFlag(options::OPT_fxl_pragma_pack, + options::OPT_fno_xl_pragma_pack, true)) +CC1Args.push_back("-fxl-pragma-pack"); + // Pass "-fno-sized-deallocation" only when the user hasn't manually enabled // or disabled sized deallocations. if (!DriverArgs.hasArgNoClaim(options::OPT_fsized_deallocation, diff --git a/clang/lib/Parse/ParsePragma.cpp b/clang/lib/Parse/ParsePragma.cpp index cc6f18b5b319f9..12fed448d477c0 100644 --- a/clang/lib/Parse/ParsePragma.cpp +++ b/clang/lib/Parse/ParsePragma.cpp @@ -2126,6 +2126,7 @@ void PragmaGCCVisibilityHandler::HandlePragma(Preprocessor &PP, // pack '(' [integer] ')' // pack '(' 'show' ')' // pack '(' ('push' | 'pop') [',' identifier] [, integer] ')' +// pack '(' 'packed' | 'full' | 'twobyte' | 'reset' ')' with -fzos-extensions void PragmaPackHandler::HandlePragma(Preprocessor &PP, PragmaIntroducer Introducer, Token &PackTok) { @@ -2155,10 +2156,35 @@ void PragmaPackHandler::HandlePragma(Preprocessor &PP, ? Sema::PSK_Push_Set : Sema::PSK_Set; } else if (Tok.is(tok::identifier)) { +// Map pragma pack options to pack (integer). +auto MapPack = [&](const char *Literal) { + Action = Sema::PSK_Push_Set; + Alignment = Tok; + Alignment.setKind(tok::numeric_constant); + Alignment.setLiteralData(Literal); + Alignment.setLength(1); +}; + const IdentifierInfo *II = Tok.getIdentifierInfo(); if (II->isStr("show")) { Action = Sema::PSK_Show; PP.Lex(Tok); +} else if (II->isStr("packed") && PP.getLangOpts().ZOSExt) { + // #pragma pack(packed) is the same as #pragma pack(1) + MapPack("1"); + PP.Lex(Tok); +} else if (II->isStr("full") && PP.getLangOpts().ZOSExt) { + // #pragma pack(full) is the same as #pragma pack(4) + MapPack("4"); + PP.Lex(Tok); +} else if (II->isStr("twobyte") && PP.getLangOpts().ZOSExt) { + // #pragma pack(twobyte) is the same as #pragma pack(2) + MapPack("2"); + PP.Lex(Tok); +} else if (II->isStr("reset") && PP.getLangOpts().ZOSExt) { + // #pragma pack(reset) is the same as #pragma pack(pop) on XL + Action = Sema::PSK_Pop; + PP.Lex(Tok); } else { if (II->isStr("push")) { Action = Sema::PSK_Push; diff --git a/clang/test/Driver/zos-pragma-pack.c b/clang/test/Driver/zos-pragma-pack.c new file mode 100644 index 00..0e04878daba4c5 --- /dev/null +++ b/clang/test/Driver/zos-pragma-pack.c @@ -0,0 +1,8 @@ +// REQUIRES: systemz-registered-target + +// RUN: %clang -### -target s390x-ibm-zos -c %s -o /dev/null 2>&1 | FileCheck %s +// CHECK: "-fxl-pragma-pack" + +// RUN: %clang -### -fno-xl-pragma-pack -target s390x-ibm-zos -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix=NOOPT +// NOOPT-NOT: "-fxl-pragma-pack" + diff --git a/clang/test/SemaCXX/pragma-pack-packed-2.cpp b/clang/test/SemaCXX/pragma-pack-packed-2.cpp new file mode 100644 index 00..3639addd6fe5fc --- /dev/null +++ b/clang/test/SemaCXX/pragma-pack-packed-2.cpp @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 -triple s390x-ibm-zos -fzos-extensions -fsyntax-only -verify %s +// RUN: %clang_cc1 -triple s390x-ibm-zos -fzos-extensions -fxl-pragma-pack -fsyntax-only -verify %s +// RUN: %clang -target s390x-ibm-zos -S -emit-llvm -Xclang -verify -fno-xl-pragma-pack %s + +#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 8}} +#pragma pack(twobyte) +#pragma pack(packed) +#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 1}} +#pragma pack(reset) +#pragma pack(show) // expected-warning {{value of #pragma pack(show) == 2}} +#pragm
[clang] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/111035 >From e8d355c9cd165e0a255bbbfb5b0126cf7b1461a6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 2 Oct 2024 12:56:43 -0500 Subject: [PATCH 1/6] initial work for pragma export & _Export keyword --- clang/include/clang/AST/ASTConsumer.h | 3 + clang/include/clang/Basic/Attr.td | 6 + clang/include/clang/Basic/AttrDocs.td | 21 ++ .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Basic/TokenKinds.def | 5 + clang/include/clang/Parse/Parser.h| 13 ++ clang/include/clang/Sema/DeclSpec.h | 31 ++- clang/include/clang/Sema/Sema.h | 30 +++ clang/lib/CodeGen/BackendConsumer.h | 1 + clang/lib/CodeGen/CodeGenAction.cpp | 4 + clang/lib/CodeGen/CodeGenModule.cpp | 15 ++ clang/lib/CodeGen/CodeGenModule.h | 2 + clang/lib/CodeGen/ModuleBuilder.cpp | 6 +- clang/lib/Driver/ToolChains/ZOS.cpp | 12 +- clang/lib/Parse/ParseDecl.cpp | 18 ++ clang/lib/Parse/ParseDeclCXX.cpp | 6 + clang/lib/Parse/ParsePragma.cpp | 208 ++ clang/lib/Parse/Parser.cpp| 3 + clang/lib/Sema/DeclSpec.cpp | 6 + clang/lib/Sema/Sema.cpp | 21 ++ clang/lib/Sema/SemaAttr.cpp | 162 ++ clang/lib/Sema/SemaDecl.cpp | 13 ++ clang/test/CodeGen/attr-export-failing.cpp| 4 + clang/test/CodeGen/attr-export.cpp| 51 + clang/test/CodeGen/pragma-export.c| 39 clang/test/CodeGen/pragma-export.cpp | 82 +++ clang/test/CodeGen/zos-pragmas.c | 11 + clang/test/CodeGen/zos-pragmas.cpp| 11 + 28 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGen/attr-export-failing.cpp create mode 100644 clang/test/CodeGen/attr-export.cpp create mode 100644 clang/test/CodeGen/pragma-export.c create mode 100644 clang/test/CodeGen/pragma-export.cpp create mode 100644 clang/test/CodeGen/zos-pragmas.c create mode 100644 clang/test/CodeGen/zos-pragmas.cpp diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 447f2592d23595..b15d53e700c679 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -108,6 +108,9 @@ class ASTConsumer { /// completed. virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} + /// CompletePragmaExport - complete #pragma export statements. + virtual void CompletePragmaExport(Decl *D) {} + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fbcbf0ed416416..884c4147cf1285 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4520,6 +4520,12 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def zOSExport : InheritableAttr { + let Spellings = [CustomKeyword<"_Export">]; + let Subjects = SubjectList<[Function, Var, CXXRecord]>; + let Documentation = [zOSExportDocs]; +} + def UnsafeBufferUsage : InheritableAttr { let Spellings = [Clang<"unsafe_buffer_usage">]; let Subjects = SubjectList<[Function, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 53d88482698f00..bf56fa6ad7162f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -6863,6 +6863,27 @@ attribute requires a string literal argument to identify the handle being releas }]; } +def zOSExportDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the _Export keyword with a function name or external variable to declare +that it is to be exported (made available to other modules). You must define +the object name in the same translation unit in which you use the _Export +keyword. For example: + +.. code-block:: c + + int _Export anthony(float); + +This statement exports the function anthony, if you define the function in the +translation unit. The _Export keyword must immediately precede the object name. +If you apply the _Export keyword to a class, the compiler automatically exports +all static data members and member functions of the class. However, if you want +it to apply to individual class members, then you must apply it to each member +that can be referenced. + }]; +} + def UnsafeBufferUsageDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 64e6d0407b0ce3..09842ed02efd4b 100644 --- a/c
[clang] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/111035 >From e8d355c9cd165e0a255bbbfb5b0126cf7b1461a6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 2 Oct 2024 12:56:43 -0500 Subject: [PATCH 1/7] initial work for pragma export & _Export keyword --- clang/include/clang/AST/ASTConsumer.h | 3 + clang/include/clang/Basic/Attr.td | 6 + clang/include/clang/Basic/AttrDocs.td | 21 ++ .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Basic/TokenKinds.def | 5 + clang/include/clang/Parse/Parser.h| 13 ++ clang/include/clang/Sema/DeclSpec.h | 31 ++- clang/include/clang/Sema/Sema.h | 30 +++ clang/lib/CodeGen/BackendConsumer.h | 1 + clang/lib/CodeGen/CodeGenAction.cpp | 4 + clang/lib/CodeGen/CodeGenModule.cpp | 15 ++ clang/lib/CodeGen/CodeGenModule.h | 2 + clang/lib/CodeGen/ModuleBuilder.cpp | 6 +- clang/lib/Driver/ToolChains/ZOS.cpp | 12 +- clang/lib/Parse/ParseDecl.cpp | 18 ++ clang/lib/Parse/ParseDeclCXX.cpp | 6 + clang/lib/Parse/ParsePragma.cpp | 208 ++ clang/lib/Parse/Parser.cpp| 3 + clang/lib/Sema/DeclSpec.cpp | 6 + clang/lib/Sema/Sema.cpp | 21 ++ clang/lib/Sema/SemaAttr.cpp | 162 ++ clang/lib/Sema/SemaDecl.cpp | 13 ++ clang/test/CodeGen/attr-export-failing.cpp| 4 + clang/test/CodeGen/attr-export.cpp| 51 + clang/test/CodeGen/pragma-export.c| 39 clang/test/CodeGen/pragma-export.cpp | 82 +++ clang/test/CodeGen/zos-pragmas.c | 11 + clang/test/CodeGen/zos-pragmas.cpp| 11 + 28 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGen/attr-export-failing.cpp create mode 100644 clang/test/CodeGen/attr-export.cpp create mode 100644 clang/test/CodeGen/pragma-export.c create mode 100644 clang/test/CodeGen/pragma-export.cpp create mode 100644 clang/test/CodeGen/zos-pragmas.c create mode 100644 clang/test/CodeGen/zos-pragmas.cpp diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 447f2592d23595..b15d53e700c679 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -108,6 +108,9 @@ class ASTConsumer { /// completed. virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} + /// CompletePragmaExport - complete #pragma export statements. + virtual void CompletePragmaExport(Decl *D) {} + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fbcbf0ed416416..884c4147cf1285 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4520,6 +4520,12 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def zOSExport : InheritableAttr { + let Spellings = [CustomKeyword<"_Export">]; + let Subjects = SubjectList<[Function, Var, CXXRecord]>; + let Documentation = [zOSExportDocs]; +} + def UnsafeBufferUsage : InheritableAttr { let Spellings = [Clang<"unsafe_buffer_usage">]; let Subjects = SubjectList<[Function, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 53d88482698f00..bf56fa6ad7162f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -6863,6 +6863,27 @@ attribute requires a string literal argument to identify the handle being releas }]; } +def zOSExportDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the _Export keyword with a function name or external variable to declare +that it is to be exported (made available to other modules). You must define +the object name in the same translation unit in which you use the _Export +keyword. For example: + +.. code-block:: c + + int _Export anthony(float); + +This statement exports the function anthony, if you define the function in the +translation unit. The _Export keyword must immediately precede the object name. +If you apply the _Export keyword to a class, the compiler automatically exports +all static data members and member functions of the class. However, if you want +it to apply to individual class members, then you must apply it to each member +that can be referenced. + }]; +} + def UnsafeBufferUsageDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 64e6d0407b0ce3..09842ed02efd4b 100644 --- a/c
[clang] Pass the executable name as arg[0] when calling ExecuteAndWait() (PR #114067)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/114067 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] need to pass executable name as arg[0] (PR #114067)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/114067 PR https://github.com/llvm/llvm-project/pull/111976 was enabling the tests updated in the PR to run on all systems. We found a few didn't run on z/OS. I tracked the problem down to: 1. the ExecuteToolChainProgram() function wasn't passing the executable name as the first arg. That was causing exec on z/OS to fail. 2. the temp file needs to be a text file so codepage conversion happens. >From a32c4396250b8dbbf18829988ddca4b76db1ae81 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Tue, 29 Oct 2024 09:42:14 -0500 Subject: [PATCH] need to pass executable name as arg[0] --- clang/lib/Driver/ToolChain.cpp | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 34de0043ca012a..bdf3da0c96adca 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -109,7 +109,8 @@ ToolChain::ToolChain(const Driver &D, const llvm::Triple &T, llvm::Expected> ToolChain::executeToolChainProgram(StringRef Executable) const { llvm::SmallString<64> OutputFile; - llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile); + llvm::sys::fs::createTemporaryFile("toolchain-program", "txt", OutputFile, + llvm::sys::fs::OF_Text); llvm::FileRemover OutputRemover(OutputFile.c_str()); std::optional Redirects[] = { {""}, @@ -128,7 +129,8 @@ ToolChain::executeToolChainProgram(StringRef Executable) const { *Str + "'"); SecondsToWait = std::max(SecondsToWait, 0); // infinite } - if (llvm::sys::ExecuteAndWait(Executable, {}, {}, Redirects, SecondsToWait, + if (llvm::sys::ExecuteAndWait(Executable, {Executable}, {}, Redirects, +SecondsToWait, /*MemoryLimit=*/0, &ErrorMessage)) return llvm::createStringError(std::error_code(), Executable + ": " + ErrorMessage); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Pass the executable name as arg[0] when calling ExecuteAndWait() (PR #114067)
https://github.com/perry-ca closed https://github.com/llvm/llvm-project/pull/114067 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Mark tests as unsupported when targeting z/OS (PR #107916)
perry-ca wrote: @abhina-sree could you review this. Thanks https://github.com/llvm/llvm-project/pull/107916 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Mark tests as unsupported when targeting z/OS (PR #107916)
@@ -24,6 +24,7 @@ // // FIXME: Path handling should work on all platforms. // REQUIRES: system-linux +// UNSUPPORTED: target={{.*}}-zos{{.*}} perry-ca wrote: Unless we can prove that is the case, it is better to stick with the more selective condition. I don't think many people run lit cross target so it would be difficult to validate. https://github.com/llvm/llvm-project/pull/107916 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Use %errc to get text for system errors (PR #109852)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/109852 Several lit tests look for messages with text generated from strerror() such as "no such file or directory". The value can change slightly from system to system. Use the llvm-lit macro `%errc_` instead. This was really noticable on z/OS because the generated text includes an error code as well as the text. >From f8bb9d99ae9b9e8fd546d8a5a801681c721cb11d Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 13 Sep 2024 16:49:02 -0500 Subject: [PATCH] use errc instead of hard coded text for messages --- clang/test/Driver/cl-options.c | 4 ++-- clang/test/Driver/cl-zc.cpp| 4 ++-- clang/test/Driver/config-file-errs.c | 6 +++--- clang/test/Driver/response-file-errs.c | 4 ++-- llvm/test/Support/interrupts.test | 4 ++-- .../tools/dsymutil/X86/remarks-linking-archive.text| 10 +- llvm/test/tools/gold/X86/stats-file-option.ll | 4 ++-- llvm/test/tools/llvm-ar/read-only-archive.test | 6 +++--- .../llvm-ctxprof-util/llvm-ctxprof-util-negative.test | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index a6f338533ad763..07a25da0269fd3 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -406,9 +406,9 @@ // RUN:/Zm \ // RUN:/Zo \ // RUN:/Zo- \ -// RUN:-### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s +// RUN:-### -- %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=IGNORED %s // IGNORED-NOT: argument unused during compilation -// IGNORED-NOT: no such file or directory +// IGNORED-NOT: [[MSG]] // Don't confuse /openmp- with the /o flag: // IGNORED-NOT: "-o" "penmp-.obj" diff --git a/clang/test/Driver/cl-zc.cpp b/clang/test/Driver/cl-zc.cpp index c7cf5b1b6525be..9b1ea53888ceb5 100644 --- a/clang/test/Driver/cl-zc.cpp +++ b/clang/test/Driver/cl-zc.cpp @@ -133,9 +133,9 @@ // RUN: /Zc:inline \ // RUN: /Zc:rvalueCast \ // RUN: /Zc:ternary \ -// RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s +// RUN: -### -- %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=IGNORED %s // IGNORED-NOT: argument unused during compilation -// IGNORED-NOT: no such file or directory +// IGNORED-NOT: [[MSG]] // Negated form warns: // RUN: %clang_cl /c \ diff --git a/clang/test/Driver/config-file-errs.c b/clang/test/Driver/config-file-errs.c index 96b49b2acf8ab4..dc4fcdebf44bca 100644 --- a/clang/test/Driver/config-file-errs.c +++ b/clang/test/Driver/config-file-errs.c @@ -6,13 +6,13 @@ //--- Argument of '--config' must be existing file, if it is specified by path. // -// RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck %s -check-prefix CHECK-NONEXISTENT -// CHECK-NONEXISTENT: configuration file '{{.*}}somewhere{{.}}nonexistent-config-file' cannot be opened: {{[Nn]}}o such file or directory +// RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix CHECK-NONEXISTENT +// CHECK-NONEXISTENT: configuration file '{{.*}}somewhere{{.}}nonexistent-config-file' cannot be opened: [[MSG]] //--- All '--config' arguments must be existing files. // -// RUN: not %clang --config %S/Inputs/config-4.cfg --config somewhere/nonexistent-config-file 2>&1 | FileCheck %s -check-prefix CHECK-NONEXISTENT +// RUN: not %clang --config %S/Inputs/config-4.cfg --config somewhere/nonexistent-config-file 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix CHECK-NONEXISTENT //--- Argument of '--config' must exist somewhere in well-known directories, if it is specified by bare name. diff --git a/clang/test/Driver/response-file-errs.c b/clang/test/Driver/response-file-errs.c index efde7575a51e06..5331c8e308f487 100644 --- a/clang/test/Driver/response-file-errs.c +++ b/clang/test/Driver/response-file-errs.c @@ -11,5 +11,5 @@ // If file in `@file` is a directory, it is an error. // -// RUN: not %clang @%S/Inputs -### 2>&1 | FileCheck --check-prefix=DIRECTORY %s -// DIRECTORY: cannot not open file '{{.*}}Inputs': {{[Ii]}}s a directory +// RUN: not %clang @%S/Inputs -### 2>&1 | FileCheck -DMSG=%errc_EISDIR --check-prefix=DIRECTORY %s +// DIRECTORY: cannot not open file '{{.*}}Inputs': [[MSG]] diff --git a/llvm/test/Support/interrupts.test b/llvm/test/Support/interrupts.test index 4768ac61dff026..0966586106cc7a 100644 --- a/llvm/test/Support/interrupts.test +++ b/llvm/test/Support/interrupts.test @@ -1,9 +1,9 @@ ## Show that SIGINT and similar signals don't cause crash messages to be ## reported. # RUN: %python %s wrapper llvm-symbolizer 2> %t.err -# RUN: FileCheck --input-file=%t.err %s +# RUN: FileCheck -DMSG=%errc_ENOENT --input-file=%t.err %s -# CHECK: {{.*}} error: 'foo': {{[Nn]}}o such file or directory +# CHECK: {{.*}} error: 'foo': [[MSG
[clang] [llvm] Use %errc to get text for system errors (PR #109852)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/109852 >From f8bb9d99ae9b9e8fd546d8a5a801681c721cb11d Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 13 Sep 2024 16:49:02 -0500 Subject: [PATCH] use errc instead of hard coded text for messages --- clang/test/Driver/cl-options.c | 4 ++-- clang/test/Driver/cl-zc.cpp| 4 ++-- clang/test/Driver/config-file-errs.c | 6 +++--- clang/test/Driver/response-file-errs.c | 4 ++-- llvm/test/Support/interrupts.test | 4 ++-- .../tools/dsymutil/X86/remarks-linking-archive.text| 10 +- llvm/test/tools/gold/X86/stats-file-option.ll | 4 ++-- llvm/test/tools/llvm-ar/read-only-archive.test | 6 +++--- .../llvm-ctxprof-util/llvm-ctxprof-util-negative.test | 4 ++-- 9 files changed, 23 insertions(+), 23 deletions(-) diff --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c index a6f338533ad763..07a25da0269fd3 100644 --- a/clang/test/Driver/cl-options.c +++ b/clang/test/Driver/cl-options.c @@ -406,9 +406,9 @@ // RUN:/Zm \ // RUN:/Zo \ // RUN:/Zo- \ -// RUN:-### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s +// RUN:-### -- %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=IGNORED %s // IGNORED-NOT: argument unused during compilation -// IGNORED-NOT: no such file or directory +// IGNORED-NOT: [[MSG]] // Don't confuse /openmp- with the /o flag: // IGNORED-NOT: "-o" "penmp-.obj" diff --git a/clang/test/Driver/cl-zc.cpp b/clang/test/Driver/cl-zc.cpp index c7cf5b1b6525be..9b1ea53888ceb5 100644 --- a/clang/test/Driver/cl-zc.cpp +++ b/clang/test/Driver/cl-zc.cpp @@ -133,9 +133,9 @@ // RUN: /Zc:inline \ // RUN: /Zc:rvalueCast \ // RUN: /Zc:ternary \ -// RUN: -### -- %s 2>&1 | FileCheck -check-prefix=IGNORED %s +// RUN: -### -- %s 2>&1 | FileCheck -DMSG=%errc_ENOENT -check-prefix=IGNORED %s // IGNORED-NOT: argument unused during compilation -// IGNORED-NOT: no such file or directory +// IGNORED-NOT: [[MSG]] // Negated form warns: // RUN: %clang_cl /c \ diff --git a/clang/test/Driver/config-file-errs.c b/clang/test/Driver/config-file-errs.c index 96b49b2acf8ab4..dc4fcdebf44bca 100644 --- a/clang/test/Driver/config-file-errs.c +++ b/clang/test/Driver/config-file-errs.c @@ -6,13 +6,13 @@ //--- Argument of '--config' must be existing file, if it is specified by path. // -// RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck %s -check-prefix CHECK-NONEXISTENT -// CHECK-NONEXISTENT: configuration file '{{.*}}somewhere{{.}}nonexistent-config-file' cannot be opened: {{[Nn]}}o such file or directory +// RUN: not %clang --config somewhere/nonexistent-config-file 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix CHECK-NONEXISTENT +// CHECK-NONEXISTENT: configuration file '{{.*}}somewhere{{.}}nonexistent-config-file' cannot be opened: [[MSG]] //--- All '--config' arguments must be existing files. // -// RUN: not %clang --config %S/Inputs/config-4.cfg --config somewhere/nonexistent-config-file 2>&1 | FileCheck %s -check-prefix CHECK-NONEXISTENT +// RUN: not %clang --config %S/Inputs/config-4.cfg --config somewhere/nonexistent-config-file 2>&1 | FileCheck -DMSG=%errc_ENOENT %s -check-prefix CHECK-NONEXISTENT //--- Argument of '--config' must exist somewhere in well-known directories, if it is specified by bare name. diff --git a/clang/test/Driver/response-file-errs.c b/clang/test/Driver/response-file-errs.c index efde7575a51e06..5331c8e308f487 100644 --- a/clang/test/Driver/response-file-errs.c +++ b/clang/test/Driver/response-file-errs.c @@ -11,5 +11,5 @@ // If file in `@file` is a directory, it is an error. // -// RUN: not %clang @%S/Inputs -### 2>&1 | FileCheck --check-prefix=DIRECTORY %s -// DIRECTORY: cannot not open file '{{.*}}Inputs': {{[Ii]}}s a directory +// RUN: not %clang @%S/Inputs -### 2>&1 | FileCheck -DMSG=%errc_EISDIR --check-prefix=DIRECTORY %s +// DIRECTORY: cannot not open file '{{.*}}Inputs': [[MSG]] diff --git a/llvm/test/Support/interrupts.test b/llvm/test/Support/interrupts.test index 4768ac61dff026..0966586106cc7a 100644 --- a/llvm/test/Support/interrupts.test +++ b/llvm/test/Support/interrupts.test @@ -1,9 +1,9 @@ ## Show that SIGINT and similar signals don't cause crash messages to be ## reported. # RUN: %python %s wrapper llvm-symbolizer 2> %t.err -# RUN: FileCheck --input-file=%t.err %s +# RUN: FileCheck -DMSG=%errc_ENOENT --input-file=%t.err %s -# CHECK: {{.*}} error: 'foo': {{[Nn]}}o such file or directory +# CHECK: {{.*}} error: 'foo': [[MSG]] # CHECK-NOT: {{.+}} import os diff --git a/llvm/test/tools/dsymutil/X86/remarks-linking-archive.text b/llvm/test/tools/dsymutil/X86/remarks-linking-archive.text index e23d0b620cac1b..47f9df82296fed 100644 --- a/llvm/test/tools/dsymutil/X86/remarks-linking-archive.text +++ b/llvm/test/tools/dsymutil/X86/rem
[clang] [llvm] Use %errc to get text for system errors (PR #109852)
perry-ca wrote: Thanks for the offer David. I do have permission now. I held off merging yesterday because the builds were all broken from some other change. The builds all pass now. I'll merge it. https://github.com/llvm/llvm-project/pull/109852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] Use %errc to get text for system errors (PR #109852)
https://github.com/perry-ca closed https://github.com/llvm/llvm-project/pull/109852 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [clang-tools-extra] [lldb] [llvm] Propagate IsText parameter to openFileForRead function (PR #110661)
perry-ca wrote: > @perry-ca raised some concerns in #109664 about this functionality requiring > some context awareness, I don't think any of those is addressed by this patch > either. Pretty much all of the callers apart from ASTReader is just using > `IsText = true`. It just happens that 90% of the time you are dealing with text files. As you noted, in the context of the ASTReader, the file being read is expected to be a binary file. In that case the parameter is false. These change mirror interface to `getFileOrSTDIN()` which has a IsText parameter. This does touch a number of places but I feel the changes are in line with the rest of the file I/O functions in llvm. https://github.com/llvm/llvm-project/pull/110661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] The real option name and not the alias used is displayed in msgs when using a config file (PR #107613)
https://github.com/perry-ca closed https://github.com/llvm/llvm-project/pull/107613 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/111035 The z/OS operating system uses the linker to control what symbols are exported from shared libraries. The compilation step sets a bit on each symbol that should be exported from a shared library and then the linker marks these as exported from the shared library. The linker also produces what is called a side deck that is a list of all the exported symbols. This is then used as an import file during the link process for programs (or other shared libraries) that link against a shared library. The default for compilation is to only export symbols that the user wants to export. Control over what is exported is done by: - making the default for visibility to be hidden - using the _Export keyword or #pragma export to indicate what symbols should be exported. These are features the existing compilers on z/OS use. - using attribute((visibility,"default")) to mark the symbol as exported. Note: `Parser::HandlePragmaExport()` has an extra layer of call to parse the pragma. We have some more pragmas that have very similar syntax. I'll be upstreaming those next. It is easier to leave that layer in than to remove it for this PR and then add it back. >From e8d355c9cd165e0a255bbbfb5b0126cf7b1461a6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 2 Oct 2024 12:56:43 -0500 Subject: [PATCH 1/4] initial work for pragma export & _Export keyword --- clang/include/clang/AST/ASTConsumer.h | 3 + clang/include/clang/Basic/Attr.td | 6 + clang/include/clang/Basic/AttrDocs.td | 21 ++ .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Basic/TokenKinds.def | 5 + clang/include/clang/Parse/Parser.h| 13 ++ clang/include/clang/Sema/DeclSpec.h | 31 ++- clang/include/clang/Sema/Sema.h | 30 +++ clang/lib/CodeGen/BackendConsumer.h | 1 + clang/lib/CodeGen/CodeGenAction.cpp | 4 + clang/lib/CodeGen/CodeGenModule.cpp | 15 ++ clang/lib/CodeGen/CodeGenModule.h | 2 + clang/lib/CodeGen/ModuleBuilder.cpp | 6 +- clang/lib/Driver/ToolChains/ZOS.cpp | 12 +- clang/lib/Parse/ParseDecl.cpp | 18 ++ clang/lib/Parse/ParseDeclCXX.cpp | 6 + clang/lib/Parse/ParsePragma.cpp | 208 ++ clang/lib/Parse/Parser.cpp| 3 + clang/lib/Sema/DeclSpec.cpp | 6 + clang/lib/Sema/Sema.cpp | 21 ++ clang/lib/Sema/SemaAttr.cpp | 162 ++ clang/lib/Sema/SemaDecl.cpp | 13 ++ clang/test/CodeGen/attr-export-failing.cpp| 4 + clang/test/CodeGen/attr-export.cpp| 51 + clang/test/CodeGen/pragma-export.c| 39 clang/test/CodeGen/pragma-export.cpp | 82 +++ clang/test/CodeGen/zos-pragmas.c | 11 + clang/test/CodeGen/zos-pragmas.cpp| 11 + 28 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGen/attr-export-failing.cpp create mode 100644 clang/test/CodeGen/attr-export.cpp create mode 100644 clang/test/CodeGen/pragma-export.c create mode 100644 clang/test/CodeGen/pragma-export.cpp create mode 100644 clang/test/CodeGen/zos-pragmas.c create mode 100644 clang/test/CodeGen/zos-pragmas.cpp diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 447f2592d23595..b15d53e700c679 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -108,6 +108,9 @@ class ASTConsumer { /// completed. virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} + /// CompletePragmaExport - complete #pragma export statements. + virtual void CompletePragmaExport(Decl *D) {} + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fbcbf0ed416416..884c4147cf1285 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4520,6 +4520,12 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def zOSExport : InheritableAttr { + let Spellings = [CustomKeyword<"_Export">]; + let Subjects = SubjectList<[Function, Var, CXXRecord]>; + let Documentation = [zOSExportDocs]; +} + def UnsafeBufferUsage : InheritableAttr { let Spellings = [Clang<"unsafe_buffer_usage">]; let Subjects = SubjectList<[Function, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 53d88482698f00..bf56fa6ad7162f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -6863,6 +6863,27 @@ attribute requires a
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/111035 >From e8d355c9cd165e0a255bbbfb5b0126cf7b1461a6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 2 Oct 2024 12:56:43 -0500 Subject: [PATCH 1/9] initial work for pragma export & _Export keyword --- clang/include/clang/AST/ASTConsumer.h | 3 + clang/include/clang/Basic/Attr.td | 6 + clang/include/clang/Basic/AttrDocs.td | 21 ++ .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Basic/TokenKinds.def | 5 + clang/include/clang/Parse/Parser.h| 13 ++ clang/include/clang/Sema/DeclSpec.h | 31 ++- clang/include/clang/Sema/Sema.h | 30 +++ clang/lib/CodeGen/BackendConsumer.h | 1 + clang/lib/CodeGen/CodeGenAction.cpp | 4 + clang/lib/CodeGen/CodeGenModule.cpp | 15 ++ clang/lib/CodeGen/CodeGenModule.h | 2 + clang/lib/CodeGen/ModuleBuilder.cpp | 6 +- clang/lib/Driver/ToolChains/ZOS.cpp | 12 +- clang/lib/Parse/ParseDecl.cpp | 18 ++ clang/lib/Parse/ParseDeclCXX.cpp | 6 + clang/lib/Parse/ParsePragma.cpp | 208 ++ clang/lib/Parse/Parser.cpp| 3 + clang/lib/Sema/DeclSpec.cpp | 6 + clang/lib/Sema/Sema.cpp | 21 ++ clang/lib/Sema/SemaAttr.cpp | 162 ++ clang/lib/Sema/SemaDecl.cpp | 13 ++ clang/test/CodeGen/attr-export-failing.cpp| 4 + clang/test/CodeGen/attr-export.cpp| 51 + clang/test/CodeGen/pragma-export.c| 39 clang/test/CodeGen/pragma-export.cpp | 82 +++ clang/test/CodeGen/zos-pragmas.c | 11 + clang/test/CodeGen/zos-pragmas.cpp| 11 + 28 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGen/attr-export-failing.cpp create mode 100644 clang/test/CodeGen/attr-export.cpp create mode 100644 clang/test/CodeGen/pragma-export.c create mode 100644 clang/test/CodeGen/pragma-export.cpp create mode 100644 clang/test/CodeGen/zos-pragmas.c create mode 100644 clang/test/CodeGen/zos-pragmas.cpp diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 447f2592d23595..b15d53e700c679 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -108,6 +108,9 @@ class ASTConsumer { /// completed. virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} + /// CompletePragmaExport - complete #pragma export statements. + virtual void CompletePragmaExport(Decl *D) {} + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fbcbf0ed416416..884c4147cf1285 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4520,6 +4520,12 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def zOSExport : InheritableAttr { + let Spellings = [CustomKeyword<"_Export">]; + let Subjects = SubjectList<[Function, Var, CXXRecord]>; + let Documentation = [zOSExportDocs]; +} + def UnsafeBufferUsage : InheritableAttr { let Spellings = [Clang<"unsafe_buffer_usage">]; let Subjects = SubjectList<[Function, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 53d88482698f00..bf56fa6ad7162f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -6863,6 +6863,27 @@ attribute requires a string literal argument to identify the handle being releas }]; } +def zOSExportDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the _Export keyword with a function name or external variable to declare +that it is to be exported (made available to other modules). You must define +the object name in the same translation unit in which you use the _Export +keyword. For example: + +.. code-block:: c + + int _Export anthony(float); + +This statement exports the function anthony, if you define the function in the +translation unit. The _Export keyword must immediately precede the object name. +If you apply the _Export keyword to a class, the compiler automatically exports +all static data members and member functions of the class. However, if you want +it to apply to individual class members, then you must apply it to each member +that can be referenced. + }]; +} + def UnsafeBufferUsageDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 64e6d0407b0ce3..09842ed02efd4b 100644 --- a/c
[clang] [llvm] [SystemZ][z/OS] Update autoconversion functions to improve support for UTF-8 (PR #98652)
@@ -166,8 +167,15 @@ ContentCache::getBufferOrNone(DiagnosticsEngine &Diag, FileManager &FM, // Unless this is a named pipe (in which case we can handle a mismatch), // check that the file's size is the same as in the file entry (which may // have come from a stat cache). +#ifndef __MVS__ if (!ContentsEntry->isNamedPipe() && Buffer->getBufferSize() != (size_t)ContentsEntry->getSize()) { +#else + // The buffer will always be larger than the file size on z/OS in the presence + // of characters outside the base character set. + if (!ContentsEntry->isNamedPipe() && + Buffer->getBufferSize() < (size_t)ContentsEntry->getSize()) { perry-ca wrote: To remove the #if we could just replace the != with < and then add an assert: ```cpp assert(Buffer->getBufferSize() <= (size_t)ContentsEntry->getSize()); f (!ContentsEntry->isNamedPipe() && Buffer->getBufferSize() < (size_t)ContentsEntry->getSize()) { ``` https://github.com/llvm/llvm-project/pull/98652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [llvm] [SystemZ][z/OS] Update autoconversion functions to improve support for UTF-8 (PR #98652)
@@ -617,6 +625,23 @@ FileID SourceManager::createFileIDImpl(ContentCache &File, StringRef Filename, return FileID::get(LoadedID); } unsigned FileSize = File.getSize(); +#ifdef __MVS__ perry-ca wrote: I think we can just remove #if and make a version of `needzOSConversion` that is not z/OS specific. We need to be doing something with the error condition. https://github.com/llvm/llvm-project/pull/98652 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [libcxx] [libc++] Rename `__` prefix to `__libcpp_` for locale related functions (PR #119241)
perry-ca wrote: These macros can't be undef'ed as they are used to implement the functions like islower(int) by the headers like ctype.h. Any name other than __X will work for these inline functions in libc++. https://github.com/llvm/llvm-project/pull/119241 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add z/OS customization file (PR #111182)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/82 >From 360bab981d8ec36e17aa4fbadbb4feef42c5d135 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Fri, 4 Oct 2024 10:09:32 -0500 Subject: [PATCH 1/2] Add z/OS customization file --- clang/include/clang/Driver/Driver.h | 5 +++ clang/lib/Driver/Driver.cpp | 33 +++ clang/test/Driver/Inputs/config-zos/clang.cfg | 1 + clang/test/Driver/Inputs/config-zos/def.cfg | 1 + .../test/Driver/Inputs/config-zos/tst/def.cfg | 1 + clang/test/Driver/config-zos.c| 17 ++ clang/test/Driver/config-zos1.c | 23 + 7 files changed, 81 insertions(+) create mode 100644 clang/test/Driver/Inputs/config-zos/clang.cfg create mode 100644 clang/test/Driver/Inputs/config-zos/def.cfg create mode 100644 clang/test/Driver/Inputs/config-zos/tst/def.cfg create mode 100644 clang/test/Driver/config-zos.c create mode 100644 clang/test/Driver/config-zos1.c diff --git a/clang/include/clang/Driver/Driver.h b/clang/include/clang/Driver/Driver.h index 9177d56718ee77..5466659044ba22 100644 --- a/clang/include/clang/Driver/Driver.h +++ b/clang/include/clang/Driver/Driver.h @@ -738,6 +738,11 @@ class Driver { /// \returns true if error occurred. bool loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx); + /// Tries to load options from customization file. + /// + /// \returns true if error occurred. + bool loadZOSCustomizationFile(llvm::cl::ExpansionContext &); + /// Read options from the specified file. /// /// \param [in] FileName File to read. diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index e9bf60d5e2ee46..dcf01cc2c29ee8 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -998,6 +998,34 @@ void Driver::CreateOffloadingDeviceToolChains(Compilation &C, // } +bool Driver::loadZOSCustomizationFile(llvm::cl::ExpansionContext &ExpCtx) { + if (IsCLMode() || IsDXCMode() || IsFlangMode()) +return false; + + SmallString<128> CustomizationFile; + StringRef PathLIBEnv = StringRef(getenv("CLANG_CONFIG_PATH")).trim(); + // If the env var is a directory then append "/clang.cfg" and treat + // that as the config file. Otherwise treat the env var as the + // config file. + if (!PathLIBEnv.empty()) { +llvm::sys::path::append(CustomizationFile, PathLIBEnv); +if (llvm::sys::fs::is_directory(PathLIBEnv)) + llvm::sys::path::append(CustomizationFile, "/clang.cfg"); +if (llvm::sys::fs::is_regular_file(CustomizationFile)) + return readConfigFile(CustomizationFile, ExpCtx); +Diag(diag::err_drv_config_file_not_found) << CustomizationFile; +return true; + } + + SmallString<128> BaseDir(llvm::sys::path::parent_path(Dir)); + llvm::sys::path::append(CustomizationFile, BaseDir + "/etc/clang.cfg"); + if (llvm::sys::fs::is_regular_file(CustomizationFile)) +return readConfigFile(CustomizationFile, ExpCtx); + + // If no customization file, just return + return false; +} + static void appendOneArg(InputArgList &Args, const Arg *Opt, const Arg *BaseArg) { // The args for config files or /clang: flags belong to different InputArgList @@ -1179,6 +1207,11 @@ bool Driver::loadDefaultConfigFiles(llvm::cl::ExpansionContext &ExpCtx) { assert(!Triple.empty()); } + // On z/OS, start by loading the customization file before loading + // the usual default config file(s). + if (llvm::Triple(Triple).isOSzOS() && loadZOSCustomizationFile(ExpCtx)) +return true; + // Search for config files in the following order: // 1. -.cfg using real driver mode //(e.g. i386-pc-linux-gnu-clang++.cfg). diff --git a/clang/test/Driver/Inputs/config-zos/clang.cfg b/clang/test/Driver/Inputs/config-zos/clang.cfg new file mode 100644 index 00..43a5dbfaa61826 --- /dev/null +++ b/clang/test/Driver/Inputs/config-zos/clang.cfg @@ -0,0 +1 @@ +-DABC=123 diff --git a/clang/test/Driver/Inputs/config-zos/def.cfg b/clang/test/Driver/Inputs/config-zos/def.cfg new file mode 100644 index 00..156f9c85fb4f2e --- /dev/null +++ b/clang/test/Driver/Inputs/config-zos/def.cfg @@ -0,0 +1 @@ +-DDEF=456 diff --git a/clang/test/Driver/Inputs/config-zos/tst/def.cfg b/clang/test/Driver/Inputs/config-zos/tst/def.cfg new file mode 100644 index 00..156f9c85fb4f2e --- /dev/null +++ b/clang/test/Driver/Inputs/config-zos/tst/def.cfg @@ -0,0 +1 @@ +-DDEF=456 diff --git a/clang/test/Driver/config-zos.c b/clang/test/Driver/config-zos.c new file mode 100644 index 00..8de02ec101b914 --- /dev/null +++ b/clang/test/Driver/config-zos.c @@ -0,0 +1,17 @@ +// REQUIRES: shell +// REQUIRES: systemz-registered-target + +// RUN: unset CLANG_NO_DEFAULT_CONFIG +// RUN: rm -rf %t && mkdir %t + +// RUN: mkdir -p %t/testbin +// RUN: mkdir -p %t/etc +// RUN: ln -s %clang %t/testbin/clang +// RUN: echo "-DXYZ=789" >%t/etc/clang.cfg +
[clang] [SystemZ][z/OS] Add z/OS customization file (PR #111182)
perry-ca wrote: build failures were from time outs uploading to the artifactory. Is unrelated to change. ``` 2025-01-06 21:33:11 ERROR Error uploading artifact states: PUT https://agent.buildkite.com/v3/jobs/01943cd5-d77e-4011-a1f4-08aabba24f73/artifacts: 504 Gateway Time-out -- | fatal: failed to upload artifacts: uploading artifacts: errors uploading artifacts: [PUT https://agent.buildkite.com/v3/jobs/01943cd5-d77e-4011-a1f4-08aabba24f73/artifacts: 504 Gateway Time-out] ``` https://github.com/llvm/llvm-project/pull/82 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add z/OS customization file (PR #111182)
https://github.com/perry-ca closed https://github.com/llvm/llvm-project/pull/82 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Add option to target older versions of LE on z/OS (PR #123399)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/123399 >From 9f5763faa81691f540af42721147daf50042e549 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 27 Nov 2024 18:33:09 -0600 Subject: [PATCH 1/3] Add -mzos-target --- .../clang/Basic/DiagnosticDriverKinds.td | 5 ++ clang/include/clang/Driver/Options.td | 1 + clang/lib/Basic/Targets/SystemZ.cpp | 15 clang/lib/Driver/Driver.cpp | 72 +++ clang/lib/Driver/ToolChain.cpp| 15 clang/test/Preprocessor/zos-target.c | 18 + 6 files changed, 126 insertions(+) create mode 100644 clang/test/Preprocessor/zos-target.c diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 5155b23d151c04..140bc52af12b25 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -277,6 +277,11 @@ def err_cpu_unsupported_isa def err_arch_unsupported_isa : Error<"architecture '%0' does not support '%1' execution mode">; +def err_zos_target_release_discontinued + : Error<"z/OS target level \"%0\" is discontinued. Unexpected behavior might occur if an out-of-support target level is specified. Use z/OS target level \"zOSv2r4\", or later instead">; +def err_zos_target_unrecognized_release + : Error<"\"%0\" is not recognized as a valid z/OS target level. The z/OS target level must be \"current\", or of the form \"zosvVrR\", where \"V\" is the version and \"R\" is the release, or given as a \"0x\"-prefixed eight digit hexadecimal value">; + def err_drv_I_dash_not_supported : Error< "'%0' not supported, please use -iquote instead">; def err_drv_unknown_argument : Error<"unknown argument: '%0'">; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 40fd48761928b3..ddbd857414e714 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4734,6 +4734,7 @@ def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min= def march_EQ : Joined<["-"], "march=">, Group, Flags<[TargetSpecific]>, Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, HelpText<"For a list of available architectures for the target use '-mcpu=help'">; +def mzos_target_EQ : Joined<["-"], "mzos-target=">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Set the z/OS release of the runtime environment">; def masm_EQ : Joined<["-"], "masm=">, Group, Visibility<[ClangOption, FlangOption]>; def inline_asm_EQ : Joined<["-"], "inline-asm=">, Group, Visibility<[ClangOption, CC1Option]>, diff --git a/clang/lib/Basic/Targets/SystemZ.cpp b/clang/lib/Basic/Targets/SystemZ.cpp index 06f08db2eadd47..2c749c0ba76937 100644 --- a/clang/lib/Basic/Targets/SystemZ.cpp +++ b/clang/lib/Basic/Targets/SystemZ.cpp @@ -168,6 +168,21 @@ void SystemZTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__VX__"); if (Opts.ZVector) Builder.defineMacro("__VEC__", "10304"); + + /* Set __TARGET_LIB__ only if a value was given. If no value was given */ + /* we rely on the LE headers to define __TARGET_LIB__. */ + if (!getTriple().getOSVersion().empty()) { +llvm::VersionTuple V = getTriple().getOSVersion(); +// Create string with form: 0xPVRR, where P=4 +std::string Str("0x"); +unsigned int Librel = 0x4000; +Librel |= V.getMajor() << 24; +Librel |= (V.getMinor() ? V.getMinor().value() : 1) << 16; +Librel |= V.getSubminor() ? V.getSubminor().value() : 0; +Str += llvm::utohexstr(Librel); + +Builder.defineMacro("__TARGET_LIB__", Str.c_str()); + } } ArrayRef SystemZTargetInfo::getTargetBuiltins() const { diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index ad14b5c9b6dc80..eebe60648ed22b 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -517,6 +517,72 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { return DAL; } +static void setZosTargetVersion(const Driver &D, llvm::Triple &Target, +StringRef ArgTarget) { + + static bool BeSilent = false; + auto IsTooOldToBeSupported = [](int v, int r) -> bool { +return ((v < 2) || ((v == 2) && (r < 4))); + }; + + /* expect CURRENT, zOSV2R[45], or 0x */ + if (ArgTarget.equals_insensitive("CURRENT")) { +/* If the user gives CURRENT, then we rely on the LE to set */ +/* __TARGET_LIB__. There's nothing more we need to do. */ + } else { +unsigned int Version = 0; +unsigned int Release = 0; +unsigned int Modification = 0; +bool IsOk = true; +llvm::Regex ZOsvRegex("[zZ][oO][sS][vV]([0-9])[rR]([0-9])"); +llvm::Regex HexRegex( +"0x4" /* product */ +"([0-9a-fA-F])"/* version *
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/111035 >From e8d355c9cd165e0a255bbbfb5b0126cf7b1461a6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 2 Oct 2024 12:56:43 -0500 Subject: [PATCH 1/9] initial work for pragma export & _Export keyword --- clang/include/clang/AST/ASTConsumer.h | 3 + clang/include/clang/Basic/Attr.td | 6 + clang/include/clang/Basic/AttrDocs.td | 21 ++ .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Basic/TokenKinds.def | 5 + clang/include/clang/Parse/Parser.h| 13 ++ clang/include/clang/Sema/DeclSpec.h | 31 ++- clang/include/clang/Sema/Sema.h | 30 +++ clang/lib/CodeGen/BackendConsumer.h | 1 + clang/lib/CodeGen/CodeGenAction.cpp | 4 + clang/lib/CodeGen/CodeGenModule.cpp | 15 ++ clang/lib/CodeGen/CodeGenModule.h | 2 + clang/lib/CodeGen/ModuleBuilder.cpp | 6 +- clang/lib/Driver/ToolChains/ZOS.cpp | 12 +- clang/lib/Parse/ParseDecl.cpp | 18 ++ clang/lib/Parse/ParseDeclCXX.cpp | 6 + clang/lib/Parse/ParsePragma.cpp | 208 ++ clang/lib/Parse/Parser.cpp| 3 + clang/lib/Sema/DeclSpec.cpp | 6 + clang/lib/Sema/Sema.cpp | 21 ++ clang/lib/Sema/SemaAttr.cpp | 162 ++ clang/lib/Sema/SemaDecl.cpp | 13 ++ clang/test/CodeGen/attr-export-failing.cpp| 4 + clang/test/CodeGen/attr-export.cpp| 51 + clang/test/CodeGen/pragma-export.c| 39 clang/test/CodeGen/pragma-export.cpp | 82 +++ clang/test/CodeGen/zos-pragmas.c | 11 + clang/test/CodeGen/zos-pragmas.cpp| 11 + 28 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGen/attr-export-failing.cpp create mode 100644 clang/test/CodeGen/attr-export.cpp create mode 100644 clang/test/CodeGen/pragma-export.c create mode 100644 clang/test/CodeGen/pragma-export.cpp create mode 100644 clang/test/CodeGen/zos-pragmas.c create mode 100644 clang/test/CodeGen/zos-pragmas.cpp diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 447f2592d23595..b15d53e700c679 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -108,6 +108,9 @@ class ASTConsumer { /// completed. virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} + /// CompletePragmaExport - complete #pragma export statements. + virtual void CompletePragmaExport(Decl *D) {} + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fbcbf0ed416416..884c4147cf1285 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4520,6 +4520,12 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def zOSExport : InheritableAttr { + let Spellings = [CustomKeyword<"_Export">]; + let Subjects = SubjectList<[Function, Var, CXXRecord]>; + let Documentation = [zOSExportDocs]; +} + def UnsafeBufferUsage : InheritableAttr { let Spellings = [Clang<"unsafe_buffer_usage">]; let Subjects = SubjectList<[Function, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 53d88482698f00..bf56fa6ad7162f 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -6863,6 +6863,27 @@ attribute requires a string literal argument to identify the handle being releas }]; } +def zOSExportDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the _Export keyword with a function name or external variable to declare +that it is to be exported (made available to other modules). You must define +the object name in the same translation unit in which you use the _Export +keyword. For example: + +.. code-block:: c + + int _Export anthony(float); + +This statement exports the function anthony, if you define the function in the +translation unit. The _Export keyword must immediately precede the object name. +If you apply the _Export keyword to a class, the compiler automatically exports +all static data members and member functions of the class. However, if you want +it to apply to individual class members, then you must apply it to each member +that can be referenced. + }]; +} + def UnsafeBufferUsageDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 64e6d0407b0ce3..09842ed02efd4b 100644 --- a/c
[clang] [z/OS] Add option to target older versions of LE on z/OS (PR #123399)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/123399 Add an option similar to the -qtarget option in XL to allow the user to say they want to be able to run the generated program on an older version of the LE environment. This option will do two things: - set the `__TARGET_LIBS` macro so the system headers exclude newer interfaces when targeting older environments - set the arch level to match the minimum arch level for that older version of LE. It some happens right now all of the supported LE versions have a the same minimum ach level so the option doesn't change this yet. The user can specify three different kinds of arguments: 1. -mzos-target=zosv*V*r*R* - where V & R are the version and release 2. -mzos-target=0x4vrr - v, r, m, p are the hex values for the version, release, and modlevel 3. -mzos-target=current - uses the latest version of LE the system headers have support for >From 9f5763faa81691f540af42721147daf50042e549 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 27 Nov 2024 18:33:09 -0600 Subject: [PATCH 1/2] Add -mzos-target --- .../clang/Basic/DiagnosticDriverKinds.td | 5 ++ clang/include/clang/Driver/Options.td | 1 + clang/lib/Basic/Targets/SystemZ.cpp | 15 clang/lib/Driver/Driver.cpp | 72 +++ clang/lib/Driver/ToolChain.cpp| 15 clang/test/Preprocessor/zos-target.c | 18 + 6 files changed, 126 insertions(+) create mode 100644 clang/test/Preprocessor/zos-target.c diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td index 5155b23d151c04..140bc52af12b25 100644 --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -277,6 +277,11 @@ def err_cpu_unsupported_isa def err_arch_unsupported_isa : Error<"architecture '%0' does not support '%1' execution mode">; +def err_zos_target_release_discontinued + : Error<"z/OS target level \"%0\" is discontinued. Unexpected behavior might occur if an out-of-support target level is specified. Use z/OS target level \"zOSv2r4\", or later instead">; +def err_zos_target_unrecognized_release + : Error<"\"%0\" is not recognized as a valid z/OS target level. The z/OS target level must be \"current\", or of the form \"zosvVrR\", where \"V\" is the version and \"R\" is the release, or given as a \"0x\"-prefixed eight digit hexadecimal value">; + def err_drv_I_dash_not_supported : Error< "'%0' not supported, please use -iquote instead">; def err_drv_unknown_argument : Error<"unknown argument: '%0'">; diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 40fd48761928b3..ddbd857414e714 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -4734,6 +4734,7 @@ def mwatchsimulator_version_min_EQ : Joined<["-"], "mwatchsimulator-version-min= def march_EQ : Joined<["-"], "march=">, Group, Flags<[TargetSpecific]>, Visibility<[ClangOption, CLOption, DXCOption, FlangOption]>, HelpText<"For a list of available architectures for the target use '-mcpu=help'">; +def mzos_target_EQ : Joined<["-"], "mzos-target=">, Group, Visibility<[ClangOption, CC1Option]>, HelpText<"Set the z/OS release of the runtime environment">; def masm_EQ : Joined<["-"], "masm=">, Group, Visibility<[ClangOption, FlangOption]>; def inline_asm_EQ : Joined<["-"], "inline-asm=">, Group, Visibility<[ClangOption, CC1Option]>, diff --git a/clang/lib/Basic/Targets/SystemZ.cpp b/clang/lib/Basic/Targets/SystemZ.cpp index 06f08db2eadd47..2c749c0ba76937 100644 --- a/clang/lib/Basic/Targets/SystemZ.cpp +++ b/clang/lib/Basic/Targets/SystemZ.cpp @@ -168,6 +168,21 @@ void SystemZTargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__VX__"); if (Opts.ZVector) Builder.defineMacro("__VEC__", "10304"); + + /* Set __TARGET_LIB__ only if a value was given. If no value was given */ + /* we rely on the LE headers to define __TARGET_LIB__. */ + if (!getTriple().getOSVersion().empty()) { +llvm::VersionTuple V = getTriple().getOSVersion(); +// Create string with form: 0xPVRR, where P=4 +std::string Str("0x"); +unsigned int Librel = 0x4000; +Librel |= V.getMajor() << 24; +Librel |= (V.getMinor() ? V.getMinor().value() : 1) << 16; +Librel |= V.getSubminor() ? V.getSubminor().value() : 0; +Str += llvm::utohexstr(Librel); + +Builder.defineMacro("__TARGET_LIB__", Str.c_str()); + } } ArrayRef SystemZTargetInfo::getTargetBuiltins() const { diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index ad14b5c9b6dc80..eebe60648ed22b 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -517,6 +517,72 @@ DerivedArgList *Driver::TranslateInputArgs(const InputArgList &Args) const { return DAL
[clang] [z/OS] Add option to target older versions of LE on z/OS (PR #123399)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/123399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] add tail padding to TypeLoc if needed (PR #122761)
https://github.com/perry-ca created https://github.com/llvm/llvm-project/pull/122761 The code in getLocalDataSize() returns the sum of the size of the LocalData plus the size of the extra data. The start of the extra data is padded so it starts on a multiple of it's alignment. We also need to be adding tail padding so the final size is a multiple of the alignment of the LocalData. On most systems the alignment of the extra data is the same or greater than the alignment of the LocalData so you don't need the tail padding. However, on z/OS, the alignment of the extra data is less than the alignment of the LocalData and thus you do need the tail padding to make the final size a multiple of the LocalData alignment. The extra data is the WrittenBuiltinSpecs struct. This struct is just a struct of bitfields. On most systems the alignment of the struct is determined by the type of the bitfields (eg. unsigned int -> align of 4). On z/OS, all bitfields are 1 byte aligned. Thus on z/OS WrittenBuiltinSpecs is only size 2 with alignment of 1 (verses 4 & 4). >From 2dc4b2785d9dea502e7a496a0f4069adf7c79d64 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Mon, 13 Jan 2025 12:53:05 -0500 Subject: [PATCH] add tail padding if needed --- clang/include/clang/AST/TypeLoc.h | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/include/clang/AST/TypeLoc.h b/clang/include/clang/AST/TypeLoc.h index 62ca52e508ba20..a55a38335ef6a6 100644 --- a/clang/include/clang/AST/TypeLoc.h +++ b/clang/include/clang/AST/TypeLoc.h @@ -397,6 +397,7 @@ class ConcreteTypeLoc : public Base { unsigned extraAlign = asDerived()->getExtraLocalDataAlignment(); size = llvm::alignTo(size, extraAlign); size += asDerived()->getExtraLocalDataSize(); +size = llvm::alignTo(size, asDerived()->getLocalDataAlignment()); return size; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] add tail padding to TypeLoc if needed (PR #122761)
perry-ca wrote: This is an internal data structure so hard to write a test case. The clang code does have assertions that fail if the size isn't a multiple of the alignment. https://github.com/llvm/llvm-project/pull/122761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] add tail padding to TypeLoc if needed (PR #122761)
https://github.com/perry-ca closed https://github.com/llvm/llvm-project/pull/122761 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [z/OS] Add option to target older versions of LE on z/OS (PR #123399)
https://github.com/perry-ca closed https://github.com/llvm/llvm-project/pull/123399 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca updated https://github.com/llvm/llvm-project/pull/111035 >From e8d355c9cd165e0a255bbbfb5b0126cf7b1461a6 Mon Sep 17 00:00:00 2001 From: Sean Perry Date: Wed, 2 Oct 2024 12:56:43 -0500 Subject: [PATCH 1/9] initial work for pragma export & _Export keyword --- clang/include/clang/AST/ASTConsumer.h | 3 + clang/include/clang/Basic/Attr.td | 6 + clang/include/clang/Basic/AttrDocs.td | 21 ++ .../clang/Basic/DiagnosticSemaKinds.td| 7 + clang/include/clang/Basic/TokenKinds.def | 5 + clang/include/clang/Parse/Parser.h| 13 ++ clang/include/clang/Sema/DeclSpec.h | 31 ++- clang/include/clang/Sema/Sema.h | 30 +++ clang/lib/CodeGen/BackendConsumer.h | 1 + clang/lib/CodeGen/CodeGenAction.cpp | 4 + clang/lib/CodeGen/CodeGenModule.cpp | 15 ++ clang/lib/CodeGen/CodeGenModule.h | 2 + clang/lib/CodeGen/ModuleBuilder.cpp | 6 +- clang/lib/Driver/ToolChains/ZOS.cpp | 12 +- clang/lib/Parse/ParseDecl.cpp | 18 ++ clang/lib/Parse/ParseDeclCXX.cpp | 6 + clang/lib/Parse/ParsePragma.cpp | 208 ++ clang/lib/Parse/Parser.cpp| 3 + clang/lib/Sema/DeclSpec.cpp | 6 + clang/lib/Sema/Sema.cpp | 21 ++ clang/lib/Sema/SemaAttr.cpp | 162 ++ clang/lib/Sema/SemaDecl.cpp | 13 ++ clang/test/CodeGen/attr-export-failing.cpp| 4 + clang/test/CodeGen/attr-export.cpp| 51 + clang/test/CodeGen/pragma-export.c| 39 clang/test/CodeGen/pragma-export.cpp | 82 +++ clang/test/CodeGen/zos-pragmas.c | 11 + clang/test/CodeGen/zos-pragmas.cpp| 11 + 28 files changed, 784 insertions(+), 7 deletions(-) create mode 100644 clang/test/CodeGen/attr-export-failing.cpp create mode 100644 clang/test/CodeGen/attr-export.cpp create mode 100644 clang/test/CodeGen/pragma-export.c create mode 100644 clang/test/CodeGen/pragma-export.cpp create mode 100644 clang/test/CodeGen/zos-pragmas.c create mode 100644 clang/test/CodeGen/zos-pragmas.cpp diff --git a/clang/include/clang/AST/ASTConsumer.h b/clang/include/clang/AST/ASTConsumer.h index 447f2592d2359..b15d53e700c67 100644 --- a/clang/include/clang/AST/ASTConsumer.h +++ b/clang/include/clang/AST/ASTConsumer.h @@ -108,6 +108,9 @@ class ASTConsumer { /// completed. virtual void CompleteExternalDeclaration(DeclaratorDecl *D) {} + /// CompletePragmaExport - complete #pragma export statements. + virtual void CompletePragmaExport(Decl *D) {} + /// Callback invoked when an MSInheritanceAttr has been attached to a /// CXXRecordDecl. virtual void AssignInheritanceModel(CXXRecordDecl *RD) {} diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td index fbcbf0ed41641..884c4147cf128 100644 --- a/clang/include/clang/Basic/Attr.td +++ b/clang/include/clang/Basic/Attr.td @@ -4520,6 +4520,12 @@ def ReleaseHandle : InheritableParamAttr { let Documentation = [ReleaseHandleDocs]; } +def zOSExport : InheritableAttr { + let Spellings = [CustomKeyword<"_Export">]; + let Subjects = SubjectList<[Function, Var, CXXRecord]>; + let Documentation = [zOSExportDocs]; +} + def UnsafeBufferUsage : InheritableAttr { let Spellings = [Clang<"unsafe_buffer_usage">]; let Subjects = SubjectList<[Function, Field]>; diff --git a/clang/include/clang/Basic/AttrDocs.td b/clang/include/clang/Basic/AttrDocs.td index 53d88482698f0..bf56fa6ad7162 100644 --- a/clang/include/clang/Basic/AttrDocs.td +++ b/clang/include/clang/Basic/AttrDocs.td @@ -6863,6 +6863,27 @@ attribute requires a string literal argument to identify the handle being releas }]; } +def zOSExportDocs : Documentation { + let Category = DocCatFunction; + let Content = [{ +Use the _Export keyword with a function name or external variable to declare +that it is to be exported (made available to other modules). You must define +the object name in the same translation unit in which you use the _Export +keyword. For example: + +.. code-block:: c + + int _Export anthony(float); + +This statement exports the function anthony, if you define the function in the +translation unit. The _Export keyword must immediately precede the object name. +If you apply the _Export keyword to a class, the compiler automatically exports +all static data members and member functions of the class. However, if you want +it to apply to individual class members, then you must apply it to each member +that can be referenced. + }]; +} + def UnsafeBufferUsageDocs : Documentation { let Category = DocCatFunction; let Content = [{ diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td index 64e6d0407b0ce..09842ed02efd4 100644 --- a/clang/inc
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
@@ -1273,6 +1273,168 @@ void Sema::AddImplicitMSFunctionNoBuiltinAttr(FunctionDecl *FD) { FD->addAttr(NoBuiltinAttr::CreateImplicit(Context, V.data(), V.size())); } +static bool typeListMatches(FunctionDecl *FD, +const clang::Sema::SymbolLabel &Label) { + assert(Label.TypeList.has_value()); + if (FD->getNumParams() != Label.TypeList->size()) { +return false; + } + + // Check if arguments match. + for (unsigned i = 0; i != FD->getNumParams(); ++i) { +const ParmVarDecl *PVD = FD->getParamDecl(i); +QualType ParmType = PVD->getOriginalType().getCanonicalType(); perry-ca wrote: @efriedma-quic I've found a problem related to this comment. If I have a pragma like: ```cpp void fd6(int (*)()) {} #pragma export (fd6(int (*)())) ``` I noticed that the type chain for the function arguments when I parse them on the pragma has the ParenType. eg: ``` PointerType 0xc7957d5eeb0 'int (*)(void)' `-ParenType 0xc7957d5ee80 'int (void)' sugar `-FunctionProtoType 0xc7957d5eb90 'int (void)' cdecl `-BuiltinType 0xc7957d2e570 'int' ``` This results in a type mismatch when I do the QualType compare in this code. Any idea on how to solve this? Thanks https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
@@ -1273,6 +1273,168 @@ void Sema::AddImplicitMSFunctionNoBuiltinAttr(FunctionDecl *FD) { FD->addAttr(NoBuiltinAttr::CreateImplicit(Context, V.data(), V.size())); } +static bool typeListMatches(FunctionDecl *FD, +const clang::Sema::SymbolLabel &Label) { + assert(Label.TypeList.has_value()); + if (FD->getNumParams() != Label.TypeList->size()) { +return false; + } + + // Check if arguments match. + for (unsigned i = 0; i != FD->getNumParams(); ++i) { +const ParmVarDecl *PVD = FD->getParamDecl(i); +QualType ParmType = PVD->getOriginalType().getCanonicalType(); perry-ca wrote: Good catch. This code does work for a case like: ``` void func(int []); #pragma export(func(int[])) ``` but not for: ``` void func(int []); #pragma export(func(int*)) ``` (or vice versa) The later case should work. I'll add code to use `getType()` and then to decay the types. https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
@@ -1906,6 +1906,36 @@ class Sema final : public SemaBase { ActOnPragmaMSFunction(SourceLocation Loc, const llvm::SmallVectorImpl &NoBuiltins); + /// A label from a C++ #pragma export, for a symbol that we + /// haven't seen the declaration for yet. The TypeList is the argument list + /// the function must match if HasTypeList is true. + struct SymbolLabel { +std::optional> TypeList; +StringRef MappedName; +SourceLocation NameLoc; +bool HasTypeList; +Qualifiers CVQual; + }; + + typedef SmallVector PendingSymbolOverloads; + typedef llvm::DenseMap + SymbolNames; + SymbolNames PendingExportNames; + + FunctionDecl *tryFunctionLookUp(NestedNameSpecifier *NestedName, + SourceLocation NameLoc); + + /// trySymbolLookUp try to look up a decl matching the nested specifier + /// with optional type list. + NamedDecl *trySymbolLookUp(NestedNameSpecifier *NestedName, perry-ca wrote: Sure. I'll pick a name the works with the other pragmas too. https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
@@ -1906,6 +1906,36 @@ class Sema final : public SemaBase { ActOnPragmaMSFunction(SourceLocation Loc, const llvm::SmallVectorImpl &NoBuiltins); + /// A label from a C++ #pragma export, for a symbol that we + /// haven't seen the declaration for yet. The TypeList is the argument list + /// the function must match if HasTypeList is true. + struct SymbolLabel { +std::optional> TypeList; +StringRef MappedName; +SourceLocation NameLoc; +bool HasTypeList; +Qualifiers CVQual; + }; + + typedef SmallVector PendingSymbolOverloads; + typedef llvm::DenseMap + SymbolNames; + SymbolNames PendingExportNames; + + FunctionDecl *tryFunctionLookUp(NestedNameSpecifier *NestedName, perry-ca wrote: This is used by another pragma I'm going to upstream next. This isn't used by pragma export but it is used by other pragmas we'll upstream after this one. I missed this when removing all of that code and can remove it for now if you wish. https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
@@ -5722,6 +5723,7 @@ TypeSourceInfo *Sema::GetTypeForDeclarator(Declarator &D) { TypeSourceInfo *ReturnTypeInfo = nullptr; QualType T = GetDeclSpecTypeForDeclarator(state, ReturnTypeInfo); + fprintf(stderr, "SDP: === GetTypeForDeclarator\n"); T->dump(); fprintf(stderr, "SDP: === GetTypeForDeclarator\n"); perry-ca wrote: yeah. I merged in the latest code and the PR got updated. I'll remove it. I'm sorting out a problem so not ready for a review again. I wish I could put the PR in draft mode. https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca edited https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [SystemZ][z/OS] Add visibility features for z/OS (eg. _Export, pragma export) (PR #111035)
https://github.com/perry-ca commented: @AaronBallman Thanks for the feedback. I'll make the changes and look into why _Exxport wasn't implemented like the other declspecs. I did consider these to be the same feature (two ways to set the same information). If it's easier for reviewing I can look into splitting the PR. https://github.com/llvm/llvm-project/pull/111035 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits