Skip to content

Commit 9e0dc4f

Browse files
authored
[MachineFunction] Move CallSiteInfo constructor out of header (#151520)
1 parent 77f8a91 commit 9e0dc4f

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

llvm/include/llvm/CodeGen/MachineFunction.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,11 @@
2626
#include "llvm/CodeGen/MachineBasicBlock.h"
2727
#include "llvm/CodeGen/MachineInstr.h"
2828
#include "llvm/CodeGen/MachineMemOperand.h"
29-
#include "llvm/IR/Constants.h"
3029
#include "llvm/IR/EHPersonalities.h"
31-
#include "llvm/IR/Instructions.h"
3230
#include "llvm/Support/Allocator.h"
3331
#include "llvm/Support/ArrayRecycler.h"
3432
#include "llvm/Support/AtomicOrdering.h"
3533
#include "llvm/Support/Compiler.h"
36-
#include "llvm/Support/MD5.h"
3734
#include "llvm/Support/Recycler.h"
3835
#include "llvm/Target/TargetOptions.h"
3936
#include <bitset>
@@ -526,26 +523,7 @@ class LLVM_ABI MachineFunction {
526523
/// Extracts the numeric type id from the CallBase's callee_type Metadata,
527524
/// and sets CalleeTypeIds. This is used as type id for the indirect call in
528525
/// the call graph section.
529-
CallSiteInfo(const CallBase &CB) {
530-
// Call graph section needs numeric callee_type id only for indirect
531-
// calls.
532-
if (!CB.isIndirectCall())
533-
return;
534-
535-
MDNode *CalleeTypeList = CB.getMetadata(LLVMContext::MD_callee_type);
536-
if (!CalleeTypeList)
537-
return;
538-
539-
for (const MDOperand &Op : CalleeTypeList->operands()) {
540-
MDNode *TypeMD = cast<MDNode>(Op);
541-
MDString *TypeIdStr = cast<MDString>(TypeMD->getOperand(1));
542-
// Compute numeric type id from generalized type id string
543-
uint64_t TypeIdVal = MD5Hash(TypeIdStr->getString());
544-
IntegerType *Int64Ty = Type::getInt64Ty(CB.getContext());
545-
CalleeTypeIds.push_back(
546-
ConstantInt::get(Int64Ty, TypeIdVal, /*IsSigned=*/false));
547-
}
548-
}
526+
CallSiteInfo(const CallBase &CB);
549527
};
550528

551529
struct CalledGlobalInfo {

llvm/lib/CodeGen/MachineFunction.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,26 @@ bool MachineFunction::needsFrameMoves() const {
698698
!F.getParent()->debug_compile_units().empty();
699699
}
700700

701+
MachineFunction::CallSiteInfo::CallSiteInfo(const CallBase &CB) {
702+
// Numeric callee_type ids are only for indirect calls.
703+
if (!CB.isIndirectCall())
704+
return;
705+
706+
MDNode *CalleeTypeList = CB.getMetadata(LLVMContext::MD_callee_type);
707+
if (!CalleeTypeList)
708+
return;
709+
710+
for (const MDOperand &Op : CalleeTypeList->operands()) {
711+
MDNode *TypeMD = cast<MDNode>(Op);
712+
MDString *TypeIdStr = cast<MDString>(TypeMD->getOperand(1));
713+
// Compute numeric type id from generalized type id string
714+
uint64_t TypeIdVal = MD5Hash(TypeIdStr->getString());
715+
IntegerType *Int64Ty = Type::getInt64Ty(CB.getContext());
716+
CalleeTypeIds.push_back(
717+
ConstantInt::get(Int64Ty, TypeIdVal, /*IsSigned=*/false));
718+
}
719+
}
720+
701721
namespace llvm {
702722

703723
template<>

0 commit comments

Comments
 (0)