[llvm-dev] about __attribute__((artificial)) and inline pass

Fangqing Du via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 28 09:43:41 PST 2022


Dear all,

In clang/llvm 7.0, `__attribute__((artificial))` can be identified by clang
and attach `DIFlagArtificial` into function metadata in this change.
<https://reviews.llvm.org/D43259#change-jbvcnfxttyAz>

And according to the specification
<https://clang.llvm.org/docs/AttributeReference.html#artificial> 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.

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.
Here is my experiment: godbolt experiment link
<https://godbolt.org/z/oW8Td5d4M>

Is my understanding correct?
Thanks,
Fangqing
Xilinx Inc.

== ------------ example -------------===

  1 int bar(int);

  2

  3 inline int __attribute__((artificial)) __attribute__((always_inline))
foo(int x)

  4 {

  5     return bar(x + 1);

  6 }

  7

  8 void baz(void)

  9 {

 10     auto x = foo(1);

 11     x = foo(2);

 12 }

When function 'foo' is inlined, the debug location of call instruction
'bar' still points to line #5, instead of line #10 and #11.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20220128/f5ee0a55/attachment.html>


More information about the llvm-dev mailing list