[clang] [llvm] [llvm][AsmPrinter] Add direct calls to callgraph section (PR #155706)
Prabhu Rajasekaran via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 15 17:09:53 PDT 2025
================
@@ -1866,20 +1875,39 @@ static StringRef getMIMnemonic(const MachineInstr &MI, MCStreamer &Streamer) {
return Name;
}
-void AsmPrinter::emitIndirectCalleeLabels(
+void AsmPrinter::emitCallsiteLabelsForCallgraph(
FunctionInfo &FuncInfo,
const MachineFunction::CallSiteInfoMap &CallSitesInfoMap,
const MachineInstr &MI) {
- // Only indirect calls have type identifiers set.
- const auto &CallSiteInfo = CallSitesInfoMap.find(&MI);
- if (CallSiteInfo == CallSitesInfoMap.end())
- return;
-
- for (ConstantInt *CalleeTypeId : CallSiteInfo->second.CalleeTypeIds) {
+ assert(MI.isCall() && "Callsite labels are meant for call instruction only.");
+ const MachineOperand &CalleeOperand = MI.getOperand(0);
+ if (CalleeOperand.isGlobal() || CalleeOperand.isSymbol()) {
+ // Handle direct calls.
+ MCSymbol *CalleeSymbol = nullptr;
+ switch (CalleeOperand.getType()) {
+ case llvm::MachineOperand::MO_GlobalAddress:
+ CalleeSymbol = getSymbol(CalleeOperand.getGlobal());
+ break;
+ case llvm::MachineOperand::MO_ExternalSymbol:
+ CalleeSymbol = GetExternalSymbolSymbol(CalleeOperand.getSymbolName());
+ break;
+ default:
+ llvm_unreachable(
+ "Expected to only handle direct call instructions here.");
+ }
MCSymbol *S = MF->getContext().createTempSymbol();
OutStreamer->emitLabel(S);
- uint64_t CalleeTypeIdVal = CalleeTypeId->getZExtValue();
- FuncInfo.CallSiteLabels.emplace_back(CalleeTypeIdVal, S);
+ FuncInfo.DirectCallSiteLabels.emplace_back(S, CalleeSymbol);
----------------
Prabhuk wrote:
Done. PTAL.
https://github.com/llvm/llvm-project/pull/155706
More information about the llvm-commits
mailing list