[llvm-branch-commits] [clang] callee_type metadata for indirect calls (PR #117036)

Prabhu Rajasekaran via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Apr 22 20:57:18 PDT 2025


================
@@ -2813,7 +2814,17 @@ static void setLinkageForGV(llvm::GlobalValue *GV, const NamedDecl *ND) {
 
 void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD,
                                                        llvm::Function *F) {
-  // Only if we are checking indirect calls.
+  bool EmittedMDIdGeneralized = false;
+  if (CodeGenOpts.CallGraphSection &&
+      (!F->hasLocalLinkage() ||
+       F->getFunction().hasAddressTaken(nullptr, /*IgnoreCallbackUses=*/true,
+                                        /*IgnoreAssumeLikeCalls=*/true,
+                                        /*IgnoreLLVMUsed=*/false))) {
+    F->addTypeMetadata(0, CreateMetadataIdentifierGeneralized(FD->getType()));
+    EmittedMDIdGeneralized = true;
----------------
Prabhuk wrote:

This code has been refactored. Marking this as resolved.

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


More information about the llvm-branch-commits mailing list