[llvm] 9e0dc4f - [MachineFunction] Move CallSiteInfo constructor out of header (#151520)

via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 31 07:34:49 PDT 2025


Author: Prabhu Rajasekaran
Date: 2025-07-31T07:34:46-07:00
New Revision: 9e0dc4f7377b9614944de0fc40638451d0cfd8da

URL: https://github.com/llvm/llvm-project/commit/9e0dc4f7377b9614944de0fc40638451d0cfd8da
DIFF: https://github.com/llvm/llvm-project/commit/9e0dc4f7377b9614944de0fc40638451d0cfd8da.diff

LOG: [MachineFunction] Move CallSiteInfo constructor out of header (#151520)

Added: 
    

Modified: 
    llvm/include/llvm/CodeGen/MachineFunction.h
    llvm/lib/CodeGen/MachineFunction.cpp

Removed: 
    


################################################################################
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