Change debuginfo check for addHeapAllocSiteMetadata

Summary:
Move check inside of addHeapAllocSiteMetadata().
Change check to DebugInfo <= DebugLineTablesOnly.

Reviewers: akhuang

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D81481
This commit is contained in:
Arthur Eubanks 2020-06-09 09:55:25 -07:00
parent 7a38618a20
commit bc38793852
2 changed files with 4 additions and 2 deletions

View File

@ -2149,6 +2149,9 @@ llvm::DIType *CGDebugInfo::getOrCreateStandaloneType(QualType D,
void CGDebugInfo::addHeapAllocSiteMetadata(llvm::CallBase *CI,
QualType AllocatedTy,
SourceLocation Loc) {
if (CGM.getCodeGenOpts().getDebugInfo() <=
codegenoptions::DebugLineTablesOnly)
return;
llvm::MDNode *node;
if (AllocatedTy->isVoidType())
node = llvm::MDNode::get(CGM.getLLVMContext(), None);

View File

@ -1639,8 +1639,7 @@ llvm::Value *CodeGenFunction::EmitCXXNewExpr(const CXXNewExpr *E) {
EmitNewDeleteCall(*this, allocator, allocatorType, allocatorArgs);
// Set !heapallocsite metadata on the call to operator new.
if (CGM.getCodeGenOpts().getDebugInfo() != codegenoptions::NoDebugInfo &&
getDebugInfo())
if (getDebugInfo())
if (auto *newCall = dyn_cast<llvm::CallBase>(RV.getScalarVal()))
getDebugInfo()->addHeapAllocSiteMetadata(newCall, allocType,
E->getExprLoc());