Change debuginfo check for addHeapAllocSiteMetadata
authorArthur Eubanks <aeubanks@google.com>
Tue, 9 Jun 2020 16:55:25 +0000 (09:55 -0700)
committerArthur Eubanks <aeubanks@google.com>
Tue, 9 Jun 2020 18:01:06 +0000 (11:01 -0700)
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

clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGExprCXX.cpp

index 1737154..65d513c 100644 (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);
index d018443..d59aa6c 100644 (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());