Skip to content

[MachineFunction] Move CallSiteInfo constructor out of header #151520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 31, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 1 addition & 23 deletions llvm/include/llvm/CodeGen/MachineFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 {
Expand Down
20 changes: 20 additions & 0 deletions llvm/lib/CodeGen/MachineFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<>
Expand Down