[LLVMdev] [RFC] NoBuiltin Attribute

Bill Wendling wendling at apple.com
Mon Feb 18 16:49:13 PST 2013


On Feb 18, 2013, at 4:45 PM, Chris Lattner <clattner at apple.com> wrote:

> 
> On Feb 18, 2013, at 1:54 PM, Bill Wendling <wendling at apple.com> wrote:
> 
>> Hi LLVMites!
>> 
>> This patch adds the 'nobuiltin' attribute to to LLVM. This is needed during LTO, which right now ignores this attribute and command line flag. I want to make this an IR-level attribute instead of a target-dependent attribute because it's used during IR modification and not code generation.
>> 
> 
> 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. 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"

-bw





More information about the llvm-dev mailing list