[llvm] [MachineFunction] Move CallSiteInfo constructor out of header (PR #151520)
Prabhu Rajasekaran via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 31 06:40:44 PDT 2025
https://github.com/Prabhuk created https://github.com/llvm/llvm-project/pull/151520
In a recently landed PR #87575 a new constructor for
MachineFunction::CallSiteInfo was introduced to support handling of
callee_type metadata for indirect calls. Moving the implementation of
the constructor out of the header into the CPP file.
>From fdee5e77a7f9fb0c6e9d4aafd4a65320719fb5f3 Mon Sep 17 00:00:00 2001
From: prabhukr <prabhukr at google.com>
Date: Thu, 31 Jul 2025 13:37:27 +0000
Subject: [PATCH] [MachineFunction] Move CallSiteInfo constructor out of header
In a recently landed PR #87575 a new constructor for
MachineFunction::CallSiteInfo was introduced to support handling of
callee_type metadata for indirect calls. Moving the implementation of
the constructor out of the header into the CPP file.
---
llvm/include/llvm/CodeGen/MachineFunction.h | 24 +--------------------
llvm/lib/CodeGen/MachineFunction.cpp | 20 +++++++++++++++++
2 files changed, 21 insertions(+), 23 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/MachineFunction.h b/llvm/include/llvm/CodeGen/MachineFunction.h
index f729d419ad008..79a1a8f340d24 100644
--- a/llvm/include/llvm/CodeGen/MachineFunction.h
+++ b/llvm/include/llvm/CodeGen/MachineFunction.h
@@ -26,14 +26,11 @@
#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineMemOperand.h"
-#include "llvm/IR/Constants.h"
#include "llvm/IR/EHPersonalities.h"
-#include "llvm/IR/Instructions.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/ArrayRecycler.h"
#include "llvm/Support/AtomicOrdering.h"
#include "llvm/Support/Compiler.h"
-#include "llvm/Support/MD5.h"
#include "llvm/Support/Recycler.h"
#include "llvm/Target/TargetOptions.h"
#include <bitset>
@@ -526,26 +523,7 @@ class LLVM_ABI MachineFunction {
/// Extracts the numeric type id from the CallBase's callee_type Metadata,
/// and sets CalleeTypeIds. This is used as type id for the indirect call in
/// the call graph section.
- CallSiteInfo(const CallBase &CB) {
- // Call graph section needs numeric callee_type id only for indirect
- // calls.
- if (!CB.isIndirectCall())
- return;
-
- MDNode *CalleeTypeList = CB.getMetadata(LLVMContext::MD_callee_type);
- if (!CalleeTypeList)
- return;
-
- for (const MDOperand &Op : CalleeTypeList->operands()) {
- MDNode *TypeMD = cast<MDNode>(Op);
- MDString *TypeIdStr = cast<MDString>(TypeMD->getOperand(1));
- // Compute numeric type id from generalized type id string
- uint64_t TypeIdVal = MD5Hash(TypeIdStr->getString());
- IntegerType *Int64Ty = Type::getInt64Ty(CB.getContext());
- CalleeTypeIds.push_back(
- ConstantInt::get(Int64Ty, TypeIdVal, /*IsSigned=*/false));
- }
- }
+ CallSiteInfo(const CallBase &CB);
};
struct CalledGlobalInfo {
diff --git a/llvm/lib/CodeGen/MachineFunction.cpp b/llvm/lib/CodeGen/MachineFunction.cpp
index 60d42e0c0cb01..ec40f6af3caae 100644
--- a/llvm/lib/CodeGen/MachineFunction.cpp
+++ b/llvm/lib/CodeGen/MachineFunction.cpp
@@ -698,6 +698,26 @@ bool MachineFunction::needsFrameMoves() const {
!F.getParent()->debug_compile_units().empty();
}
+MachineFunction::CallSiteInfo::CallSiteInfo(const CallBase &CB) {
+ // Numeric callee_type ids are only for indirect calls.
+ if (!CB.isIndirectCall())
+ return;
+
+ MDNode *CalleeTypeList = CB.getMetadata(LLVMContext::MD_callee_type);
+ if (!CalleeTypeList)
+ return;
+
+ for (const MDOperand &Op : CalleeTypeList->operands()) {
+ MDNode *TypeMD = cast<MDNode>(Op);
+ MDString *TypeIdStr = cast<MDString>(TypeMD->getOperand(1));
+ // Compute numeric type id from generalized type id string
+ uint64_t TypeIdVal = MD5Hash(TypeIdStr->getString());
+ IntegerType *Int64Ty = Type::getInt64Ty(CB.getContext());
+ CalleeTypeIds.push_back(
+ ConstantInt::get(Int64Ty, TypeIdVal, /*IsSigned=*/false));
+ }
+}
+
namespace llvm {
template<>
More information about the llvm-commits
mailing list