[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)

via cfe-commits cfe-commits at lists.llvm.org
Tue Sep 17 20:44:14 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Ming-Yi Lai (mylai-mtk)

<details>
<summary>Changes</summary>

According to the comments in <https://reviews.llvm.org/D119296>, which introduces the KCFI sanitizer, the data structures of KCFI should avoid embedding the term "kcfi" in their names so that later/new CFI mechanisms can make use of the data structures, however, those "kcfi" were not removed completely. This patch further removes those "kcfi" terms from the Function metadata !kcfi_type so that the RISC-V Zicfilp extension code generation can reuse the same data path as the KCFI sanitizer to pass function-specific CFI labels.

---

Patch is 28.96 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/109080.diff


28 Files Affected:

- (modified) clang/lib/CodeGen/CodeGenModule.cpp (+8-8) 
- (modified) clang/lib/CodeGen/CodeGenModule.h (+3-3) 
- (modified) clang/test/CodeGen/kcfi-normalize.c (+3-3) 
- (modified) clang/test/CodeGen/kcfi.c (+10-10) 
- (modified) llvm/docs/LangRef.rst (+6-6) 
- (modified) llvm/include/llvm/IR/FixedMetadataKinds.def (+1-1) 
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+1-1) 
- (modified) llvm/lib/CodeGen/MachineFunction.cpp (+2-1) 
- (modified) llvm/lib/IR/Verifier.cpp (+11-12) 
- (modified) llvm/lib/Target/X86/X86AsmPrinter.cpp (+1-1) 
- (modified) llvm/lib/Transforms/IPO/MergeFunctions.cpp (+2-2) 
- (modified) llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp (+2-2) 
- (modified) llvm/lib/Transforms/Utils/ModuleUtils.cpp (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/kcfi-bti.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/kcfi-patchable-function-prefix.ll (+2-2) 
- (modified) llvm/test/CodeGen/AArch64/kcfi.ll (+1-1) 
- (modified) llvm/test/CodeGen/ARM/kcfi.ll (+1-1) 
- (modified) llvm/test/CodeGen/RISCV/kcfi-isel-mir.ll (+1-1) 
- (modified) llvm/test/CodeGen/RISCV/kcfi-mir.ll (+1-1) 
- (modified) llvm/test/CodeGen/RISCV/kcfi-patchable-function-prefix.ll (+2-2) 
- (modified) llvm/test/CodeGen/RISCV/kcfi.ll (+1-1) 
- (modified) llvm/test/CodeGen/X86/kcfi-patchable-function-prefix.ll (+2-2) 
- (modified) llvm/test/CodeGen/X86/kcfi.ll (+3-3) 
- (modified) llvm/test/Instrumentation/AddressSanitizer/kcfi-offset.ll (+1-1) 
- (modified) llvm/test/Instrumentation/AddressSanitizer/kcfi.ll (+2-2) 
- (modified) llvm/test/Transforms/GCOVProfiling/kcfi-normalize.ll (+4-4) 
- (modified) llvm/test/Transforms/GCOVProfiling/kcfi.ll (+4-4) 
- (modified) llvm/test/Verifier/metadata-function-kcfi-type.ll (+11-11) 


``````````diff
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index 17b82b205063d4..561673ab960b31 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -910,7 +910,7 @@ void CodeGenModule::Release() {
     CodeGenFunction(*this).EmitCfiCheckStub();
   }
   if (LangOpts.Sanitize.has(SanitizerKind::KCFI))
-    finalizeKCFITypes();
+    finalizeCFITypes();
   emitAtAvailableLinkGuard();
   if (Context.getTargetInfo().getTriple().isWasm())
     EmitMainVoidAlias();
@@ -2818,10 +2818,10 @@ void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
       F->addTypeMetadata(0, llvm::ConstantAsMetadata::get(CrossDsoTypeId));
 }
 
-void CodeGenModule::setKCFIType(const FunctionDecl *FD, llvm::Function *F) {
+void CodeGenModule::setCFIType(const FunctionDecl *FD, llvm::Function *F) {
   llvm::LLVMContext &Ctx = F->getContext();
   llvm::MDBuilder MDB(Ctx);
-  F->setMetadata(llvm::LLVMContext::MD_kcfi_type,
+  F->setMetadata(llvm::LLVMContext::MD_cfi_type,
                  llvm::MDNode::get(
                      Ctx, MDB.createConstant(CreateKCFITypeId(FD->getType()))));
 }
@@ -2835,13 +2835,13 @@ static bool allowKCFIIdentifier(StringRef Name) {
   });
 }
 
-void CodeGenModule::finalizeKCFITypes() {
+void CodeGenModule::finalizeCFITypes() {
   llvm::Module &M = getModule();
   for (auto &F : M.functions()) {
-    // Remove KCFI type metadata from non-address-taken local functions.
+    // Remove CFI type metadata from non-address-taken local functions.
     bool AddressTaken = F.hasAddressTaken();
     if (!AddressTaken && F.hasLocalLinkage())
-      F.eraseMetadata(llvm::LLVMContext::MD_kcfi_type);
+      F.eraseMetadata(llvm::LLVMContext::MD_cfi_type);
 
     // Generate a constant with the expected KCFI type identifier for all
     // address-taken function declarations to support annotating indirectly
@@ -2850,7 +2850,7 @@ void CodeGenModule::finalizeKCFITypes() {
       continue;
 
     const llvm::ConstantInt *Type;
-    if (const llvm::MDNode *MD = F.getMetadata(llvm::LLVMContext::MD_kcfi_type))
+    if (const llvm::MDNode *MD = F.getMetadata(llvm::LLVMContext::MD_cfi_type))
       Type = llvm::mdconst::extract<llvm::ConstantInt>(MD->getOperand(0));
     else
       continue;
@@ -2949,7 +2949,7 @@ void CodeGenModule::SetFunctionAttributes(GlobalDecl GD, llvm::Function *F,
     CreateFunctionTypeMetadataForIcall(FD, F);
 
   if (LangOpts.Sanitize.has(SanitizerKind::KCFI))
-    setKCFIType(FD, F);
+    setCFIType(FD, F);
 
   if (getLangOpts().OpenMP && FD->hasAttr<OMPDeclareSimdDeclAttr>())
     getOpenMPRuntime().emitDeclareSimdFunction(FD, F);
diff --git a/clang/lib/CodeGen/CodeGenModule.h b/clang/lib/CodeGen/CodeGenModule.h
index c58bb88035ca8a..0ebcf7dfba6b28 100644
--- a/clang/lib/CodeGen/CodeGenModule.h
+++ b/clang/lib/CodeGen/CodeGenModule.h
@@ -1554,10 +1554,10 @@ class CodeGenModule : public CodeGenTypeCache {
                                           llvm::Function *F);
 
   /// Set type metadata to the given function.
-  void setKCFIType(const FunctionDecl *FD, llvm::Function *F);
+  void setCFIType(const FunctionDecl *FD, llvm::Function *F);
 
-  /// Emit KCFI type identifier constants and remove unused identifiers.
-  void finalizeKCFITypes();
+  /// Emit CFI type identifier constants and remove unused identifiers.
+  void finalizeCFITypes();
 
   /// Whether this function's return type has no side effects, and thus may
   /// be trivially discarded if it is unused.
diff --git a/clang/test/CodeGen/kcfi-normalize.c b/clang/test/CodeGen/kcfi-normalize.c
index b9150e88f6ab5f..5fa0732c72eb26 100644
--- a/clang/test/CodeGen/kcfi-normalize.c
+++ b/clang/test/CodeGen/kcfi-normalize.c
@@ -9,21 +9,21 @@
 
 void foo(void (*fn)(int), int arg) {
     // CHECK-LABEL: define{{.*}}foo
-    // CHECK-SAME: {{.*}}!kcfi_type ![[TYPE1:[0-9]+]]
+    // CHECK-SAME: {{.*}}!cfi_type ![[TYPE1:[0-9]+]]
     // CHECK: call void %0(i32 noundef %1){{.*}}[ "kcfi"(i32 1162514891) ]
     fn(arg);
 }
 
 void bar(void (*fn)(int, int), int arg1, int arg2) {
     // CHECK-LABEL: define{{.*}}bar
-    // CHECK-SAME: {{.*}}!kcfi_type ![[TYPE2:[0-9]+]]
+    // CHECK-SAME: {{.*}}!cfi_type ![[TYPE2:[0-9]+]]
     // CHECK: call void %0(i32 noundef %1, i32 noundef %2){{.*}}[ "kcfi"(i32 448046469) ]
     fn(arg1, arg2);
 }
 
 void baz(void (*fn)(int, int, int), int arg1, int arg2, int arg3) {
     // CHECK-LABEL: define{{.*}}baz
-    // CHECK-SAME: {{.*}}!kcfi_type ![[TYPE3:[0-9]+]]
+    // CHECK-SAME: {{.*}}!cfi_type ![[TYPE3:[0-9]+]]
     // CHECK: call void %0(i32 noundef %1, i32 noundef %2, i32 noundef %3){{.*}}[ "kcfi"(i32 -2049681433) ]
     fn(arg1, arg2, arg3);
 }
diff --git a/clang/test/CodeGen/kcfi.c b/clang/test/CodeGen/kcfi.c
index 622843cedba50f..e5c7a49b0665b7 100644
--- a/clang/test/CodeGen/kcfi.c
+++ b/clang/test/CodeGen/kcfi.c
@@ -15,10 +15,10 @@
 // C: @ifunc2 = ifunc i64 (i64), ptr @resolver2
 typedef int (*fn_t)(void);
 
-// CHECK: define dso_local{{.*}} i32 @{{f1|_Z2f1v}}(){{.*}} !kcfi_type ![[#TYPE:]]
+// CHECK: define dso_local{{.*}} i32 @{{f1|_Z2f1v}}(){{.*}} !cfi_type ![[#TYPE:]]
 int f1(void) { return 0; }
 
-// CHECK: define dso_local{{.*}} i32 @{{f2|_Z2f2v}}(){{.*}} !kcfi_type ![[#TYPE2:]]
+// CHECK: define dso_local{{.*}} i32 @{{f2|_Z2f2v}}(){{.*}} !cfi_type ![[#TYPE2:]]
 unsigned int f2(void) { return 2; }
 
 // CHECK-LABEL: define dso_local{{.*}} i32 @{{__call|_Z6__callPFivE}}(ptr{{.*}} %f)
@@ -33,27 +33,27 @@ int call(fn_t f) {
   return f();
 }
 
-// CHECK-DAG: define internal{{.*}} i32 @{{f3|_ZL2f3v}}(){{.*}} !kcfi_type ![[#TYPE]]
+// CHECK-DAG: define internal{{.*}} i32 @{{f3|_ZL2f3v}}(){{.*}} !cfi_type ![[#TYPE]]
 static int f3(void) { return 1; }
 
-// CHECK-DAG: declare !kcfi_type ![[#TYPE]]{{.*}} i32 @[[F4]]()
+// CHECK-DAG: declare !cfi_type ![[#TYPE]]{{.*}} i32 @[[F4]]()
 extern int f4(void);
 
-/// Must not emit !kcfi_type for non-address-taken local functions
+/// Must not emit !cfi_type for non-address-taken local functions
 // CHECK: define internal{{.*}} i32 @{{f5|_ZL2f5v}}()
-// CHECK-NOT: !kcfi_type
+// CHECK-NOT: !cfi_type
 // CHECK-SAME: {
 static int f5(void) { return 2; }
 
-// CHECK-DAG: declare !kcfi_type ![[#TYPE]]{{.*}} i32 @{{f6|_Z2f6v}}()
+// CHECK-DAG: declare !cfi_type ![[#TYPE]]{{.*}} i32 @{{f6|_Z2f6v}}()
 extern int f6(void);
 
 #ifndef __cplusplus
-// C: define internal ptr @resolver1() #[[#]] !kcfi_type ![[#]] {
+// C: define internal ptr @resolver1() #[[#]] !cfi_type ![[#]] {
 int ifunc1(int) __attribute__((ifunc("resolver1")));
 static void *resolver1(void) { return 0; }
 
-// C: define internal ptr @resolver2() #[[#]] !kcfi_type ![[#]] {
+// C: define internal ptr @resolver2() #[[#]] !cfi_type ![[#]] {
 static void *resolver2(void) { return 0; }
 long ifunc2(long) __attribute__((ifunc("resolver2")));
 #endif
@@ -69,7 +69,7 @@ int test(void) {
 
 #ifdef __cplusplus
 struct A {
-  // MEMBER-DAG: define{{.*}} void @_ZN1A1fEv(ptr{{.*}} %this){{.*}} !kcfi_type ![[#TYPE3:]]
+  // MEMBER-DAG: define{{.*}} void @_ZN1A1fEv(ptr{{.*}} %this){{.*}} !cfi_type ![[#TYPE3:]]
   void f() {}
 };
 
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index 144b4497ca63ce..3077329eda33da 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -2960,7 +2960,7 @@ KCFI Operand Bundles
 
 A ``"kcfi"`` operand bundle on an indirect call indicates that the call will
 be preceded by a runtime type check, which validates that the call target is
-prefixed with a :ref:`type identifier<md_kcfi_type>` that matches the operand
+prefixed with a :ref:`type identifier<md_cfi_type>` that matches the operand
 bundle attribute. For example:
 
 .. code-block:: llvm
@@ -7932,12 +7932,12 @@ Example:
     }
     !0 = !{i32 846595819, ptr @__llvm_rtti_proxy}
 
-.. _md_kcfi_type:
+.. _md_cfi_type:
 
-'``kcfi_type``' Metadata
+'``cfi_type``' Metadata
 ^^^^^^^^^^^^^^^^^^^^^^^^
 
-The ``kcfi_type`` metadata can be used to attach a type identifier to
+The ``cfi_type`` metadata can be used to attach a type identifier to
 functions that can be called indirectly. The type data is emitted before the
 function entry in the assembly. Indirect calls with the :ref:`kcfi operand
 bundle<ob_kcfi>` will emit a check that compares the type identifier to the
@@ -7947,12 +7947,12 @@ Example:
 
 .. code-block:: text
 
-    define dso_local i32 @f() !kcfi_type !0 {
+    define dso_local i32 @f() !cfi_type !0 {
       ret i32 0
     }
     !0 = !{i32 12345678}
 
-Clang emits ``kcfi_type`` metadata nodes for address-taken functions with
+Clang emits ``cfi_type`` metadata nodes for address-taken functions with
 ``-fsanitize=kcfi``.
 
 .. _md_memprof:
diff --git a/llvm/include/llvm/IR/FixedMetadataKinds.def b/llvm/include/llvm/IR/FixedMetadataKinds.def
index 5f4cc230a0f5ff..007cf9a38ccc80 100644
--- a/llvm/include/llvm/IR/FixedMetadataKinds.def
+++ b/llvm/include/llvm/IR/FixedMetadataKinds.def
@@ -47,7 +47,7 @@ LLVM_FIXED_MD_KIND(MD_func_sanitize, "func_sanitize", 32)
 LLVM_FIXED_MD_KIND(MD_exclude, "exclude", 33)
 LLVM_FIXED_MD_KIND(MD_memprof, "memprof", 34)
 LLVM_FIXED_MD_KIND(MD_callsite, "callsite", 35)
-LLVM_FIXED_MD_KIND(MD_kcfi_type, "kcfi_type", 36)
+LLVM_FIXED_MD_KIND(MD_cfi_type, "cfi_type", 36)
 LLVM_FIXED_MD_KIND(MD_pcsections, "pcsections", 37)
 LLVM_FIXED_MD_KIND(MD_DIAssignID, "DIAssignID", 38)
 LLVM_FIXED_MD_KIND(MD_coro_outside_frame, "coro.outside.frame", 39)
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index db7adfd3b21e5f..a51c859f665af5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1512,7 +1512,7 @@ void AsmPrinter::emitKCFITrapEntry(const MachineFunction &MF,
 
 void AsmPrinter::emitKCFITypeId(const MachineFunction &MF) {
   const Function &F = MF.getFunction();
-  if (const MDNode *MD = F.getMetadata(LLVMContext::MD_kcfi_type))
+  if (const MDNode *MD = F.getMetadata(LLVMContext::MD_cfi_type))
     emitGlobalConstant(F.getDataLayout(),
                        mdconst::extract<ConstantInt>(MD->getOperand(0)));
 }
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index ab45663436cedc..4193ce5730c28f 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -225,7 +225,8 @@ void MachineFunction::init() {
   // by a least 4 to avoid unaligned access, which is especially important for
   // -mno-unaligned-access.
   if (F.hasMetadata(LLVMContext::MD_func_sanitize) ||
-      F.getMetadata(LLVMContext::MD_kcfi_type))
+      (F.getParent()->getModuleFlag("kcfi") &&
+       F.getMetadata(LLVMContext::MD_cfi_type)))
     Alignment = std::max(Alignment, Align(4));
 
   if (AlignAllFunctions)
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index 06a67346fbf959..1c0ceb9e12fbfc 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -2413,19 +2413,19 @@ void Verifier::verifyFunctionMetadata(
             MD);
       Check(isa<ConstantAsMetadata>(MD->getOperand(1)),
             "expected integer argument to function_entry_count", MD);
-    } else if (Pair.first == LLVMContext::MD_kcfi_type) {
+    } else if (Pair.first == LLVMContext::MD_cfi_type) {
       MDNode *MD = Pair.second;
       Check(MD->getNumOperands() == 1,
-            "!kcfi_type must have exactly one operand", MD);
-      Check(MD->getOperand(0) != nullptr, "!kcfi_type operand must not be null",
+            "!cfi_type must have exactly one operand", MD);
+      Check(MD->getOperand(0) != nullptr, "!cfi_type operand must not be null",
             MD);
       Check(isa<ConstantAsMetadata>(MD->getOperand(0)),
-            "expected a constant operand for !kcfi_type", MD);
+            "expected a constant operand for !cfi_type", MD);
       Constant *C = cast<ConstantAsMetadata>(MD->getOperand(0))->getValue();
       Check(isa<ConstantInt>(C) && isa<IntegerType>(C->getType()),
-            "expected a constant integer operand for !kcfi_type", MD);
+            "expected a constant integer operand for !cfi_type", MD);
       Check(cast<ConstantInt>(C)->getBitWidth() == 32,
-            "expected a 32-bit integer constant operand for !kcfi_type", MD);
+            "expected a 32-bit integer constant operand for !cfi_type", MD);
     }
   }
 }
@@ -2927,7 +2927,7 @@ void Verifier::visitFunction(const Function &F) {
     }
 
     unsigned NumDebugAttachments = 0, NumProfAttachments = 0,
-             NumKCFIAttachments = 0;
+             NumCFIAttachments = 0;
     // Visit metadata attachments.
     for (const auto &I : MDs) {
       // Verify that the attachment is legal.
@@ -2958,11 +2958,10 @@ void Verifier::visitFunction(const Function &F) {
         Check(NumProfAttachments == 1,
               "function must have a single !prof attachment", &F, I.second);
         break;
-      case LLVMContext::MD_kcfi_type:
-        ++NumKCFIAttachments;
-        Check(NumKCFIAttachments == 1,
-              "function must have a single !kcfi_type attachment", &F,
-              I.second);
+      case LLVMContext::MD_cfi_type:
+        ++NumCFIAttachments;
+        Check(NumCFIAttachments == 1,
+              "function must have a single !cfi_type attachment", &F, I.second);
         break;
       }
 
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index 957eb21cf4f8c3..83979f28844921 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -158,7 +158,7 @@ void X86AsmPrinter::emitKCFITypeId(const MachineFunction &MF) {
     return;
 
   ConstantInt *Type = nullptr;
-  if (const MDNode *MD = F.getMetadata(LLVMContext::MD_kcfi_type))
+  if (const MDNode *MD = F.getMetadata(LLVMContext::MD_cfi_type))
     Type = mdconst::extract<ConstantInt>(MD->getOperand(0));
 
   // If we don't have a type to emit, just emit padding if needed to maintain
diff --git a/llvm/lib/Transforms/IPO/MergeFunctions.cpp b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
index b50a700e09038f..a396b70ca29c50 100644
--- a/llvm/lib/Transforms/IPO/MergeFunctions.cpp
+++ b/llvm/lib/Transforms/IPO/MergeFunctions.cpp
@@ -803,7 +803,7 @@ void MergeFunctions::writeThunk(Function *F, Function *G) {
     NewG->takeName(G);
     // Ensure CFI type metadata is propagated to the new function.
     copyMetadataIfPresent(G, NewG, "type");
-    copyMetadataIfPresent(G, NewG, "kcfi_type");
+    copyMetadataIfPresent(G, NewG, "cfi_type");
     removeUsers(G);
     G->replaceAllUsesWith(NewG);
     G->eraseFromParent();
@@ -882,7 +882,7 @@ void MergeFunctions::mergeTwoFunctions(Function *F, Function *G) {
     NewF->IsNewDbgInfoFormat = F->IsNewDbgInfoFormat;
     // Ensure CFI type metadata is propagated to the new function.
     copyMetadataIfPresent(F, NewF, "type");
-    copyMetadataIfPresent(F, NewF, "kcfi_type");
+    copyMetadataIfPresent(F, NewF, "cfi_type");
     removeUsers(F);
     F->replaceAllUsesWith(NewF);
 
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
index 61011d55227e7b..86abd753cd7d0e 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -3982,13 +3982,13 @@ Instruction *InstCombinerImpl::visitCallBase(CallBase &Call) {
         ConstantInt *FunctionType = nullptr;
         ConstantInt *ExpectedType = cast<ConstantInt>(Bundle->Inputs[0]);
 
-        if (MDNode *MD = CalleeF->getMetadata(LLVMContext::MD_kcfi_type))
+        if (MDNode *MD = CalleeF->getMetadata(LLVMContext::MD_cfi_type))
           FunctionType = mdconst::extract<ConstantInt>(MD->getOperand(0));
 
         if (FunctionType &&
             FunctionType->getZExtValue() != ExpectedType->getZExtValue())
           dbgs() << Call.getModule()->getName()
-                 << ": warning: kcfi: " << Call.getCaller()->getName()
+                 << ": warning: cfi: " << Call.getCaller()->getName()
                  << ": call to " << CalleeF->getName()
                  << " using a mismatching function pointer type\n";
       }
diff --git a/llvm/lib/Transforms/Utils/ModuleUtils.cpp b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
index 7249571f344938..93fcec091d640e 100644
--- a/llvm/lib/Transforms/Utils/ModuleUtils.cpp
+++ b/llvm/lib/Transforms/Utils/ModuleUtils.cpp
@@ -208,7 +208,7 @@ void llvm::setKCFIType(Module &M, Function &F, StringRef MangledType) {
   std::string Type = MangledType.str();
   if (M.getModuleFlag("cfi-normalize-integers"))
     Type += ".normalized";
-  F.setMetadata(LLVMContext::MD_kcfi_type,
+  F.setMetadata(LLVMContext::MD_cfi_type,
                 MDNode::get(Ctx, MDB.createConstant(ConstantInt::get(
                                      Type::getInt32Ty(Ctx),
                                      static_cast<uint32_t>(xxHash64(Type))))));
diff --git a/llvm/test/CodeGen/AArch64/kcfi-bti.ll b/llvm/test/CodeGen/AArch64/kcfi-bti.ll
index 1ac894fa09015b..a6e29ba3651b7f 100644
--- a/llvm/test/CodeGen/AArch64/kcfi-bti.ll
+++ b/llvm/test/CodeGen/AArch64/kcfi-bti.ll
@@ -3,7 +3,7 @@
 ; RUN: llc -mtriple=aarch64-- -verify-machineinstrs -stop-after=kcfi < %s | FileCheck %s --check-prefixes=MIR,KCFI
 
 ; ASM:       .word 12345678
-define void @f1(ptr noundef %x) #1 !kcfi_type !2 {
+define void @f1(ptr noundef %x) #1 !cfi_type !2 {
 ; ASM-LABEL: f1:
 ; ASM:       // %bb.0:
 ; ASM:         ldur w16, [x0, #-4]
@@ -30,7 +30,7 @@ define void @f1(ptr noundef %x) #1 !kcfi_type !2 {
 }
 
 ; ASM:       .word 12345678
-define void @f2(ptr noundef %x)  #1 !kcfi_type !2 {
+define void @f2(ptr noundef %x)  #1 !cfi_type !2 {
 ; ASM-LABEL: f2:
 ; ASM:       // %bb.0:
 ; ASM:         ldur w16, [x0, #-4]
diff --git a/llvm/test/CodeGen/AArch64/kcfi-patchable-function-prefix.ll b/llvm/test/CodeGen/AArch64/kcfi-patchable-function-prefix.ll
index e5cf0d6200475c..6f10436832882b 100644
--- a/llvm/test/CodeGen/AArch64/kcfi-patchable-function-prefix.ll
+++ b/llvm/test/CodeGen/AArch64/kcfi-patchable-function-prefix.ll
@@ -4,7 +4,7 @@
 ; CHECK-NOT:        nop
 ; CHECK:          .word   12345678
 ; CHECK-LABEL:    f1:
-define void @f1(ptr noundef %x) !kcfi_type !1 {
+define void @f1(ptr noundef %x) !cfi_type !1 {
 ; CHECK:            ldur    w16, [x0, #-4]
   call void %x() [ "kcfi"(i32 12345678) ]
   ret void
@@ -24,7 +24,7 @@ define void @f2(ptr noundef %x) {
 ; CHECK:          .word   12345678
 ; CHECK-COUNT-11:   nop
 ; CHECK-LABEL:    f3:
-define void @f3(ptr noundef %x) #0 !kcfi_type !1 {
+define void @f3(ptr noundef %x) #0 !cfi_type !1 {
 ; CHECK:            ldur    w16, [x0, #-48]
   call void %x() [ "kcfi"(i32 12345678) ]
   ret void
diff --git a/llvm/test/CodeGen/AArch64/kcfi.ll b/llvm/test/CodeGen/AArch64/kcfi.ll
index 7c824c19ee69ad..62ac11c884c286 100644
--- a/llvm/test/CodeGen/AArch64/kcfi.ll
+++ b/llvm/test/CodeGen/AArch64/kcfi.ll
@@ -11,7 +11,7 @@
 ; RUN: llc -mtriple=aarch64-- -verify-machineinstrs -mattr=harden-sls-blr -stop-after=kcfi < %s | FileCheck %s --check-prefixes=MIR,KCFI-SLS
 
 ; ASM:       .word 12345678
-define void @f1(ptr noundef %x) !kcfi_type !1 {
+define void @f1(ptr noundef %x) !cfi_type !1 {
 ; ASM-LABEL: f1:
 ; ASM:       // %bb.0:
 ; ASM:         ldur w16, [x0, #-4]
diff --git a/llvm/test/CodeGen/ARM/kcfi.ll b/llvm/test/CodeGen/ARM/kcfi.ll
index 9e16468c9347b9..6897bf968917e7 100644
--- a/llvm/test/CodeGen/ARM/kcfi.ll
+++ b/llvm/test/CodeGen/ARM/kcfi.ll
@@ -19,7 +19,7 @@ define dso_local void @nosan() nounwind {
 ; CHECK-NEXT:  .code 16
 ; CHECK-NEXT:  .thumb_func
 ; CHECK-NEXT:  f1:
-define void @f1(ptr noundef %x) !kcfi_type !1 {
+define void @f1(ptr noundef %x) !cfi_type !1 {
   ret void
 }
 
diff --git a/llvm/test/CodeGen/RISCV/kcfi-isel-mir.ll b/llvm/test/CodeGen/RISCV/kcfi-isel-mir.ll
index 4c47b5f741fa67..0bc4085a7da206 100644
--- a/llvm/test/CodeGen/RISCV/kcfi-isel-mir.ll
+++ b/llvm/test/CodeGen/RISCV/kcfi-isel-mir.ll
@@ -1,6 +1,6 @@
 ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
 ; RUN: llc -mtriple=riscv64 -stop-after=finalize-isel -verify-machineinstrs -o - %s | FileCheck %s
-define void @f1(ptr noundef %x) !kcfi_type !1 {
+define void @f1(ptr noundef %x) !cfi_type !1 {
   ; CHECK-LABEL: name: f1
   ; CHECK: bb.0 (%ir-block.0):
   ; CHECK-NEXT:   liveins: $x10
diff --git a/llvm/test/CodeGen/RISCV/kcfi-mir.ll b/llvm/test/CodeGen/RISCV/kcfi-mir.ll
index 9d8475e2171eaa..9a1a5d6df4b74f 100644
--...
[truncated]

``````````

</details>


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


More information about the cfe-commits mailing list