https://github.com/mylai-mtk created https://github.com/llvm/llvm-project/pull/109080
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. >From b3f6c6edbbcc005f9ceb4dec5873b23fcc75989b Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai <ming-yi....@mediatek.com> Date: Fri, 14 Jun 2024 15:28:11 +0800 Subject: [PATCH] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type 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. --- clang/lib/CodeGen/CodeGenModule.cpp | 16 ++++++------- clang/lib/CodeGen/CodeGenModule.h | 6 ++--- clang/test/CodeGen/kcfi-normalize.c | 6 ++--- clang/test/CodeGen/kcfi.c | 20 ++++++++-------- llvm/docs/LangRef.rst | 12 +++++----- llvm/include/llvm/IR/FixedMetadataKinds.def | 2 +- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 2 +- llvm/lib/CodeGen/MachineFunction.cpp | 3 ++- llvm/lib/IR/Verifier.cpp | 23 +++++++++---------- llvm/lib/Target/X86/X86AsmPrinter.cpp | 2 +- llvm/lib/Transforms/IPO/MergeFunctions.cpp | 4 ++-- .../InstCombine/InstCombineCalls.cpp | 4 ++-- llvm/lib/Transforms/Utils/ModuleUtils.cpp | 2 +- llvm/test/CodeGen/AArch64/kcfi-bti.ll | 4 ++-- .../AArch64/kcfi-patchable-function-prefix.ll | 4 ++-- llvm/test/CodeGen/AArch64/kcfi.ll | 2 +- llvm/test/CodeGen/ARM/kcfi.ll | 2 +- llvm/test/CodeGen/RISCV/kcfi-isel-mir.ll | 2 +- llvm/test/CodeGen/RISCV/kcfi-mir.ll | 2 +- .../RISCV/kcfi-patchable-function-prefix.ll | 4 ++-- llvm/test/CodeGen/RISCV/kcfi.ll | 2 +- .../X86/kcfi-patchable-function-prefix.ll | 4 ++-- llvm/test/CodeGen/X86/kcfi.ll | 6 ++--- .../AddressSanitizer/kcfi-offset.ll | 2 +- .../Instrumentation/AddressSanitizer/kcfi.ll | 4 ++-- .../GCOVProfiling/kcfi-normalize.ll | 8 +++---- llvm/test/Transforms/GCOVProfiling/kcfi.ll | 8 +++---- .../Verifier/metadata-function-kcfi-type.ll | 22 +++++++++--------- 28 files changed, 89 insertions(+), 89 deletions(-) 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 --- a/llvm/test/CodeGen/RISCV/kcfi-mir.ll +++ b/llvm/test/CodeGen/RISCV/kcfi-mir.ll @@ -1,7 +1,7 @@ ; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2 ; RUN: llc -mtriple=riscv64 -stop-after=kcfi -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, $x1 diff --git a/llvm/test/CodeGen/RISCV/kcfi-patchable-function-prefix.ll b/llvm/test/CodeGen/RISCV/kcfi-patchable-function-prefix.ll index 8e13bb769ea506..c27ca93ec79649 100644 --- a/llvm/test/CodeGen/RISCV/kcfi-patchable-function-prefix.ll +++ b/llvm/test/CodeGen/RISCV/kcfi-patchable-function-prefix.ll @@ -8,7 +8,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: lw t1, -4(a0) call void %x() [ "kcfi"(i32 12345678) ] ret void @@ -31,7 +31,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 { ; NOC: lw t1, -48(a0) ; C: lw t1, -26(a0) call void %x() [ "kcfi"(i32 12345678) ] diff --git a/llvm/test/CodeGen/RISCV/kcfi.ll b/llvm/test/CodeGen/RISCV/kcfi.ll index 52be56fcbf55fe..cd44ada1c405b8 100644 --- a/llvm/test/CodeGen/RISCV/kcfi.ll +++ b/llvm/test/CodeGen/RISCV/kcfi.ll @@ -4,7 +4,7 @@ ; RUN: | FileCheck %s --check-prefixes=CHECK,RV64 ; CHECK: .word 12345678 -define void @f1(ptr noundef %x) !kcfi_type !1 { +define void @f1(ptr noundef %x) !cfi_type !1 { ; CHECK-LABEL: f1: ; CHECK: # %bb.0: ; CHECK: lw t1, -4(a0) diff --git a/llvm/test/CodeGen/X86/kcfi-patchable-function-prefix.ll b/llvm/test/CodeGen/X86/kcfi-patchable-function-prefix.ll index e5d541f8ed9d97..4569307716289f 100644 --- a/llvm/test/CodeGen/X86/kcfi-patchable-function-prefix.ll +++ b/llvm/test/CodeGen/X86/kcfi-patchable-function-prefix.ll @@ -7,7 +7,7 @@ ; CHECK-LABEL: .Lcfi_func_end0: ; CHECK-NEXT: .size __cfi_f1, .Lcfi_func_end0-__cfi_f1 ; CHECK-LABEL: f1: -define void @f1(ptr noundef %x) !kcfi_type !1 { +define void @f1(ptr noundef %x) !cfi_type !1 { ; CHECK: addl -4(%r{{..}}), %r10d call void %x() [ "kcfi"(i32 12345678) ] ret void @@ -29,7 +29,7 @@ define void @f2(ptr noundef %x) { ; CHECK-NEXT: movl $12345678, %eax ; 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: addl -15(%r{{..}}), %r10d call void %x() [ "kcfi"(i32 12345678) ] ret void diff --git a/llvm/test/CodeGen/X86/kcfi.ll b/llvm/test/CodeGen/X86/kcfi.ll index 566a88b76c4fc9..0658e070d31e9e 100644 --- a/llvm/test/CodeGen/X86/kcfi.ll +++ b/llvm/test/CodeGen/X86/kcfi.ll @@ -19,7 +19,7 @@ ; ASM-NEXT: movl $12345678, %eax ; ASM-LABEL: .Lcfi_func_end0: ; ASM-NEXT: .size __cfi_f1, .Lcfi_func_end0-__cfi_f1 -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: movl $4282621618, %r10d # imm = 0xFF439EB2 @@ -91,7 +91,7 @@ define void @f4(ptr noundef %x) #0 { ;; Ensure we emit Value + 1 for unwanted values (e.g. endbr64 == 4196274163). ; ASM-LABEL: __cfi_f5: ; ASM: movl $4196274164, %eax # imm = 0xFA1E0FF4 -define void @f5(ptr noundef %x) !kcfi_type !2 { +define void @f5(ptr noundef %x) !cfi_type !2 { ; ASM-LABEL: f5: ; ASM: movl $98693132, %r10d # imm = 0x5E1F00C tail call void %x() [ "kcfi"(i32 4196274163) ] @@ -101,7 +101,7 @@ define void @f5(ptr noundef %x) !kcfi_type !2 { ;; Ensure we emit Value + 1 for unwanted values (e.g. -endbr64 == 98693133). ; ASM-LABEL: __cfi_f6: ; ASM: movl $98693134, %eax # imm = 0x5E1F00E -define void @f6(ptr noundef %x) !kcfi_type !3 { +define void @f6(ptr noundef %x) !cfi_type !3 { ; ASM-LABEL: f6: ; ASM: movl $4196274162, %r10d # imm = 0xFA1E0FF2 tail call void %x() [ "kcfi"(i32 98693133) ] diff --git a/llvm/test/Instrumentation/AddressSanitizer/kcfi-offset.ll b/llvm/test/Instrumentation/AddressSanitizer/kcfi-offset.ll index b5d103c0739988..0c9b44f3a8a427 100644 --- a/llvm/test/Instrumentation/AddressSanitizer/kcfi-offset.ll +++ b/llvm/test/Instrumentation/AddressSanitizer/kcfi-offset.ll @@ -6,7 +6,7 @@ ; CHECK: define internal void @asan.module_ctor() ; CHECK-SAME: #[[#ATTR:]] -; CHECK-SAME: !kcfi_type +; CHECK-SAME: !cfi_type ; CHECK: attributes #[[#ATTR]] = { {{.*}} "patchable-function-prefix"="3" } diff --git a/llvm/test/Instrumentation/AddressSanitizer/kcfi.ll b/llvm/test/Instrumentation/AddressSanitizer/kcfi.ll index d263cbd7390481..bd298cb16ca62b 100644 --- a/llvm/test/Instrumentation/AddressSanitizer/kcfi.ll +++ b/llvm/test/Instrumentation/AddressSanitizer/kcfi.ll @@ -1,11 +1,11 @@ -;; Test that we emit kcfi_type metadata for asan.module_ctor with KCFI. +;; Test that we emit cfi_type metadata for asan.module_ctor with KCFI. ; RUN: opt < %s -passes=asan -S | FileCheck %s ; CHECK: @llvm.global_ctors = {{.*}}{ i32 1, ptr @asan.module_ctor, ptr @asan.module_ctor } ; CHECK: define internal void @asan.module_ctor() -; CHECK-SAME: !kcfi_type +; CHECK-SAME: !cfi_type !llvm.module.flags = !{!0} !0 = !{i32 4, !"kcfi", i32 1} diff --git a/llvm/test/Transforms/GCOVProfiling/kcfi-normalize.ll b/llvm/test/Transforms/GCOVProfiling/kcfi-normalize.ll index 19122b920d1ca4..d83666c7e03084 100644 --- a/llvm/test/Transforms/GCOVProfiling/kcfi-normalize.ll +++ b/llvm/test/Transforms/GCOVProfiling/kcfi-normalize.ll @@ -1,4 +1,4 @@ -;; Ensure __llvm_gcov_(writeout|reset|init) have the correct !kcfi_type +;; Ensure __llvm_gcov_(writeout|reset|init) have the correct !cfi_type ;; with integer normalization. ; RUN: mkdir -p %t && cd %t ; RUN: opt < %s -S -passes=insert-gcov-profiling | FileCheck %s @@ -26,10 +26,10 @@ entry: !10 = !{i32 4, !"cfi-normalize-integers", i32 1} ; CHECK: define internal void @__llvm_gcov_writeout() -; CHECK-SAME: !kcfi_type ![[#TYPE:]] +; CHECK-SAME: !cfi_type ![[#TYPE:]] ; CHECK: define internal void @__llvm_gcov_reset() -; CHECK-SAME: !kcfi_type ![[#TYPE]] +; CHECK-SAME: !cfi_type ![[#TYPE]] ; CHECK: define internal void @__llvm_gcov_init() -; CHECK-SAME: !kcfi_type ![[#TYPE]] +; CHECK-SAME: !cfi_type ![[#TYPE]] ; CHECK: ![[#TYPE]] = !{i32 -440107680} diff --git a/llvm/test/Transforms/GCOVProfiling/kcfi.ll b/llvm/test/Transforms/GCOVProfiling/kcfi.ll index 1b97d25294cd65..ab6c07ce8e70d3 100644 --- a/llvm/test/Transforms/GCOVProfiling/kcfi.ll +++ b/llvm/test/Transforms/GCOVProfiling/kcfi.ll @@ -1,4 +1,4 @@ -;; Ensure __llvm_gcov_(writeout|reset|init) have !kcfi_type with KCFI. +;; Ensure __llvm_gcov_(writeout|reset|init) have !cfi_type with KCFI. ; RUN: mkdir -p %t && cd %t ; RUN: opt < %s -S -passes=insert-gcov-profiling | FileCheck %s @@ -24,10 +24,10 @@ entry: !9 = !{i32 4, !"kcfi", i32 1} ; CHECK: define internal void @__llvm_gcov_writeout() -; CHECK-SAME: !kcfi_type ![[#TYPE:]] +; CHECK-SAME: !cfi_type ![[#TYPE:]] ; CHECK: define internal void @__llvm_gcov_reset() -; CHECK-SAME: !kcfi_type ![[#TYPE]] +; CHECK-SAME: !cfi_type ![[#TYPE]] ; CHECK: define internal void @__llvm_gcov_init() -; CHECK-SAME: !kcfi_type ![[#TYPE]] +; CHECK-SAME: !cfi_type ![[#TYPE]] ; CHECK: ![[#TYPE]] = !{i32 -1522505972} diff --git a/llvm/test/Verifier/metadata-function-kcfi-type.ll b/llvm/test/Verifier/metadata-function-kcfi-type.ll index 93bac98e11937a..5a521e9c811455 100644 --- a/llvm/test/Verifier/metadata-function-kcfi-type.ll +++ b/llvm/test/Verifier/metadata-function-kcfi-type.ll @@ -4,36 +4,36 @@ define void @a() { unreachable } -define void @b() !kcfi_type !0 { +define void @b() !cfi_type !0 { unreachable } -; CHECK: function must have a single !kcfi_type attachment -define void @f0() !kcfi_type !0 !kcfi_type !0 { +; CHECK: function must have a single !cfi_type attachment +define void @f0() !cfi_type !0 !cfi_type !0 { unreachable } !0 = !{i32 10} -; CHECK: !kcfi_type must have exactly one operand -define void @f1() !kcfi_type !1 { +; CHECK: !cfi_type must have exactly one operand +define void @f1() !cfi_type !1 { unreachable } !1 = !{!"string", i32 0} -; CHECK: expected a constant operand for !kcfi_type -define void @f2() !kcfi_type !2 { +; CHECK: expected a constant operand for !cfi_type +define void @f2() !cfi_type !2 { unreachable } !2 = !{!"string"} -; CHECK: expected a constant integer operand for !kcfi_type -define void @f3() !kcfi_type !3 { +; CHECK: expected a constant integer operand for !cfi_type +define void @f3() !cfi_type !3 { unreachable } !3 = !{ptr @f3} -; CHECK: expected a 32-bit integer constant operand for !kcfi_type -define void @f4() !kcfi_type !4 { +; CHECK: expected a 32-bit integer constant operand for !cfi_type +define void @f4() !cfi_type !4 { unreachable } !4 = !{i64 10} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits