Skip to content

Commit 15cfbe5

Browse files
committed
Lift up call site emission conditions check
1 parent 919d777 commit 15cfbe5

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

clang/lib/CodeGen/CGCall.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
#include "llvm/IR/Attributes.h"
3939
#include "llvm/IR/CallingConv.h"
4040
#include "llvm/IR/DataLayout.h"
41+
#include "llvm/IR/DebugInfoMetadata.h"
4142
#include "llvm/IR/InlineAsm.h"
4243
#include "llvm/IR/IntrinsicInst.h"
4344
#include "llvm/IR/Intrinsics.h"
@@ -6277,10 +6278,13 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
62776278
pushDestroy(QualType::DK_nontrivial_c_struct, Ret.getAggregateAddress(),
62786279
RetTy);
62796280

6280-
if (CalleeDecl) {
6281-
// Generate function declaration DISuprogram in order to be used
6282-
// in debug info about call sites.
6283-
if (CGDebugInfo *DI = getDebugInfo()) {
6281+
// Generate function declaration DISuprogram in order to be used
6282+
// in debug info about call sites.
6283+
if (CGDebugInfo *DI = getDebugInfo()) {
6284+
// Ensure call site info would actually be emitted before collecting
6285+
// further callee info.
6286+
if (CalleeDecl && !CalleeDecl->hasAttr<NoDebugAttr>() &&
6287+
DI->getCallSiteRelatedAttrs() != llvm::DINode::FlagZero) {
62846288
CodeGenFunction CalleeCGF(CGM);
62856289
const GlobalDecl &CalleeGlobalDecl =
62866290
Callee.getAbstractInfo().getCalleeDecl();

clang/lib/CodeGen/CGDebugInfo.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,10 @@ class CGDebugInfo {
678678
/// Emit symbol for debugger that holds the pointer to the vtable.
679679
void emitVTableSymbol(llvm::GlobalVariable *VTable, const CXXRecordDecl *RD);
680680

681+
/// Return flags which enable debug info emission for call sites, provided
682+
/// that it is supported and enabled.
683+
llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;
684+
681685
private:
682686
/// Amend \p I's DebugLoc with \p Group (its source atom group) and \p
683687
/// Rank (lower nonzero rank is higher precedence). Does nothing if \p I
@@ -828,10 +832,6 @@ class CGDebugInfo {
828832
llvm::GlobalVariable *Var, llvm::DIScope *DContext);
829833

830834

831-
/// Return flags which enable debug info emission for call sites, provided
832-
/// that it is supported and enabled.
833-
llvm::DINode::DIFlags getCallSiteRelatedAttrs() const;
834-
835835
/// Get the printing policy for producing names for debug info.
836836
PrintingPolicy getPrintingPolicy() const;
837837

0 commit comments

Comments
 (0)