Skip to content

Commit 7837b84

Browse files
[clang][DebugInfo] Add virtual call-site target information in DWARF.
As the extra call site information is available by default, update other targets that support call site debug information. Move the 'CallSiteInfo' set to the block introduced by: llvm#166202
1 parent 4ec56ac commit 7837b84

File tree

6 files changed

+36
-12
lines changed

6 files changed

+36
-12
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5958,9 +5958,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
59585958
}
59595959
}
59605960

5961-
if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
5962-
DI->addCallTarget(CI->getCalledFunction(), CalleeDecl, CI);
5963-
59645961
// If this is within a function that has the guard(nocf) attribute and is an
59655962
// indirect call, add the "guard_nocf" attribute to this call to indicate that
59665963
// Control Flow Guard checks should not be added, even if the call is inlined.
@@ -6298,6 +6295,8 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
62986295
DI->EmitFuncDeclForCallSite(
62996296
CI, DI->getFunctionType(CalleeDecl, ResTy, Args), CalleeGlobalDecl);
63006297
}
6298+
// Collect call site target information.
6299+
DI->addCallTarget(CI->getCalledFunction(), CalleeDecl, CI);
63016300
}
63026301

63036302
return Ret;

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -914,7 +914,7 @@ class CGDebugInfo {
914914
llvm::StringRef GetMethodLinkageName(const CXXMethodDecl *Method) const;
915915

916916
/// For each 'DISuprogram' we store a list of call instructions 'CallBase'
917-
/// that indirectly call such 'DISuprogram'. We use its linkage name to
917+
/// that indirectly call such 'DISuprogram'. We use its linkage name to
918918
/// update such list.
919919
/// The 'CallTargetCache' is updated in the following scenarios:
920920
/// - Both 'CallBase' and 'MDNode' are ready available.

llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9418,8 +9418,14 @@ AArch64TargetLowering::LowerCall(CallLoweringInfo &CLI,
94189418
*DAG.getContext());
94199419
RetCCInfo.AnalyzeCallResult(Ins, RetCC);
94209420

9421-
// Set type id for call site info.
9422-
if (MF.getTarget().Options.EmitCallGraphSection && CB && CB->isIndirectCall())
9421+
// Set type id for call site info and metadata 'call_target'.
9422+
// We are filtering for:
9423+
// a) The call-graph-section use case that wants to know about indirect
9424+
// calls, or
9425+
// b) We want to annotate indirect calls.
9426+
if (CB && CB->isIndirectCall() &&
9427+
(MF.getTarget().Options.EmitCallGraphSection ||
9428+
MF.getTarget().Options.EmitCallSiteInfo))
94239429
CSInfo = MachineFunction::CallSiteInfo(*CB);
94249430

94259431
// Check callee args/returns for SVE registers and set calling convention

llvm/lib/Target/ARM/ARMISelLowering.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2316,8 +2316,14 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
23162316
!Subtarget->noBTIAtReturnTwice())
23172317
GuardWithBTI = AFI->branchTargetEnforcement();
23182318

2319-
// Set type id for call site info.
2320-
if (MF.getTarget().Options.EmitCallGraphSection && CB && CB->isIndirectCall())
2319+
// Set type id for call site info and metadata 'call_target'.
2320+
// We are filtering for:
2321+
// a) The call-graph-section use case that wants to know about indirect
2322+
// calls, or
2323+
// b) We want to annotate indirect calls.
2324+
if (CB && CB->isIndirectCall() &&
2325+
(MF.getTarget().Options.EmitCallGraphSection ||
2326+
MF.getTarget().Options.EmitCallSiteInfo))
23212327
CSInfo = MachineFunction::CallSiteInfo(*CB);
23222328

23232329
// Determine whether this is a non-secure function call.

llvm/lib/Target/Mips/MipsISelLowering.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3400,8 +3400,15 @@ MipsTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
34003400

34013401
// Call site info for function parameters tracking and call base type info.
34023402
MachineFunction::CallSiteInfo CSInfo;
3403-
// Set type id for call site info.
3404-
if (MF.getTarget().Options.EmitCallGraphSection && CB && CB->isIndirectCall())
3403+
3404+
// Set type id for call site info and metadata 'call_target'.
3405+
// We are filtering for:
3406+
// a) The call-graph-section use case that wants to know about indirect
3407+
// calls, or
3408+
// b) We want to annotate indirect calls.
3409+
if (CB && CB->isIndirectCall() &&
3410+
(MF.getTarget().Options.EmitCallGraphSection ||
3411+
MF.getTarget().Options.EmitCallSiteInfo))
34053412
CSInfo = MachineFunction::CallSiteInfo(*CB);
34063413

34073414
// Check if it's really possible to do a tail call. Restrict it to functions

llvm/lib/Target/RISCV/RISCVISelLowering.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23601,8 +23601,14 @@ SDValue RISCVTargetLowering::LowerCall(CallLoweringInfo &CLI,
2360123601
MachineFunction &MF = DAG.getMachineFunction();
2360223602
MachineFunction::CallSiteInfo CSInfo;
2360323603

23604-
// Set type id for call site info.
23605-
if (MF.getTarget().Options.EmitCallGraphSection && CB && CB->isIndirectCall())
23604+
// Set type id for call site info and metadata 'call_target'.
23605+
// We are filtering for:
23606+
// a) The call-graph-section use case that wants to know about indirect
23607+
// calls, or
23608+
// b) We want to annotate indirect calls.
23609+
if (CB && CB->isIndirectCall() &&
23610+
(MF.getTarget().Options.EmitCallGraphSection ||
23611+
MF.getTarget().Options.EmitCallSiteInfo))
2360623612
CSInfo = MachineFunction::CallSiteInfo(*CB);
2360723613

2360823614
// Analyze the operands of the call, assigning locations to each operand.

0 commit comments

Comments
 (0)