[clang] [CodeGen][KCFI] Fix asm comment style (PR #170739)
Kees Cook via cfe-commits
cfe-commits at lists.llvm.org
Thu Dec 4 12:39:53 PST 2025
https://github.com/kees created https://github.com/llvm/llvm-project/pull/170739
We can't use "#" in the middle of the asm output, so switch to a /* */ pair instead.
>From bf8fd89b98404b5ef5fcb1ee7065048ed2a8e822 Mon Sep 17 00:00:00 2001
From: Kees Cook <kees at kernel.org>
Date: Thu, 4 Dec 2025 12:06:37 -0800
Subject: [PATCH] [CodeGen][KCFI] Fix asm comment style
We can't use "#" in the middle of the asm output, so switch to a
/* */ pair instead.
---
clang/lib/CodeGen/CodeGenModule.cpp | 4 ++--
clang/test/CodeGen/cfi-salt.c | 4 ++--
clang/test/CodeGen/kcfi.c | 2 +-
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 319e10c93c517..1dcf94fc35e07 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -3212,8 +3212,8 @@ void CodeGenModule::finalizeKCFITypes() {
continue;
std::string Asm = (".weak __kcfi_typeid_" + Name + "\n.set __kcfi_typeid_" +
- Name + ", " + Twine(Type->getZExtValue()) + " # " +
- Twine(Type->getSExtValue()) + "\n")
+ Name + ", " + Twine(Type->getZExtValue()) + " /* " +
+ Twine(Type->getSExtValue()) + " */\n")
.str();
M.appendModuleInlineAsm(Asm);
}
diff --git a/clang/test/CodeGen/cfi-salt.c b/clang/test/CodeGen/cfi-salt.c
index 8363236869013..2a90dc31d939b 100644
--- a/clang/test/CodeGen/cfi-salt.c
+++ b/clang/test/CodeGen/cfi-salt.c
@@ -27,9 +27,9 @@ typedef unsigned int (* __cfi_salt ufn_salt_t)(void);
/// Must emit __kcfi_typeid symbols for address-taken function declarations
// CHECK: module asm ".weak __kcfi_typeid_[[F4:[a-zA-Z0-9_]+]]"
-// CHECK: module asm ".set __kcfi_typeid_[[F4]], {{[0-9]+}} # [[#%d,LOW_SODIUM_HASH:]]"
+// CHECK: module asm ".set __kcfi_typeid_[[F4]], {{[0-9]+}} /* [[#%d,LOW_SODIUM_HASH:]] */"
// CHECK: module asm ".weak __kcfi_typeid_[[F4_SALT:[a-zA-Z0-9_]+]]"
-// CHECK: module asm ".set __kcfi_typeid_[[F4_SALT]], {{[0-9]+}} # [[#%d,ASM_SALTY_HASH:]]"
+// CHECK: module asm ".set __kcfi_typeid_[[F4_SALT]], {{[0-9]+}} /* [[#%d,ASM_SALTY_HASH:]] */"
/// Must not __kcfi_typeid symbols for non-address-taken declarations
// CHECK-NOT: module asm ".weak __kcfi_typeid_f6"
diff --git a/clang/test/CodeGen/kcfi.c b/clang/test/CodeGen/kcfi.c
index b2856b5149be9..da32859dd3d88 100644
--- a/clang/test/CodeGen/kcfi.c
+++ b/clang/test/CodeGen/kcfi.c
@@ -7,7 +7,7 @@
/// Must emit __kcfi_typeid symbols for address-taken function declarations
// CHECK: module asm ".weak __kcfi_typeid_[[F4:[a-zA-Z0-9_]+]]"
-// CHECK: module asm ".set __kcfi_typeid_[[F4]], {{[0-9]+}} # [[#%d,HASH:]]"
+// CHECK: module asm ".set __kcfi_typeid_[[F4]], {{[0-9]+}} /* [[#%d,HASH:]] */"
/// Must not __kcfi_typeid symbols for non-address-taken declarations
// CHECK-NOT: module asm ".weak __kcfi_typeid_{{f6|_Z2f6v}}"
More information about the cfe-commits
mailing list