<div dir="ltr"><div dir="ltr">On Fri, Jan 28, 2022 at 11:26 AM Reid Kleckner <<a href="mailto:rnk@google.com">rnk@google.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>I thought `artificial` and `nodebug` were supposed to be synonyms, just different names invented by different communities. </div></div></blockquote><div><br>Doesn't look like it, based on the GCC documentation and behavior - GCC puts the DW_AT_artificial attribute on the entity, but still fully describes it (DWARF remains the same except for that attribute). I think the second option in the GCC docs is for debug info formats that don't have an equivalent of DW_AT_artificial, in which case it downgrades to the equivalent of "nodebug".<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>The linked patch doesn't implement the LLVM side of things, so I'm not sure when that got added.<br></div></div></blockquote><div><br>The patch added the artificial flag on the metadata which was already implemented/supported in LLVM (used for things like implicit constructors, etc, which don't have user-written code in them) and matches the GCC behavior - no extra work was needed on the LLVM side.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 28, 2022 at 11:03 AM David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hmm, seems I missed this feature (or at least don't remember) when it went in.<br><br>Looks like the GCC spec might be more accurate to the current implementation than what Clang's documentation says:<br><br>"<span style="color:rgb(0,0,0);font-family:Times;font-size:medium">artificial</span><dl><dd style="color:rgb(0,0,0);font-family:Times;font-size:medium"><a name="m_8334339238115289765_m_4238466721377605530_index-g_t_0040code_007bartificial_007d-function-attribute-2500"></a>This attribute is useful for small inline wrappers which if possible should appear during debugging as a unit, depending on the debug info format it will either mean marking the function as artificial or using the caller location for all instructions within the inlined body."</dd></dl><br>& the "marking the function as artificial" is the thing that this patch implemented in Clang. This did not have the same effect as nodebug, and doesn't "use the caller location for all instructions within the inlined body".<br><br>It's possible we could implement the "artificial" attribute as a an alias for "nodebug" which would also be conforming with GCC's spec, but would be less expressive than the current implementation (though would save debug info size in a way the current Clang implementation does not).<br><br>It looks like Clang's implementation is consistent with GCC's implementation for DWARF - "marking the function as artificial", not "using the caller location for instructions within the inlined body", but Clang's documentation is incorrect, since it documents the latter and not the former.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Jan 28, 2022 at 9:44 AM Fangqing Du via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Dear all,</div><div><br></div><div>In clang/llvm 7.0, `__attribute__((artificial))` can be identified by clang and attach `DIFlagArtificial` into function metadata in <a href="https://reviews.llvm.org/D43259#change-jbvcnfxttyAz" target="_blank">this change.</a></div><div><br></div><div>And according to the <a href="https://clang.llvm.org/docs/AttributeReference.html#artificial" target="_blank">specification</a> of `artificial`, if I understand correctly, when the function (which is marked with `artificial` attribute) is inlined, the inlined function instructions should be associated with the callsite line number, instead of the line of inlined callee.</div><br><div>But from my observation, with and without this attribute, the inline pass behavior is not affected, and inlined instructions debug location still point to the callee instead of callsite.</div><div>Here is my experiment: <a href="https://godbolt.org/z/oW8Td5d4M" target="_blank">godbolt experiment link</a></div><div><br></div><div>Is my understanding correct?</div><div>Thanks,</div><div>Fangqing</div><div>Xilinx Inc.</div><div><br></div><div>== ------------ example -------------===</div><div>





<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>1 int bar(int);</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>2<span> </span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>3 inline int __attribute__((artificial)) __attribute__((always_inline)) foo(int x)</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>4 {</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>5 <span>    </span>return bar(x + 1);<span> </span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>6 }</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>7<span> </span></span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>8 void baz(void)</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span>  </span>9 {</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span> </span>10 <span>    </span>auto x = foo(1);</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span> </span>11 <span>    </span>x = foo(2);</span></p>
<p style="margin:0px;font-variant-numeric:normal;font-variant-east-asian:normal;font-stretch:normal;font-size:13px;line-height:normal;font-family:"Helvetica Neue""><span style="background-color:rgb(204,204,204)"><span> </span>12 }</span></p></div><div><br></div><div>When function 'foo' is inlined, the debug location of call instruction 'bar' still points to line #5, instead of line #10 and #11.</div></div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>