https://github.com/abhina-sree created 
https://github.com/llvm/llvm-project/pull/210058

The zos_translation_time flag needs to be 64-bit to handle the year 2038 
problem.

>From 05f425a7ff413753048e604b9c149bbd1c570f6d Mon Sep 17 00:00:00 2001
From: Abhina Sreeskantharajan <[email protected]>
Date: Thu, 25 Jun 2026 08:23:36 -0400
Subject: [PATCH 1/2] changes

---
 clang/lib/CodeGen/CodeGenModule.cpp |  7 ++++---
 llvm/include/llvm/IR/Module.h       |  8 ++++++++
 llvm/lib/IR/Module.cpp              | 10 ++++++++++
 3 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index fec18acd46998..e87398d834aa3 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -1300,7 +1300,7 @@ 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,
@@ -1335,7 +1335,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);
   }
 
@@ -1491,7 +1491,8 @@ void CodeGenModule::Release() {
                                   "ptrauth-sign-personality", 1);
       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/llvm/include/llvm/IR/Module.h b/llvm/include/llvm/IR/Module.h
index 4f7e33969f16f..223834ffce81e 100644
--- a/llvm/include/llvm/IR/Module.h
+++ b/llvm/include/llvm/IR/Module.h
@@ -529,12 +529,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 40ef7e354da72..553894fda4106 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);

>From 8e9cbe2efca8627f049851f2468dca3cb9b68c8d Mon Sep 17 00:00:00 2001
From: Abhina Sreeskantharajan <[email protected]>
Date: Thu, 16 Jul 2026 09:32:47 -0400
Subject: [PATCH 2/2] add testcase

---
 clang/test/CodeGen/SystemZ/systemz-module.flags.c | 3 +++
 1 file changed, 3 insertions(+)
 create mode 100644 clang/test/CodeGen/SystemZ/systemz-module.flags.c

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}

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

Reply via email to