<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><div>On Feb 19, 2013, at 1:18 AM, Chandler Carruth <<a href="mailto:chandlerc@google.com">chandlerc@google.com</a>> wrote:</div><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex; position: static; z-index: auto; ">there are two parts to libcall simplification:<br>
<br>
(1) recognizing that a call is to a function we understand (eg: printf);<br>
(2) generating a new call to a library function (eg: synthesizing memcpy).<br>
<br>
Plunking an attribute on a call to say "this isn't the printf function you know"<br>
seems kind of useful to me, even if it only takes care of (1).<br></blockquote><div><br></div><div style="">And what I'm wondering is if you could could annotate two cases in the frontend:<br></div><div style=""><br></div>
<div style="">a) Mark a call to a function 'foo' as no-builtin to prevent exactly *that* callsite from being transformed based on special knowledge of the function being called.</div></div></div></div></blockquote><div><br></div><div>Yes, this is necessary.</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div style=""><br></div><div style="">b) Mark a function definition of 'foo' as not being subject to synthesized calls to a library function.</div></div></div></div></blockquote><div><br></div><div>I don't understand why this is either necessary or sufficient.</div><br><blockquote type="cite"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">
<div style="">However, now that I think about it, I think there is an alternative to (b) that I like better, and actually goes particularly well with (a): for any 'foo' in '-fno-builtin-foo', *introduce* a declaration of the function and attach the 'no-builtin' attribute to it. If code goes on to define that function, great, attach the 'no-builtin' attribute to that. Attach it to all of the calls, etc.</div>
</div></div></div></blockquote><br></div><div>Among other problems, doing this would requires us to:</div><div><br></div><div>1. Add each of these to llvm.used (or add other hacks) to prevent them from being used.</div><div>2. Add a *ton* of function prototypes when -fno-builtin is passed (since there are dozens or hundreds of different "builtin" functions that we optimize.</div><div>3. Every time the optimizer learns to optimize some new libcall, we would have to change every llvm frontend that wants -fno-builtin to add the prototype.</div><div><br></div><div>Lets not do this! :)</div><div><br></div><div>-Chris</div><br></body></html>