<div dir="ltr">It does, when the function has a body. When it doesn't, <a href="https://godbolt.org/g/2BCvht">it ignores</a>. The body might be provided later on in the toolchain via linking a library.<div><br clear="all"><div><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Regards,<div>Soham Sinha</div><div>PhD Student, Department of Computer Science</div><div>Boston University</div></div></div></div></div></div></div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr">On Tue, Jun 26, 2018 at 10:25 AM Hans Wennborg <<a href="mailto:hans@chromium.org">hans@chromium.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">It works for me:<br>
<br>
<a href="https://godbolt.org/g/3QzqAH" rel="noreferrer" target="_blank">https://godbolt.org/g/3QzqAH</a><br>
<br>
Can you share an example?<br>
<br>
On Tue, Jun 26, 2018 at 5:21 PM, Soham Sinha via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
> For the same reason GCC allowed the attribute. Even if I want to use/inline<br>
> a function later on in the pipeline.<br>
><br>
> Regards,<br>
> Soham Sinha<br>
> PhD Student, Department of Computer Science<br>
> Boston University<br>
><br>
><br>
> On Tue, Jun 26, 2018 at 8:30 AM <a href="http://mayuyu.io" rel="noreferrer" target="_blank">mayuyu.io</a> <<a href="mailto:admin@mayuyu.io" target="_blank">admin@mayuyu.io</a>> wrote:<br>
>><br>
>> Out of curiosity, how does an unused declaration affect the emitted object<br>
>> file<br>
>><br>
>> Zhang<br>
>><br>
>> > 在 2018年6月26日,08:48,Soham Sinha via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
>> > 写道:<br>
>> ><br>
>> > clang doesn't seem to respect __attribute__((used)) in C functions. Even<br>
>> > if I declare a function like the following: __attribute__((used)) void<br>
>> > function(), then also it doesn't declare the function in its IR file if I<br>
>> > don't use the function. Is there any other way to force the declaration of<br>
>> > "unused" function declarations with clang.<br>
>> ><br>
>> > I have hacked in clang 6.0.0 in<br>
>> > tools/clang/lib/CodeGen/CodeGenModule.cpp file. I changed in EmitGlobal<br>
>> > function to detect if the function has "used" attribute and then if it has<br>
>> > then use "GetOrCreateLLVMFunction" this to create the function declaration.<br>
>> > However, this hack fails in some other cases. Therefore I am looking for a<br>
>> > proper way to do this.<br>
>> ><br>
>> > Regards,<br>
>> > Soham Sinha<br>
>> > PhD Student, Department of Computer Science<br>
>> > Boston University<br>
>> > _______________________________________________<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>><br>
>><br>
>><br>
><br>
> _______________________________________________<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
><br>
</blockquote></div>