[LLVMdev] [RFC] NoBuiltin Attribute

Chris Lattner clattner at apple.com
Mon Feb 18 16:45:01 PST 2013


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.

-Chris



More information about the llvm-dev mailing list