<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">this change.</a></div><div><br></div><div>And according to the <a href="https://clang.llvm.org/docs/AttributeReference.html#artificial">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">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 class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>1 int bar(int);</span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>2<span class="gmail-Apple-converted-space"> </span></span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>3 inline int __attribute__((artificial)) __attribute__((always_inline)) foo(int x)</span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>4 {</span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>5 <span class="gmail-Apple-converted-space"> </span>return bar(x + 1);<span class="gmail-Apple-converted-space"> </span></span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>6 }</span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>7<span class="gmail-Apple-converted-space"> </span></span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>8 void baz(void)</span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>9 {</span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>10 <span class="gmail-Apple-converted-space"> </span>auto x = foo(1);</span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </span>11 <span class="gmail-Apple-converted-space"> </span>x = foo(2);</span></p>
<p class="gmail-p1" 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 class="gmail-Apple-converted-space"> </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>