<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Jul 1, 2015 at 11:07 AM, David Blaikie <span dir="ltr"><<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: dblaikie<br>
Date: Wed Jul 1 13:07:16 2015<br>
New Revision: 241176<br>
<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject-3Frev-3D241176-26view-3Drev&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=nErmAwBtLzi9rJLQ-MTRzktdRNwia2oEF72vmcwtjbE&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=241176&view=rev</a><br>
Log:<br>
Revert "[DWARF] Fix debug info generation for function static variables, typedefs, and records"<br>
<br>
Caused PR24008<br>
<br>
This reverts commit 37cb5f1c2db9f42d29f26b215585f56bb64ae4f5.<br></blockquote><div><br></div><div><span style="font-family:monospace">r241153 (and r241162)</span><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
<br>
Removed:<br>
llvm/trunk/test/DebugInfo/X86/lexical-block-pr19238.ll<br>
Modified:<br>
llvm/trunk/include/llvm/ADT/iterator_range.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h<br>
<br>
Modified: llvm/trunk/include/llvm/ADT/iterator_range.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_include_llvm_ADT_iterator-5Frange.h-3Frev-3D241176-26r1-3D241175-26r2-3D241176-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=WaWbHGUO6nOKHXcjVGjxBh4gxAWAqYhVLIH_svHtlPc&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ADT/iterator_range.h?rev=241176&r1=241175&r2=241176&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/ADT/iterator_range.h (original)<br>
+++ llvm/trunk/include/llvm/ADT/iterator_range.h Wed Jul 1 13:07:16 2015<br>
@@ -53,7 +53,4 @@ template <typename T> iterator_range<T><br>
}<br>
}<br>
<br>
-template <typename R><br>
-bool empty(const R& r) { return begin(r) == end(r); }<br>
-<br>
#endif<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfCompileUnit.cpp-3Frev-3D241176-26r1-3D241175-26r2-3D241176-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=0E7TNBVaeJJg5vYVJ2zqSI2F-5GbZZb9tro5JRK7sw0&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp?rev=241176&r1=241175&r2=241176&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp Wed Jul 1 13:07:16 2015<br>
@@ -101,7 +101,7 @@ static const ConstantExpr *getMergedGlob<br>
<br>
/// getOrCreateGlobalVariableDIE - get or create global variable DIE.<br>
DIE *DwarfCompileUnit::getOrCreateGlobalVariableDIE(<br>
- const DIGlobalVariable *GV, DIE *ContextDIE) {<br>
+ const DIGlobalVariable *GV) {<br>
// Check for pre-existence.<br>
if (DIE *Die = getDIE(GV))<br>
return Die;<br>
@@ -113,8 +113,7 @@ DIE *DwarfCompileUnit::getOrCreateGlobal<br>
<br>
// Construct the context before querying for the existence of the DIE in<br>
// case such construction creates the DIE.<br>
- if (ContextDIE == nullptr)<br>
- ContextDIE = getOrCreateContextDIE(GVContext);<br>
+ DIE *ContextDIE = getOrCreateContextDIE(GVContext);<br>
<br>
// Add to map.<br>
DIE *VariableDIE = &createAndAddDIE(GV->getTag(), *ContextDIE, GV);<br>
@@ -336,16 +335,17 @@ void DwarfCompileUnit::constructScopeDIE<br>
// null and the children will be added to the scope DIE.<br>
createScopeChildrenDIE(Scope, Children, &ChildScopeCount);<br>
<br>
-<br>
- DwarfDebug::LocalDeclMapRange LocalDeclNodeRangeForScope(nullptr, nullptr);<br>
- // Skip local decls in gmlt-like data.<br>
- if (!includeMinimalInlineScopes())<br>
- LocalDeclNodeRangeForScope = DD->findLocalDeclNodesForScope(DS);<br>
+ // Skip imported directives in gmlt-like data.<br>
+ if (!includeMinimalInlineScopes()) {<br>
+ // There is no need to emit empty lexical block DIE.<br>
+ for (const auto &E : DD->findImportedEntitiesForScope(DS))<br>
+ Children.push_back(<br>
+ constructImportedEntityDIE(cast<DIImportedEntity>(E.second)));<br>
+ }<br>
<br>
// If there are only other scopes as children, put them directly in the<br>
// parent instead, as this scope would serve no purpose.<br>
- if (Children.size() == ChildScopeCount &&<br>
- empty(LocalDeclNodeRangeForScope)) {<br>
+ if (Children.size() == ChildScopeCount) {<br>
FinalChildren.insert(FinalChildren.end(),<br>
std::make_move_iterator(Children.begin()),<br>
std::make_move_iterator(Children.end()));<br>
@@ -353,15 +353,6 @@ void DwarfCompileUnit::constructScopeDIE<br>
}<br>
ScopeDIE = constructLexicalScopeDIE(Scope);<br>
assert(ScopeDIE && "Scope DIE should not be null.");<br>
-<br>
- for (const auto &DI : LocalDeclNodeRangeForScope) {<br>
- if (auto *IE = dyn_cast<DIImportedEntity>(DI.second))<br>
- Children.push_back(constructImportedEntityDIE(IE));<br>
- else if (auto *GV = dyn_cast<DIGlobalVariable>(DI.second))<br>
- getOrCreateGlobalVariableDIE(GV, ScopeDIE);<br>
- else if (auto *RT = dyn_cast<DIType>(DI.second))<br>
- getOrCreateTypeDIE(RT, ScopeDIE);<br>
- }<br>
}<br>
<br>
// Add children<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfCompileUnit.h-3Frev-3D241176-26r1-3D241175-26r2-3D241176-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=Kv-Jhz5oDPKLtla_H-KWhDqcuTGfQFxTJk03Rrar_7I&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h?rev=241176&r1=241175&r2=241176&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h Wed Jul 1 13:07:16 2015<br>
@@ -77,11 +77,8 @@ public:<br>
/// Apply the DW_AT_stmt_list from this compile unit to the specified DIE.<br>
void applyStmtList(DIE &D);<br>
<br>
- /// Get or create global variable DIE.<br>
- /// \param GV Global Variable Node<br>
- /// \param ContextDIE DIE scope for GV Node, if available.<br>
- DIE *getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV,<br>
- DIE *ContextDIE = nullptr);<br>
+ /// getOrCreateGlobalVariableDIE - get or create global variable DIE.<br>
+ DIE *getOrCreateGlobalVariableDIE(const DIGlobalVariable *GV);<br>
<br>
/// addLabelAddress - Add a dwarf label attribute data and value using<br>
/// either DW_FORM_addr or DW_FORM_GNU_addr_index.<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfDebug.cpp-3Frev-3D241176-26r1-3D241175-26r2-3D241176-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=p_GdilgPCZzuhr7xI08cA11NwVGvMz_QGULPNjSDuQM&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp?rev=241176&r1=241175&r2=241176&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp Wed Jul 1 13:07:16 2015<br>
@@ -449,14 +449,14 @@ void DwarfDebug::beginModule() {<br>
auto *CUNode = cast<DICompileUnit>(N);<br>
DwarfCompileUnit &CU = constructDwarfCompileUnit(CUNode);<br>
for (auto *IE : CUNode->getImportedEntities())<br>
- ScopesWithLocalDeclNodes.push_back(std::make_pair(IE->getScope(), IE));<br>
- for (auto *GV : CUNode->getGlobalVariables()) {<br>
- auto *Context = GV->getScope();<br>
- if (Context && isa<DILexicalBlockBase>(Context))<br>
- ScopesWithLocalDeclNodes.push_back(std::make_pair(Context, GV));<br>
- else<br>
- CU.getOrCreateGlobalVariableDIE(GV);<br>
- }<br>
+ ScopesWithImportedEntities.push_back(std::make_pair(IE->getScope(), IE));<br>
+ // Stable sort to preserve the order of appearance of imported entities.<br>
+ // This is to avoid out-of-order processing of interdependent declarations<br>
+ // within the same scope, e.g. { namespace A = base; namespace B = A; }<br>
+ std::stable_sort(ScopesWithImportedEntities.begin(),<br>
+ ScopesWithImportedEntities.end(), less_first());<br>
+ for (auto *GV : CUNode->getGlobalVariables())<br>
+ CU.getOrCreateGlobalVariableDIE(GV);<br>
for (auto *SP : CUNode->getSubprograms())<br>
SPMap.insert(std::make_pair(SP, &CU));<br>
for (auto *Ty : CUNode->getEnumTypes()) {<br>
@@ -467,23 +467,12 @@ void DwarfDebug::beginModule() {<br>
for (auto *Ty : CUNode->getRetainedTypes()) {<br>
// The retained types array by design contains pointers to<br>
// MDNodes rather than DIRefs. Unique them here.<br>
- DIType *RT = cast<DIType>(resolve(Ty->getRef()));<br>
- auto *Context = resolve(Ty->getScope());<br>
- if (Context && isa<DILexicalBlockBase>(Context))<br>
- ScopesWithLocalDeclNodes.push_back(std::make_pair(Context, RT));<br>
- else<br>
- CU.getOrCreateTypeDIE(RT);<br>
+ CU.getOrCreateTypeDIE(cast<DIType>(resolve(Ty->getRef())));<br>
}<br>
// Emit imported_modules last so that the relevant context is already<br>
// available.<br>
for (auto *IE : CUNode->getImportedEntities())<br>
constructAndAddImportedEntityDIE(CU, IE);<br>
-<br>
- // Stable sort to preserve the order of appearance of imported entities.<br>
- // This is to avoid out-of-order processing of interdependent declarations<br>
- // within the same scope, e.g. { namespace A = base; namespace B = A; }<br>
- std::stable_sort(ScopesWithLocalDeclNodes.begin(),<br>
- ScopesWithLocalDeclNodes.end(), less_first());<br>
}<br>
<br>
// Tell MMI that we have debug info.<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfDebug.h-3Frev-3D241176-26r1-3D241175-26r2-3D241176-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=276WElNrynkBXNXjc2t2qoLce-BLO5blnGApVI-zRXY&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h?rev=241176&r1=241175&r2=241176&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.h Wed Jul 1 13:07:16 2015<br>
@@ -278,10 +278,13 @@ class DwarfDebug : public AsmPrinterHand<br>
// Holder for the file specific debug information.<br>
DwarfFile InfoHolder;<br>
<br>
- // Holder for local declaration DI nodes per scope.<br>
+ // Holders for the various debug information flags that we might need to<br>
+ // have exposed. See accessor functions below for description.<br>
+<br>
+ // Holder for imported entities.<br>
typedef SmallVector<std::pair<const MDNode *, const MDNode *>, 32><br>
- LocalDeclMap;<br>
- LocalDeclMap ScopesWithLocalDeclNodes;<br>
+ ImportedEntityMap;<br>
+ ImportedEntityMap ScopesWithImportedEntities;<br>
<br>
// Map from MDNodes for user-defined types to the type units that describe<br>
// them.<br>
@@ -616,12 +619,10 @@ public:<br>
<br>
const MachineFunction *getCurrentFunction() const { return CurFn; }<br>
<br>
- typedef iterator_range<LocalDeclMap::const_iterator> LocalDeclMapRange;<br>
-<br>
- LocalDeclMapRange findLocalDeclNodesForScope(const MDNode *Scope) const {<br>
- assert(DILexicalBlockBase::classof(Scope) && "Expected LexicalBlock scope");<br>
+ iterator_range<ImportedEntityMap::const_iterator><br>
+ findImportedEntitiesForScope(const MDNode *Scope) const {<br>
return make_range(std::equal_range(<br>
- ScopesWithLocalDeclNodes.begin(), ScopesWithLocalDeclNodes.end(),<br>
+ ScopesWithImportedEntities.begin(), ScopesWithImportedEntities.end(),<br>
std::pair<const MDNode *, const MDNode *>(Scope, nullptr),<br>
less_first()));<br>
}<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfUnit.cpp-3Frev-3D241176-26r1-3D241175-26r2-3D241176-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=PmKNmYfW9phTlYNiwYjT2vM2nH5KExn5pnd83zHFOFw&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp?rev=241176&r1=241175&r2=241176&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.cpp Wed Jul 1 13:07:16 2015<br>
@@ -704,7 +704,7 @@ DIE *DwarfUnit::createTypeDIE(const DICo<br>
return &TyDIE;<br>
}<br>
<br>
-DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode, DIE *ContextDIE) {<br>
+DIE *DwarfUnit::getOrCreateTypeDIE(const MDNode *TyNode) {<br>
if (!TyNode)<br>
return nullptr;<br>
<br>
@@ -714,20 +714,17 @@ DIE *DwarfUnit::getOrCreateTypeDIE(const<br>
<br>
// DW_TAG_restrict_type is not supported in DWARF2<br>
if (Ty->getTag() == dwarf::DW_TAG_restrict_type && DD->getDwarfVersion() <= 2)<br>
- return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType()),<br>
- ContextDIE);<br>
+ return getOrCreateTypeDIE(resolve(cast<DIDerivedType>(Ty)->getBaseType()));<br>
<br>
// Construct the context before querying for the existence of the DIE in case<br>
// such construction creates the DIE.<br>
auto *Context = resolve(Ty->getScope());<br>
- if (ContextDIE == nullptr)<br>
- ContextDIE = getOrCreateContextDIE(Context);<br>
+ DIE *ContextDIE = getOrCreateContextDIE(Context);<br>
+ assert(ContextDIE);<br>
<br>
if (DIE *TyDIE = getDIE(Ty))<br>
return TyDIE;<br>
<br>
- assert(ContextDIE);<br>
-<br>
// Create new type.<br>
DIE &TyDIE = createAndAddDIE(Ty->getTag(), *ContextDIE, Ty);<br>
<br>
<br>
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_lib_CodeGen_AsmPrinter_DwarfUnit.h-3Frev-3D241176-26r1-3D241175-26r2-3D241176-26view-3Ddiff&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=OTnkgUaYkov4BrhR4C0PUKhC51V6WrJATrMSIgM8tpk&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h?rev=241176&r1=241175&r2=241176&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h (original)<br>
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfUnit.h Wed Jul 1 13:07:16 2015<br>
@@ -298,9 +298,7 @@ public:<br>
bool Minimal = false);<br>
<br>
/// \brief Find existing DIE or create new DIE for the given type.<br>
- /// \param N Type Node<br>
- /// \param ContextDIE DIE scope for N Node, if available.<br>
- DIE *getOrCreateTypeDIE(const MDNode *N, DIE *ContextDIE = nullptr);<br>
+ DIE *getOrCreateTypeDIE(const MDNode *N);<br>
<br>
/// \brief Get context owner's DIE.<br>
DIE *createTypeDIE(const DICompositeType *Ty);<br>
<br>
Removed: llvm/trunk/test/DebugInfo/X86/lexical-block-pr19238.ll<br>
URL: <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.org_viewvc_llvm-2Dproject_llvm_trunk_test_DebugInfo_X86_lexical-2Dblock-2Dpr19238.ll-3Frev-3D241175-26view-3Dauto&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=sSHeN08zuEOtJ4O6lljNJALezv-q6LsyIo5dQjPam10&e=" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/test/DebugInfo/X86/lexical-block-pr19238.ll?rev=241175&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/test/DebugInfo/X86/lexical-block-pr19238.ll (original)<br>
+++ llvm/trunk/test/DebugInfo/X86/lexical-block-pr19238.ll (removed)<br>
@@ -1,129 +0,0 @@<br>
-; RUN: llc -mtriple=x86_64-unknown-linux-gnu -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s<br>
-<br>
-;; This test checks the following:<br>
-;; 1. Useless lexical block entry is not emitted<br>
-;; 2. Function static variable, typedef, records (structure, class and union)<br>
-;; that are defined in lexical basic block are emitted as children to<br>
-;; these lexical blocks.<br>
-;; * For typedef and record check that both are emitted in lexical block<br>
-;; where they are declared and not in the one where they are used.<br>
-;;<br>
-;; This test was generated by running following command:<br>
-;; clang -cc1 -O0 -g -emit-llvm foo.cpp<br>
-;; Where foo.cpp<br>
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
-;;int foo(void) {<br>
-;; {<br>
-;; {<br>
-;; struct X {<br>
-;; int x;<br>
-;; };<br>
-;; typedef int Y;<br>
-;; {<br>
-;; X a;<br>
-;; Y b;<br>
-;; static int c;<br>
-;; return a.x + b + c;<br>
-;; }<br>
-;; }<br>
-;; }<br>
-;;}<br>
-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;<br>
-<br>
-<br>
-; CHECK: DW_TAG_subprogram<br>
-; CHECK-NOT: DW_TAG<br>
-; CHECK: DW_AT_name {{.*}} "foo"<br>
-; CHECK-NOT: NULL<br>
-; CHECK: DW_TAG_lexical_block<br>
-<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_TAG_structure_type<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_AT_name {{.*}} "X"<br>
-; CHECK: NULL<br>
-<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_TAG_typedef<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_AT_name {{.*}} "Y"<br>
-<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_TAG_lexical_block<br>
-<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_TAG_variable<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_AT_name {{.*}} "c"<br>
-<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_TAG_variable<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_AT_name {{.*}} "a"<br>
-<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_TAG_variable<br>
-; CHECK-NOT: {{DW_TAG|NULL}}<br>
-; CHECK: DW_AT_name {{.*}} "b"<br>
-<br>
-; CHECK-NOT: {{DW_TAG}}<br>
-; CHECK: NULL<br>
-<br>
-<br>
-%struct.X = type { i32 }<br>
-<br>
-@_ZZ3foovE1c = internal global i32 0, align 4<br>
-<br>
-; Function Attrs: nounwind<br>
-define i32 @_Z3foov() #0 {<br>
-entry:<br>
- %a = alloca %struct.X, align 4<br>
- %b = alloca i32, align 4<br>
- call void @llvm.dbg.declare(metadata %struct.X* %a, metadata !21, metadata !22), !dbg !23<br>
- call void @llvm.dbg.declare(metadata i32* %b, metadata !24, metadata !22), !dbg !25<br>
- %x = getelementptr inbounds %struct.X, %struct.X* %a, i32 0, i32 0, !dbg !26<br>
- %0 = load i32, i32* %x, align 4, !dbg !26<br>
- %1 = load i32, i32* %b, align 4, !dbg !26<br>
- %add = add nsw i32 %0, %1, !dbg !26<br>
- %2 = load i32, i32* @_ZZ3foovE1c, align 4, !dbg !26<br>
- %add1 = add nsw i32 %add, %2, !dbg !26<br>
- ret i32 %add1, !dbg !26<br>
-}<br>
-<br>
-; Function Attrs: nounwind readnone<br>
-declare void @llvm.dbg.declare(metadata, metadata, metadata) #1<br>
-<br>
-attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }<br>
-attributes #1 = { nounwind readnone }<br>
-<br>
-!<a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__llvm.dbg.cu&d=AwMFaQ&c=8hUWFZcy2Z-Za5rBPlktOQ&r=mQ4LZ2PUj9hpadE3cDHZnIdEwhEBrbAstXeMaFoB9tg&m=GJpW5gfkFMQW5DYEp2a6kYgD8Snb-JG79Zonl1CJ_08&s=FBqIScWzpPY0CJatBp6ZMhA6wgVbbyt_7kT4JU8gqoM&e=" rel="noreferrer" target="_blank">llvm.dbg.cu</a> = !{!0}<br>
-!llvm.module.flags = !{!18, !19}<br>
-!llvm.ident = !{!20}<br>
-<br>
-!0 = !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.7.0 (trunk 237245)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, retainedTypes: !3, subprograms: !14, globals: !15, imports: !2)<br>
-!1 = !DIFile(filename: "foo.cpp", directory: "/")<br>
-!2 = !{}<br>
-!3 = !{!4, !13}<br>
-!4 = !DICompositeType(tag: DW_TAG_structure_type, name: "X", scope: !5, file: !1, line: 4, size: 32, align: 32, elements: !11)<br>
-!5 = distinct !DILexicalBlock(scope: !6, file: !1, line: 3)<br>
-!6 = distinct !DILexicalBlock(scope: !7, file: !1, line: 2)<br>
-!7 = !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: false, function: i32 ()* @_Z3foov, variables: !2)<br>
-!8 = !DISubroutineType(types: !9)<br>
-!9 = !{!10}<br>
-!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
-!11 = !{!12}<br>
-!12 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !4, file: !1, line: 5, baseType: !10, size: 32, align: 32)<br>
-!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "Y", scope: !5, file: !1, line: 7, baseType: !10)<br>
-!14 = !{!7}<br>
-!15 = !{!16}<br>
-!16 = !DIGlobalVariable(name: "c", scope: !17, file: !1, line: 11, type: !10, isLocal: true, isDefinition: true, variable: i32* @_ZZ3foovE1c)<br>
-!17 = distinct !DILexicalBlock(scope: !5, file: !1, line: 8)<br>
-!18 = !{i32 2, !"Dwarf Version", i32 4}<br>
-!19 = !{i32 2, !"Debug Info Version", i32 3}<br>
-!20 = !{!"clang version 3.7.0 (trunk 237245)"}<br>
-!21 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "a", scope: !17, file: !1, line: 9, type: !4)<br>
-!22 = !DIExpression()<br>
-!23 = !DILocation(line: 9, scope: !17)<br>
-!24 = !DILocalVariable(tag: DW_TAG_auto_variable, name: "b", scope: !17, file: !1, line: 10, type: !13)<br>
-!25 = !DILocation(line: 10, scope: !17)<br>
-!26 = !DILocation(line: 12, scope: !17)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu" target="_blank">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>