<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri",sans-serif;
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri",sans-serif;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I believe it is safe to disable the assertion.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I added this assertion...I am trying to figure out why we are hitting it.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">I am not convinced that we should do a total revert.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Amjad<o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Alexey Samsonov [mailto:vonosmas@gmail.com]
<br>
<b>Sent:</b> Thursday, March 24, 2016 22:27<br>
<b>To:</b> Aboud, Amjad <amjad.aboud@intel.com><br>
<b>Cc:</b> cfe-commits <cfe-commits@lists.llvm.org><br>
<b>Subject:</b> Re: r264281 - Recommitted r263425 "Supporting all entities declared in lexical scope in LLVM debug info."<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Heads-up: I see segmentation faults in Clang following this revision. I will try to come up with a standalone reproducer and update <a href="https://llvm.org/bugs/show_bug.cgi?id=26942">https://llvm.org/bugs/show_bug.cgi?id=26942</a>, possibly
reverting this change.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Thu, Mar 24, 2016 at 6:30 AM, Amjad Aboud via cfe-commits <<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>> wrote:<o:p></o:p></p>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">Author: aaboud<br>
Date: Thu Mar 24 08:30:41 2016<br>
New Revision: 264281<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=264281&view=rev" target="_blank">
http://llvm.org/viewvc/llvm-project?rev=264281&view=rev</a><br>
Log:<br>
Recommitted r263425 "Supporting all entities declared in lexical scope in LLVM debug info."<br>
After fixing PR26942 (the fix is included in this commit).<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D18350" target="_blank">http://reviews.llvm.org/D18350</a><br>
<br>
Added:<br>
cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp<br>
- copied unchanged from r263435, cfe/trunk/test/CodeGenCXX/debug-info-lb.cpp<br>
Modified:<br>
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
cfe/trunk/lib/CodeGen/CGDebugInfo.h<br>
cfe/trunk/lib/CodeGen/CGDecl.cpp<br>
cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=264281&r1=264280&r2=264281&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=264281&r1=264280&r2=264281&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Thu Mar 24 08:30:41 2016<br>
@@ -831,15 +831,18 @@ llvm::DIType *CGDebugInfo::CreateType(co<br>
<br>
llvm::DIType *CGDebugInfo::CreateType(const TypedefType *Ty,<br>
llvm::DIFile *Unit) {<br>
+ TypedefNameDecl *TD = Ty->getDecl();<br>
// We don't set size information, but do specify where the typedef was<br>
// declared.<br>
- SourceLocation Loc = Ty->getDecl()->getLocation();<br>
+ SourceLocation Loc = TD->getLocation();<br>
+<br>
+ llvm::DIScope *TDContext = getDeclarationLexicalScope(*TD, QualType(Ty, 0));<br>
<br>
// Typedefs are derived from some other type.<br>
return DBuilder.createTypedef(<br>
getOrCreateType(Ty->getDecl()->getUnderlyingType(), Unit),<br>
Ty->getDecl()->getName(), getOrCreateFile(Loc), getLineNumber(Loc),<br>
- getDeclContextDescriptor(Ty->getDecl()));<br>
+ TDContext);<br>
}<br>
<br>
llvm::DIType *CGDebugInfo::CreateType(const FunctionType *Ty,<br>
@@ -1472,6 +1475,23 @@ llvm::DIType *CGDebugInfo::getOrCreateSt<br>
return T;<br>
}<br>
<br>
+void CGDebugInfo::recordDeclarationLexicalScope(const Decl &D) {<br>
+ assert(LexicalBlockMap.find(&D) == LexicalBlockMap.end() &&<br>
+ "D is already mapped to lexical block scope");<br>
+ if (!LexicalBlockStack.empty())<br>
+ LexicalBlockMap[&D] = LexicalBlockStack.back();<br>
+}<br>
+<br>
+llvm::DIScope *CGDebugInfo::getDeclarationLexicalScope(const Decl &D,<br>
+ QualType Ty) {<br>
+ auto I = LexicalBlockMap.find(&D);<br>
+ if (I != LexicalBlockMap.end()) {<br>
+ RetainedTypes.push_back(Ty.getAsOpaquePtr());<br>
+ return I->second;<br>
+ }<br>
+ return getDeclContextDescriptor(cast<Decl>(&D));<br>
+}<br>
+<br>
void CGDebugInfo::completeType(const EnumDecl *ED) {<br>
if (DebugKind <= codegenoptions::DebugLineTablesOnly)<br>
return;<br>
@@ -2057,7 +2077,7 @@ llvm::DIType *CGDebugInfo::CreateEnumTyp<br>
// entered into the ReplaceMap: finalize() will replace the first<br>
// FwdDecl with the second and then replace the second with<br>
// complete type.<br>
- llvm::DIScope *EDContext = getDeclContextDescriptor(ED);<br>
+ llvm::DIScope *EDContext = getDeclarationLexicalScope(*ED, QualType(Ty, 0));<br>
llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());<br>
llvm::TempDIScope TmpContext(DBuilder.createReplaceableCompositeType(<br>
llvm::dwarf::DW_TAG_enumeration_type, "", TheCU, DefUnit, 0));<br>
@@ -2101,7 +2121,7 @@ llvm::DIType *CGDebugInfo::CreateTypeDef<br>
<br>
llvm::DIFile *DefUnit = getOrCreateFile(ED->getLocation());<br>
unsigned Line = getLineNumber(ED->getLocation());<br>
- llvm::DIScope *EnumContext = getDeclContextDescriptor(ED);<br>
+ llvm::DIScope *EnumContext = getDeclarationLexicalScope(*ED, QualType(Ty, 0));<br>
llvm::DIType *ClassTy =<br>
ED->isFixed() ? getOrCreateType(ED->getIntegerType(), DefUnit) : nullptr;<br>
return DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit,<br>
@@ -2362,7 +2382,7 @@ llvm::DICompositeType *CGDebugInfo::Crea<br>
unsigned Line = getLineNumber(RD->getLocation());<br>
StringRef RDName = getClassName(RD);<br>
<br>
- llvm::DIScope *RDContext = getDeclContextDescriptor(RD);<br>
+ llvm::DIScope *RDContext = getDeclarationLexicalScope(*RD, QualType(Ty, 0));<br>
<br>
// If we ended up creating the type during the context chain construction,<br>
// just return that.<br>
@@ -2509,8 +2529,15 @@ void CGDebugInfo::collectVarDeclProps(co<br>
if (DC->isRecord())<br>
DC = CGM.getContext().getTranslationUnitDecl();<br>
<br>
- llvm::DIScope *Mod = getParentModuleOrNull(VD);<br>
- VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);<br>
+ if (VD->isStaticLocal()) {<br>
+ // Get context for static locals (that are technically globals) the same way<br>
+ // we do for "local" locals -- by using current lexical block.<br>
+ assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");<br>
+ VDContext = LexicalBlockStack.back();<br>
+ } else {<br>
+ llvm::DIScope *Mod = getParentModuleOrNull(VD);<br>
+ VDContext = getContextDescriptor(cast<Decl>(DC), Mod ? Mod : TheCU);<br>
+ }<br>
}<br>
<br>
llvm::DISubprogram *<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=264281&r1=264280&r2=264281&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.h?rev=264281&r1=264280&r2=264281&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDebugInfo.h (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.h Thu Mar 24 08:30:41 2016<br>
@@ -116,6 +116,11 @@ class CGDebugInfo {<br>
<br>
/// Keep track of our current nested lexical block.<br>
std::vector<llvm::TypedTrackingMDRef<llvm::DIScope>> LexicalBlockStack;<br>
+<br>
+ /// Map of AST declaration to its lexical block scope.<br>
+ llvm::DenseMap<const Decl *, llvm::TypedTrackingMDRef<llvm::DIScope>><br>
+ LexicalBlockMap;<br>
+<br>
llvm::DenseMap<const Decl *, llvm::TrackingMDRef> RegionMap;<br>
/// Keep track of LexicalBlockStack counter at the beginning of a<br>
/// function. This is used to pop unbalanced regions at the end of a<br>
@@ -378,6 +383,12 @@ public:<br>
/// Emit an Objective-C interface type standalone debug info.<br>
llvm::DIType *getOrCreateInterfaceType(QualType Ty, SourceLocation Loc);<br>
<br>
+ /// Map AST declaration to its lexical block scope if available.<br>
+ void recordDeclarationLexicalScope(const Decl &D);<br>
+<br>
+ /// Get lexical scope of AST declaration.<br>
+ llvm::DIScope *getDeclarationLexicalScope(const Decl &D, QualType Ty);<br>
+<br>
/// Emit standalone debug info for a type.<br>
llvm::DIType *getOrCreateStandaloneType(QualType Ty, SourceLocation Loc);<br>
<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGDecl.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=264281&r1=264280&r2=264281&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDecl.cpp?rev=264281&r1=264280&r2=264281&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CGDecl.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGDecl.cpp Thu Mar 24 08:30:41 2016<br>
@@ -87,11 +87,7 @@ void CodeGenFunction::EmitDecl(const Dec<br>
case Decl::UsingShadow:<br>
case Decl::ObjCTypeParam:<br>
llvm_unreachable("Declaration should not be in declstmts!");<br>
- case Decl::Function: // void X();<br>
- case Decl::Record: // struct/union/class X;<br>
- case Decl::Enum: // enum X;<br>
- case Decl::EnumConstant: // enum ? { X = ? }<br>
- case Decl::CXXRecord: // struct/union/class X; [C++]<br>
+ case Decl::Function: // void X();<br>
case Decl::StaticAssert: // static_assert(X, ""); [C++0x]<br>
case Decl::Label: // __label__ x;<br>
case Decl::Import:<br>
@@ -101,13 +97,21 @@ void CodeGenFunction::EmitDecl(const Dec<br>
// None of these decls require codegen support.<br>
return;<br>
<br>
+ case Decl::Record: // struct/union/class X;<br>
+ case Decl::Enum: // enum X;<br>
+ case Decl::EnumConstant: // enum ? { X = ? }<br>
+ case Decl::CXXRecord: // struct/union/class X; [C++]<br>
+ if (CGDebugInfo *DI = getDebugInfo())<br>
+ DI->recordDeclarationLexicalScope(D);<br>
+ return;<br>
+<br>
case Decl::NamespaceAlias:<br>
if (CGDebugInfo *DI = getDebugInfo())<br>
- DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));<br>
+ DI->EmitNamespaceAlias(cast<NamespaceAliasDecl>(D));<br>
return;<br>
case Decl::Using: // using X; [C++]<br>
if (CGDebugInfo *DI = getDebugInfo())<br>
- DI->EmitUsingDecl(cast<UsingDecl>(D));<br>
+ DI->EmitUsingDecl(cast<UsingDecl>(D));<br>
return;<br>
case Decl::UsingDirective: // using namespace X; [C++]<br>
if (CGDebugInfo *DI = getDebugInfo())<br>
@@ -128,6 +132,9 @@ void CodeGenFunction::EmitDecl(const Dec<br>
const TypedefNameDecl &TD = cast<TypedefNameDecl>(D);<br>
QualType Ty = TD.getUnderlyingType();<br>
<br>
+ if (CGDebugInfo *DI = getDebugInfo())<br>
+ DI->recordDeclarationLexicalScope(D);<br>
+<br>
if (Ty->isVariablyModifiedType())<br>
EmitVariablyModifiedType(Ty);<br>
}<br>
<br>
Modified: cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp?rev=264281&r1=264280&r2=264281&view=diff" target="_blank">
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp?rev=264281&r1=264280&r2=264281&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp (original)<br>
+++ cfe/trunk/test/CodeGenCXX/debug-info-anon-union-vars.cpp Thu Mar 24 08:30:41 2016<br>
@@ -44,7 +44,12 @@ void instantiate(int x) {<br>
buildBytes(x);<br>
}<br>
<br>
+// CHECK: ![[UNION:[0-9]+]] = !DICompositeType(tag: DW_TAG_union_type,<br>
+// CHECK-NOT: name:<br>
+// CHECK: elements<br>
// CHECK: [[FILE:.*]] = !DIFile(filename: "{{.*}}debug-info-anon-union-vars.cpp",<br>
+// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],<br>
+// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],<br>
// CHECK: !DIGlobalVariable(name: "c",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true<br>
// CHECK: !DIGlobalVariable(name: "d",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true<br>
// CHECK: !DIGlobalVariable(name: "a",{{.*}} file: [[FILE]], line: 6,{{.*}} isLocal: true, isDefinition: true<br>
@@ -55,9 +60,4 @@ void instantiate(int x) {<br>
// CHECK: !DILocalVariable(name: "c", {{.*}}, flags: DIFlagArtificial<br>
// CHECK: !DILocalVariable(<br>
// CHECK-NOT: name:<br>
-// CHECK: type: ![[UNION:[0-9]+]]<br>
-// CHECK: ![[UNION]] = !DICompositeType(tag: DW_TAG_union_type,<br>
-// CHECK-NOT: name:<br>
-// CHECK: elements<br>
-// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "i", scope: ![[UNION]],<br>
-// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "c", scope: ![[UNION]],<br>
+// CHECK: type: ![[UNION]]<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br>
<br clear="all">
<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p class="MsoNormal">-- <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">Alexey Samsonov<br>
<a href="mailto:vonosmas@gmail.com" target="_blank">vonosmas@gmail.com</a><o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p>
<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>