[clang] [PAC][clang] Fix ptrauth module flags behavior (PR #204226)

Anatoly Trosinenko via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 3 05:37:55 PDT 2026


================
@@ -1481,14 +1481,18 @@ void CodeGenModule::Release() {
     if (!LangOpts.isSignReturnAddressWithAKey())
       getModule().addModuleFlag(llvm::Module::Min,
                                 "sign-return-address-with-bkey", 2);
-
-    if (LangOpts.PointerAuthELFGOT)
-      getModule().addModuleFlag(llvm::Module::Error, "ptrauth-elf-got", 1);
+  }
+  if (T.isAArch64()) {
+    if (getTriple().isOSBinFormatELF())
+      getModule().addModuleFlag(
+          llvm::Module::Error, "ptrauth-elf-got",
+          static_cast<uint32_t>(LangOpts.PointerAuthELFGOT));
----------------
atrosinenko wrote:

I guess we might omit the `static_cast<uint32_t>(...)` conversion here for simplicity, as `LangOpts.PointerAuthELFGOT` is boolean-ish anyway (defined as having Bits == 1 in `LangOptions.def`). Literal zero could possibly be mistaken for `Metadata *Val` or `Constant *Val` by other overloads of `addModuleFlag`, but we have unsigned integer _variable_ here, so this shouldn't be a problem, I guess.

https://github.com/llvm/llvm-project/pull/204226


More information about the cfe-commits mailing list