[clang] 62a932a - [SystemZ][z/OS] Fix zos_translation_time module flag (#210058)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 17 05:10:16 PDT 2026
Author: Abhina Sree
Date: 2026-07-17T08:10:10-04:00
New Revision: 62a932ac3e2702a5493934c6362f9e058a204557
URL: https://github.com/llvm/llvm-project/commit/62a932ac3e2702a5493934c6362f9e058a204557
DIFF: https://github.com/llvm/llvm-project/commit/62a932ac3e2702a5493934c6362f9e058a204557.diff
LOG: [SystemZ][z/OS] Fix zos_translation_time module flag (#210058)
The zos_translation_time flag needs to be 64-bit to handle the year 2038
problem.
Added:
clang/test/CodeGen/SystemZ/systemz-module.flags.c
Modified:
clang/lib/CodeGen/CodeGenModule.cpp
llvm/include/llvm/IR/Module.h
llvm/lib/IR/Module.cpp
Removed:
################################################################################
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index ca71458d85134..d1119e6c00d14 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1356,7 +1356,8 @@ void CodeGenModule::Release() {
uint64_t WCharWidth =
Context.getTypeSizeInChars(Context.getWideCharType()).getQuantity();
if (WCharWidth != getTriple().getDefaultWCharSize())
- getModule().addModuleFlag(llvm::Module::Error, "wchar_size", WCharWidth);
+ getModule().addModuleFlag(llvm::Module::Error, "wchar_size",
+ static_cast<uint32_t>(WCharWidth));
if (getTriple().isOSzOS()) {
getModule().addModuleFlag(llvm::Module::Warning,
@@ -1391,7 +1392,7 @@ void CodeGenModule::Release() {
llvm::Triple T = Context.getTargetInfo().getTriple();
if (T.isARM() || T.isThumb()) {
// The minimum width of an enum in bytes
- uint64_t EnumWidth = Context.getLangOpts().ShortEnums ? 1 : 4;
+ uint32_t EnumWidth = Context.getLangOpts().ShortEnums ? 1 : 4;
getModule().addModuleFlag(llvm::Module::Error, "min_enum_size", EnumWidth);
}
@@ -1558,7 +1559,8 @@ void CodeGenModule::Release() {
assert(getTriple().isOSBinFormatELF());
using namespace llvm::ELF;
- uint64_t PAuthABIVersion =
+ assert(AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_LAST < 32);
+ uint32_t PAuthABIVersion =
(LangOpts.PointerAuthIntrinsics
<< AARCH64_PAUTH_PLATFORM_LLVM_LINUX_VERSION_INTRINSICS) |
(LangOpts.PointerAuthCalls
diff --git a/clang/test/CodeGen/SystemZ/systemz-module.flags.c b/clang/test/CodeGen/SystemZ/systemz-module.flags.c
new file mode 100644
index 0000000000000..261dec81a4d52
--- /dev/null
+++ b/clang/test/CodeGen/SystemZ/systemz-module.flags.c
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -source-date-epoch 253402300799 -triple s390x-ibm-zos -emit-llvm -o - %s | FileCheck %s
+// CHECK: {{.*}}"zos_cu_language", !"C"}
+// CHECK: {{.*}}"zos_translation_time", i64 253402300799}
diff --git a/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 3c6c2ccbdccc8..cfc6b34ced5ce 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -603,12 +603,20 @@ class LLVM_ABI Module {
/// the module-level flags named metadata if it doesn't already exist.
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val);
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, Constant *Val);
+ void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint64_t Val);
void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
+ inline void addModuleFlag(ModFlagBehavior Behavior, StringRef Key, int Val) {
+ addModuleFlag(Behavior, Key, static_cast<uint32_t>(Val));
+ }
void addModuleFlag(MDNode *Node);
/// Like addModuleFlag but replaces the old module flag if it already exists.
void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Metadata *Val);
void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, Constant *Val);
+ void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint64_t Val);
void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, uint32_t Val);
+ inline void setModuleFlag(ModFlagBehavior Behavior, StringRef Key, int Val) {
+ setModuleFlag(Behavior, Key, static_cast<uint32_t>(Val));
+ }
/// @}
/// @name Materialization
diff --git a/llvm/lib/IR/Module.cpp b/llvm/lib/IR/Module.cpp
index 34e44e26d5db5..a4a32613e6312 100644
--- a/llvm/lib/IR/Module.cpp
+++ b/llvm/lib/IR/Module.cpp
@@ -390,6 +390,11 @@ void Module::addModuleFlag(ModFlagBehavior Behavior, StringRef Key,
Constant *Val) {
addModuleFlag(Behavior, Key, ConstantAsMetadata::get(Val));
}
+void Module::addModuleFlag(ModFlagBehavior Behavior, StringRef Key,
+ uint64_t Val) {
+ Type *Int64Ty = Type::getInt64Ty(Context);
+ addModuleFlag(Behavior, Key, ConstantInt::get(Int64Ty, Val));
+}
void Module::addModuleFlag(ModFlagBehavior Behavior, StringRef Key,
uint32_t Val) {
Type *Int32Ty = Type::getInt32Ty(Context);
@@ -425,6 +430,11 @@ void Module::setModuleFlag(ModFlagBehavior Behavior, StringRef Key,
Constant *Val) {
setModuleFlag(Behavior, Key, ConstantAsMetadata::get(Val));
}
+void Module::setModuleFlag(ModFlagBehavior Behavior, StringRef Key,
+ uint64_t Val) {
+ Type *Int64Ty = Type::getInt64Ty(Context);
+ setModuleFlag(Behavior, Key, ConstantInt::get(Int64Ty, Val));
+}
void Module::setModuleFlag(ModFlagBehavior Behavior, StringRef Key,
uint32_t Val) {
Type *Int32Ty = Type::getInt32Ty(Context);
More information about the cfe-commits
mailing list