[LLVMdev] [RFC] NoBuiltin Attribute

Chris Lattner clattner at apple.com
Mon Feb 18 18:10:48 PST 2013


On Feb 18, 2013, at 4:49 PM, Bill Wendling <wendling at apple.com> wrote:
>> Hi Bill,
>> 
>> I think the concept of this patch makes sense, but the implementation does not.
>> 
>> I have:
>> 
>> void foo() {
>> printf("hello\n");
>> }
>> 
>> and I build with -fno-builtin-puts.  If I understand correctly, *foo* will be marked with "nobuiltin", but this code in simplifylibcalls looks at the printf:
>> 
>> Value *LibCallSimplifier::optimizeCall(CallInst *CI) {
>> +  Function *F = CI->getCalledFunction();
>> +  if (F->hasFnAttribute(Attribute::NoBuiltin)) return 0;
>>  return Impl->optimizeCall(CI);
>> }
>> 
>> In the context of LTO, it makes sense for the attribute to be on function bodies, not on prototypes.
>> 
> Yeah, I noticed that after sending this patch. I modified it to check the function CI is in for that attribute.

Was that in the patch you committed?  What specific patch are you looking for?

> Once we have support for the `-fno-builtin-FUNCTION' flag, I expect the attribute to look something like this:
> 
> 	"no-builtin-functions" = "puts,foo,bar"

I guess this could work, this means that simplifylibcalls (and others) would check this instead of TargetLibraryInfo?

Out of curiosity, how important is -fno-builtin-foo?  Isn't it enough to just have -fno-builtin-foo disable *all* builtin optimizations for the unit of code being compiled?  This is overly conservative - is that actually a problem for something?

-Chris



More information about the llvm-dev mailing list