[clang] [clang] inherit GD to let the codegen add kcfi type for ifunc (PR #96400)
via cfe-commits
cfe-commits at lists.llvm.org
Sat Jun 22 09:04:20 PDT 2024
https://github.com/aokblast created https://github.com/llvm/llvm-project/pull/96400
In FreeBSD, we use ifunc to select best performance function in load time. However, the resolver is also a function itself but not been tagged kcfi by clang. The problems is caused by
```
if (D)
CodeGenModule::SetFunctionAttribute()
```
called by CodeGenModule::GetOrCreateLLVMFunction where D is empty originally.
>From 0aa3505e0775c0cd7ef98698f930327e4af5ff7a Mon Sep 17 00:00:00 2001
From: aokblast <aokblast at FreeBSD.org>
Date: Sat, 22 Jun 2024 23:41:07 +0800
Subject: [PATCH] inherit GD to let the codegen add kcfi handler for ifunc
---
clang/lib/CodeGen/CodeGenModule.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index c8898ce196c1e..3e1f650884a7a 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -5995,7 +5995,7 @@ void CodeGenModule::emitIFuncDefinition(GlobalDecl GD) {
llvm::Type *DeclTy = getTypes().ConvertTypeForMem(D->getType());
llvm::Type *ResolverTy = llvm::GlobalIFunc::getResolverFunctionType(DeclTy);
llvm::Constant *Resolver =
- GetOrCreateLLVMFunction(IFA->getResolver(), ResolverTy, {},
+ GetOrCreateLLVMFunction(IFA->getResolver(), ResolverTy, GD,
/*ForVTable=*/false);
llvm::GlobalIFunc *GIF =
llvm::GlobalIFunc::create(DeclTy, 0, llvm::Function::ExternalLinkage,
More information about the cfe-commits
mailing list