llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Abhina Sree (abhina-sree) <details> <summary>Changes</summary> The zos_translation_time flag needs to be 64-bit to handle the year 2038 problem. --- Full diff: https://github.com/llvm/llvm-project/pull/210058.diff 4 Files Affected: - (modified) clang/lib/CodeGen/CodeGenModule.cpp (+4-3) - (added) clang/test/CodeGen/SystemZ/systemz-module.flags.c (+3) - (modified) llvm/include/llvm/IR/Module.h (+8) - (modified) llvm/lib/IR/Module.cpp (+10) ``````````diff 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/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 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); `````````` </details> https://github.com/llvm/llvm-project/pull/210058 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
