From: Devang Patel Date: Sat, 4 Jun 2011 00:38:02 +0000 (+0000) Subject: Rework r132576. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9198126067a447f8aaccf9fff09be294c8bcb81e;p=clang Rework r132576. Emit debug info only if there is an insertion point. The debug info should not force an insertion point. Codegen may later on decide to not emit code for some reason, see extensive comment in CodeGenFunction::EmitStmt(), and debug info should not get in the way. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@132610 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDecl.cpp b/lib/CodeGen/CGDecl.cpp index 048289e506..8a1a8536da 100644 --- a/lib/CodeGen/CGDecl.cpp +++ b/lib/CodeGen/CGDecl.cpp @@ -632,8 +632,6 @@ CodeGenFunction::EmitAutoVarAlloca(const VarDecl &D) { if (HaveInsertPoint()) if (CGDebugInfo *DI = getDebugInfo()) { DI->setLocation(D.getLocation()); - DI->UpdateLineDirectiveRegion(Builder); - DI->EmitStopPoint(Builder); if (Target.useGlobalsForAutomaticVariables()) { DI->EmitGlobalVariable(static_cast(DeclPtr), &D); } else diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 5f660f8858..782ff06160 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -771,6 +771,11 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) { } void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) { + // As long as debug info is modeled with instructions, we have to ensure we + // have a place to insert here and write the stop point here. + if (getDebugInfo() && HaveInsertPoint()) + EmitStopPoint(&S); + for (DeclStmt::const_decl_iterator I = S.decl_begin(), E = S.decl_end(); I != E; ++I) EmitDecl(**I);