[LLVMdev] [RFC] NoBuiltin Attribute

Chris Lattner clattner at apple.com
Tue Feb 19 10:26:45 PST 2013


On Feb 19, 2013, at 7:46 AM, Krzysztof Parzyszek <kparzysz at codeaurora.org> wrote:

> On 2/19/2013 12:31 AM, Bill Wendling wrote:
>> 
>> Yeah, that was in the one that I committed. I basically want something like this:
>> 
>>   define void @foo() "no-builtin" {
>>     call void @printf()
>>   }
>> 
>> And then the `call' to printf would check for the "no-builtin" attribute on `@foo' to determine if it can convert it to `puts'. Having the attribute on the declaration of `printf' doesn't help us here. And I'm not sure if having it on the call would be beneficial either.
> 
> Having the attribute on the prototype of printf would tell us that calls to printf cannot be converted to calls to anything else.  Isn't that what you want?

No, it isn't because that isn't sufficient.  Besides the example I gave in the other email to this thread, consider things like:

void foo() {
  auto fp = printf;
  fp("xyz\n");
}

With -fno-builtin-printf, we can't optimize the call to printf, even though it only becomes apparent after (trivial) devirtualization.

-Chris

> 
> If you want to prevent the optimizations on foo that take advantage of the knowledge about certain known functions, then we should use a different attribute for that, or else things can get really confusing.
> 
> -Krzysztof
> 
> -- 
> Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list