<div dir="ltr">LLVM 3.5 is 2+ years old, and 4 releases old now :)<div>The immediate response would be "try it with a newer version, and see if it works".</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Aug 29, 2016 at 9:51 PM, Christudasan D via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><p class="MsoNormal" style="font-size:12.8px">Greetings to all.</p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px">I am facing a problem with LLVM 3.5 and suspect it is a bug. Here is my observation.</p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px">I am trying to support a target specific function attribute for a particular target machine.</p><p class="MsoNormal" style="font-size:12.8px">Having followed the steps specified in the compiler documentation, I see the attribute is passed to the backend if we include the attribute in the function definition. But this attribute is not propagate to the backend if I include it only in the function’s prototype/declaration (in the C program).</p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px">This virtual function (given below) invocation in clang/lib/CodeGen/CodeGenModul<wbr>e.cpp in clang is responsible for attaching the target specific attributes to the backend CodeGen objects (functions, variables etc.)</p><p class="MsoNormal" style="font-size:12.8px;text-indent:0.5in">getTargetCodeGenInfo().SetTarg<wbr>etAttributes(D, GO, *this)</p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px">I found that this virtual function is getting invoked only for function definitions and not for function declarations.</p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px">Actual requirement:</p><p class="MsoNormal" style="font-size:12.8px">Along with regular C functions we have special functions supported in the target and its definition and invocation will always come in different compilation units. There must be a way to recognize these special functions at the call-sites during codegen in the backend. By attaching some info in the function prototype, we can recognize these special functions at the call-site during backend codegen. That’s why I thought of a new target specific attribute to achieve this purpose.</p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px"><b><u>Is it really a bug?</u></b></p><p class="MsoNormal" style="font-size:12.8px">When I compile a program having function declarations/prototypes with generic attributes like <span style="color:rgb(127,0,85)">__attribute__</span><span style="color:black">((</span><b><span style="color:rgb(127,0,85)">const</span></b><span style="color:black">)), clang will add it to that function’s attributelist in the IR and it will be available in the backend.</span></p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px">Similarly I expected the target specific attribute should also be added to the attributelist available in the backend and I should be able to identify it using <b>F.hasFnAttribute("XYZ")</b>, where XYZ is the new attribute name.</p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px">Since I work with LLVM 3.5 code-base, I am not sure whether this issue (if it is really a bug) has already been fixed with recent compiler releases.</p><p class="MsoNormal" style="font-size:12.8px">Please write to me.</p><p class="MsoNormal" style="font-size:12.8px"> </p><p class="MsoNormal" style="font-size:12.8px">Thanks,</p><p class="MsoNormal" style="font-size:12.8px">Christu </p></div>
<br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">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/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>