<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
Hi,
<div class=""><br class="">
</div>
<div class="">You should repost this to <a href="mailto:llvm-dev@lists.llvm.org" class="">
llvm-dev@lists.llvm.org</a>. This list is purely for auto generated bugzilla emails.</div>
<div class=""><br class="">
</div>
<div class="">Cheers,</div>
<div class=""><br class="">
</div>
<div class="">James<br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 29 Aug 2016, at 14:19, Christudasan D via llvm-bugs <<a href="mailto:llvm-bugs@lists.llvm.org" class="">llvm-bugs@lists.llvm.org</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<p class="MsoNormal">Greetings to all.</p>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal">I am facing a problem with LLVM 3.5 and suspect it is a bug. Here is my observation.</p>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal">I am trying to support a target specific function attribute for a particular target machine.
</p>
<p class="MsoNormal">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>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal">This virtual function (given below) invocation in clang/lib/CodeGen/CodeGenModule.cpp in clang is responsible for attaching the target specific attributes to the backend CodeGen objects (functions, variables etc.)</p>
<p class="MsoNormal" style="text-indent:0.5in">getTargetCodeGenInfo().SetTargetAttributes(D, GO, *this)</p>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal">I found that this virtual function is getting invoked only for function definitions and not for function declarations.</p>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal">Actual requirement:</p>
<p class="MsoNormal">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>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal"><b class=""><u class="">Is it really a bug?</u></b></p>
<p class="MsoNormal">When I compile a program having function declarations/prototypes with generic attributes like
<span style="color:rgb(127,0,85)" class="">__attribute__</span><span style="" class="">((</span><b class=""><span style="color:rgb(127,0,85)" class="">const</span></b><span style="" class="">)), clang will add it to that function’s attributelist in the IR and
 it will be available in the backend.</span></p>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal">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 class="">F.hasFnAttribute("XYZ")</b>, where XYZ is the new attribute name. </p>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal">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">Please write to me. </p>
<div class=""> <br class="webkit-block-placeholder">
</div>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">Christu </p>
</div>
_______________________________________________<br class="">
llvm-bugs mailing list<br class="">
<a href="mailto:llvm-bugs@lists.llvm.org" class="">llvm-bugs@lists.llvm.org</a><br class="">
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs<br class="">
</div>
</blockquote>
</div>
<br class="">
</div>
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose,
 or store or copy the information in any medium. Thank you.
</body>
</html>