<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;}
@font-face
{font-family:Consolas;
panose-1:2 11 6 9 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;}
p
{mso-style-priority:99;
mso-margin-top-alt:auto;
margin-right:0in;
mso-margin-bottom-alt:auto;
margin-left:0in;
font-size:12.0pt;
font-family:"Times New Roman",serif;}
pre
{mso-style-priority:99;
mso-style-link:"HTML Preformatted Char";
margin:0in;
margin-bottom:.0001pt;
font-size:10.0pt;
font-family:"Courier New";}
span.HTMLPreformattedChar
{mso-style-name:"HTML Preformatted Char";
mso-style-priority:99;
mso-style-link:"HTML Preformatted";
font-family:Consolas;}
span.EmailStyle20
{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">Hi,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">As we are talking about the code Adrian added, there is another issue with this code that leads into adding “DW_AT_abstract_origin” twice in the case when we
have an inline function that is emitted also as concrete function.<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">Source (test.cpp):<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
bar(</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> x) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> </span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">return</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
x+9;<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">}<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p> </o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
foo(</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">int</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> y) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">return</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> bar(y);<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">}</span><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"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Command line:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">clang "-cc1" "-triple" "x86_64-linux" "-emit-obj" "-debug-info-kind=standalone" "-O2" test.cpp "-o -" | llvm-dwarfdump -debug-dump=info –<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">0x0000002a: DW_TAG_subprogram [2] *<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> DW_AT_low_pc [DW_FORM_addr] (0x0000000000000000)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> DW_AT_high_pc [DW_FORM_data4] (0x00000004)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> DW_AT_APPLE_omit_frame_ptr [DW_FORM_flag_present] (true)<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> DW_AT_frame_base [DW_FORM_exprloc] (<0x1> 57 )<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">
<span style="background:yellow;mso-highlight:yellow">DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x004b => {0x0000004b} "_Z3bari")<o:p></o:p></span></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> <span style="background:yellow;mso-highlight:yellow">DW_AT_abstract_origin [DW_FORM_ref4] (cu + 0x004b => {0x0000004b} "_Z3bari")</span><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>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">This also happen due to “finishSubprogramDefinitions”:<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" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">void</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">DwarfDebug</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">::finishSubprogramDefinitions()
{<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">for</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">auto</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
&F : MMI->getModule()->functions())<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">auto</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
*SP = F.getSubprogram())<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> (ProcessedSPNodes.count(SP) &&<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> SP->getUnit()->getEmissionKind() !=
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">DICompileUnit</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">::</span><span style="font-size:9.5pt;font-family:Consolas;color:darkslategray;background:white;mso-highlight:white">NoDebug</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">)<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> forBothCUs(*CUMap.lookup(SP->getUnit()), [&](</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">DwarfCompileUnit</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
&</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white">CU</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white">CU</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">.finishSubprogramDefinition(SP);
</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><------------- This line adds the first
<span style="background:yellow;mso-highlight:yellow">DW_AT_abstract_origin</span></span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> });<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">for</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">auto</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
*AbsScope : LScopes.getAbstractScopesList())<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">auto</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
*SP = dyn_cast<</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">DISubprogram</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">>(AbsScope->getScopeNode()))<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white;mso-highlight:white">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> (ProcessedSPNodes.count(SP) &&<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> SP->getUnit()->getEmissionKind() !=
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">DICompileUnit</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">::</span><span style="font-size:9.5pt;font-family:Consolas;color:darkslategray;background:white;mso-highlight:white">NoDebug</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">)<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> forBothCUs(*CUMap.lookup(SP->getUnit()), [&](</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white;mso-highlight:white">DwarfCompileUnit</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
&</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white">CU</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">) {<o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white;mso-highlight:white">CU</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">.finishSubprogramDefinition(SP);
</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><------------- This line adds the second
<span style="background:yellow;mso-highlight:yellow">DW_AT_abstract_origin</span></span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"><o:p></o:p></span></p>
<p class="MsoNormal" style="text-autospace:none"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white"> });<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white;mso-highlight:white">}</span><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"><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"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></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"> David Blaikie [mailto:dblaikie@gmail.com]
<br>
<b>Sent:</b> Sunday, May 08, 2016 18:12<br>
<b>To:</b> Aboud, Amjad <amjad.aboud@intel.com><br>
<b>Cc:</b> Adrian Prantl <aprantl@apple.com>; llvm-dev <llvm-dev@lists.llvm.org>; Clang Dev <cfe-dev@lists.llvm.org><br>
<b>Subject:</b> Re: Debug info scope of explicit casting type does not seem correct<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">That'd be a bug - we should finish adding attributes to it at some point. If we can detect that it's never going to be handled (that it's been entirely optimized away) by the other codepaths, we should do it up-front. Otherwise we may need
to add it to a list somewhere to be handled.<br>
<br>
Ah, this probably regressed when we switched the direction of the link in subprograms (from CU->subprogram to subprogram->CU). Adrian?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Sun, May 8, 2016 at 1:13 AM, Aboud, Amjad <<a href="mailto:amjad.aboud@intel.com" target="_blank">amjad.aboud@intel.com</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">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">That happens because we create the subprogram below as a context to the “DW_TAG_typedef” that was created
as a type to “DW_TAG_pointer_type” that was added to the retained type list because of the explicit cast to (T*).</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">This is the code that creates DW_TAG_subprogram:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white">DIE</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> *</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white">DwarfUnit</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">::getOrCreateSubprogramDIE(</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">const</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white">DISubprogram</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> *</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white">SP</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">,
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">bool</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white">Minimal</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">...</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:green;background:white">// DW_TAG_inlined_subroutine may refer to this DIE.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white">DIE</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> &SPDie = createAndAddDIE(dwarf::</span><span style="font-size:9.5pt;font-family:Consolas;color:darkslategray;background:white">DW_TAG_subprogram</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">,
*ContextDIE, </span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white">SP</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:green;background:white">// Stop here and fill this in later, depending on whether or not this</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:green;background:white">// subprogram turns out to have inlined instances or not.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white">SP</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">->isDefinition())</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">return</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> &SPDie;
</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><------------- In our case the function returns here, and does not apply attributes</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> applySubprogramAttributes(</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white">SP</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">,
SPDie);</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">return</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> &SPDie;</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">}</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:9.5pt;font-family:Consolas;color:black"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">It assumes that later when the function is finalized the attributes will be applied, which is called
from this code:</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">void</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white">DwarfDebug</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">::finishSubprogramDefinitions() {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">for</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">auto</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
&F : MMI->getModule()->functions())</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> (</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">auto</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
*SP = F.getSubprogram())</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:blue;background:white">if</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> (ProcessedSPNodes.count(SP) &&</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> SP->getUnit()->getEmissionKind() !=
</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white">DICompileUnit</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">::</span><span style="font-size:9.5pt;font-family:Consolas;color:darkslategray;background:white">NoDebug</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">)</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> forBothCUs(*CUMap.lookup(SP->getUnit()), [&](</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;background:white">DwarfCompileUnit</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
&</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white">CU</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">) {</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">
</span><span style="font-size:9.5pt;font-family:Consolas;color:gray;background:white">CU</span><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">.finishSubprogramDefinition(SP);
</span><span style="font-size:9.5pt;font-family:Consolas;color:black"> </span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><------------- In our case, this code will not be reached for the above subprogram.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white"> });</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto;text-autospace:none">
<span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">...</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:9.5pt;font-family:Consolas;color:black;background:white">}</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">However, the function was optimized out and the code will not call “finishSubprogramDefinition” for
it, and attributes will not be added.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Regards,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Amjad</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a name="m_3997492950246121290__MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span></a><o:p></o:p></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" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a name="m_3997492950246121290______replyseparato"></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">
David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Saturday, May 07, 2016 21:38</span><o:p></o:p></p>
<div>
<div>
<p class="MsoNormal"><br>
<b>To:</b> Aboud, Amjad <<a href="mailto:amjad.aboud@intel.com" target="_blank">amjad.aboud@intel.com</a>><br>
<b>Cc:</b> Adrian Prantl <<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; Clang Dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: Debug info scope of explicit casting type does not seem correct<o:p></o:p></p>
</div>
</div>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Under what conditions do we produce a subprogram with no attributes? At first glance that certainly seems not useful, but perhaps there's a reason for it.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Sat, May 7, 2016 at 3:02 AM, Aboud, Amjad <<a href="mailto:amjad.aboud@intel.com" target="_blank">amjad.aboud@intel.com</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-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Hi David,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">OK, I got that DIE in Compile Unit scope may point to a DIE in subprogram scope.</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">But how about that we are emitting a subprogram entry that has no attributes?</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">0x0000002b: DW_TAG_subprogram [3] *<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">0x0000002c: DW_TAG_typedef [4]<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_type [DW_FORM_ref4] (cu + 0x0040 => {0x00000040})<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "T")<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_decl_file [DW_FORM_data1] ("c:\temp\ICL\LB\retain.cpp")<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_decl_line [DW_FORM_data1] (16)<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"> </span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Regards,</span><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D">Amjad</span><o:p></o:p></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" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><a name="m_3997492950246121290_m_-889567712679697"></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">
David Blaikie [mailto:<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>]
<br>
<b>Sent:</b> Saturday, April 30, 2016 17:59<br>
<b>To:</b> Aboud, Amjad <<a href="mailto:amjad.aboud@intel.com" target="_blank">amjad.aboud@intel.com</a>><br>
<b>Cc:</b> Adrian Prantl <<a href="mailto:aprantl@apple.com" target="_blank">aprantl@apple.com</a>>; llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>; Clang Dev <<a href="mailto:cfe-dev@lists.llvm.org" target="_blank">cfe-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: Debug info scope of explicit casting type does not seem correct</span><o:p></o:p></p>
</div>
</div>
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;margin-bottom:12.0pt">Yep, seems fine/reasonable to me. The pointer type has no logical scope so it doesn't really matter where its DIE goes.<br>
<br>
GCC does put the pointer type in the function scope in basic cases, but it can also end up in other places. For example:<o:p></o:p></p>
<pre><span style="color:black">blaikie@blaikie-linux:~/dev$ cat func.cpp</span><o:p></o:p></pre>
<pre><span style="color:black">void sink(void*);</span><o:p></o:p></pre>
<pre><span style="color:black">template<typename T></span><o:p></o:p></pre>
<pre><span style="color:black">void f1() {</span><o:p></o:p></pre>
<pre><span style="color:black"> T *t;</span><o:p></o:p></pre>
<pre><span style="color:black"> sink(&t);</span><o:p></o:p></pre>
<pre><span style="color:black">}</span><o:p></o:p></pre>
<pre><span style="color:black">void f2() {</span><o:p></o:p></pre>
<pre><span style="color:black"> struct foo { };</span><o:p></o:p></pre>
<pre><span style="color:black"> f1<foo>();</span><o:p></o:p></pre>
<pre><span style="color:black">}</span><o:p></o:p></pre>
<pre><span style="color:black">blaikie@blaikie-linux:~/dev$ g++-4.7 -std=c++11 func.cpp -g -c && llvm-dwarfdump-tot -debug-dump=info func.o | grep DW_TAG</span><o:p></o:p></pre>
<pre><span style="color:black">0x0000000b: DW_TAG_compile_unit [1] *</span><o:p></o:p></pre>
<pre><span style="color:black">0x0000002d: DW_TAG_subprogram [2] * // f2</span><o:p></o:p></pre>
<pre><span style="color:black">0x00000051: DW_TAG_lexical_block [3] </span><o:p></o:p></pre>
<pre><span style="color:black">0x00000062: DW_TAG_structure_type [4] </span><o:p></o:p></pre>
<pre><span style="color:black">0x0000006b: DW_TAG_subprogram [5] * // f1</span><o:p></o:p></pre>
<pre><span style="color:black">0x00000087: DW_TAG_template_type_parameter [6] </span><o:p></o:p></pre>
<pre><span style="color:black">0x0000008e: DW_TAG_lexical_block [7] *</span><o:p></o:p></pre>
<pre><span style="color:black">0x0000009f: DW_TAG_variable [8] </span><o:p></o:p></pre>
<pre><span style="color:black">0x000000ab: DW_TAG_pointer_type [9] // foo*</span><o:p></o:p></pre>
<pre><span style="color:black"> </span><o:p></o:p></pre>
<pre><span style="color:black">& in fact, if you introduce another template that's similar to f1, its variable's type is 0x00ab - so it points into f1's children. Seems GCC puts it in whatever scope first references the pointer type.</span><o:p></o:p></pre>
<pre><span style="color:black"> </span><o:p></o:p></pre>
<pre><span style="color:black">I think it's probably as sensible, and a bit simpler, to put any such basic types in the CU scope.</span><o:p></o:p></pre>
<pre><span style="color:black"> </span><o:p></o:p></pre>
<pre><span style="color:black">(granted, if GCC and Clang were really smart, the pointer type in f1 could be pointer to 0x0087 - but that would really bloat the debug info (now every different way of writing foo* in every different template would be a separate type description... - that would probably be not good))</span><o:p></o:p></pre>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">On Sat, Apr 30, 2016 at 3:32 AM, Aboud, Amjad <<a href="mailto:amjad.aboud@intel.com" target="_blank">amjad.aboud@intel.com</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-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi,<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I am wondering if this behavior of creating debug info is correct.<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">A type in compile unit entry is pointing to a type under subprogram entry?!<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">This is the root cause of
<a href="https://llvm.org/bugs/show_bug.cgi?id=27579" target="_blank">https://llvm.org/bugs/show_bug.cgi?id=27579</a><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">0x0000000b: DW_TAG_compile_unit [1] *<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">0x00000026: DW_TAG_pointer_type [2]<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_type [DW_FORM_ref4] (cu + 0x002c => {<span style="background:yellow">0x0000002c</span>})<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">0x0000002b: DW_TAG_subprogram [3] *<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="background:yellow">0x0000002c</span>: DW_TAG_typedef [4]<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_type [DW_FORM_ref4] (cu + 0x0040 => {0x00000040})<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000060] = "T")<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_decl_file [DW_FORM_data1] ("c:\temp\ICL\LB\retain.cpp")<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> DW_AT_decl_line [DW_FORM_data1] (16)<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">0x00000037: NULL<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">command line:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">clang -cc1 -triple i386-apple-ios9.0.0 -emit-obj -debug-info-kind=limited -O2 test.cpp –o - | llvm-dwarfdump -debug-dump=info -<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">> cat test.cpp<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">class A {<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">public:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> int x;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">};<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">class B {<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">public:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> typedef A type;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">};<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">template<typename X><o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">int foo(void* in) {<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> typedef typename X::type T;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> const T* p = (T*) in;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> return p->x;
<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">}<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">int bar() {<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">A a;<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> return foo<B>(&a);<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">}<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Reason for this behavior is the explicit cast “(T*)“, which leads into the following IR:<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 (trunk 267335)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug,
enums: !2, retainedTypes: <span style="background:yellow">!3</span>)<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="background:yellow">!3</span> = !{<span style="background:yellow">!4</span>}<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="background:yellow">!4</span> = !DIDerivedType(tag: DW_TAG_pointer_type, baseType:
<span style="background:yellow">!5</span>, size: 32, align: 32) <----------------- No Scope, leads to compile unit scope!!<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="background:yellow">!5</span> = !DIDerivedType(tag: DW_TAG_typedef, name: "T", scope:
<span style="background:yellow">!7</span>, file: !6, line: 16, baseType: !20)<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span style="background:yellow">!7</span> = distinct !<span style="background:yellow">DISubprogram</span>(name: "foo<B>", linkageName: "_Z3fooI1BEiPv", scope: !6, file: !6, line:
15, type: !8, isLocal: false, isDefinition: true, scopeLine: 15, flags: DIFlagPrototyped, isOptimized: true, unit: !0, templateParams: !12, variables: !15)<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Thanks,<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Amjad<o:p></o:p></p>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited<o:p></o:p></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.<o:p></o:p></p>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited<o:p></o:p></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.<o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal" style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
<div>
<div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited<o:p></o:p></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.<o:p></o:p></p>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</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>