[llvm-commits] [llvm] r56885 - in /llvm/trunk: include/llvm/Target/TargetLowering.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Su

Devang Patel dpatel at apple.com
Tue Sep 30 15:10:10 PDT 2008


On Sep 30, 2008, at 2:52 PM, Bill Wendling wrote:

> On Tue, Sep 30, 2008 at 2:49 PM, Devang Patel <dpatel at apple.com>  
> wrote:
>>
>> On Sep 30, 2008, at 2:22 PM, Bill Wendling wrote:
>>
>>> Author: void
>>> Date: Tue Sep 30 16:22:07 2008
>>> New Revision: 56885
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=56885&view=rev
>>> Log:
>>> Add the new `-no-builtin' flag. This flag is meant to mimic the GCC
>>> `-fno-builtin' flag. Currently, it's used to replace "memset" with
>>> "_bzero"
>>> instead of "__bzero" on Darwin10+. This arguably violates the
>>> meaning of this
>>> flag, but is currently sufficient. The meaning of this flag should
>>> become more
>>> specific over time.
>>
>> Is it possible encode this in IR as an attribute ?
>>
>> Right now this info. is lost during
>> 1) llvm-gcc -c --emit-llvm -fno-builtin foo.c -o foo.bc && llc  
>> foo.bc -
>> o foo.s
>> 2) and LTO.
>>
> Sure! How do you do that? :-)

Here is completely untested patch to begin with...

Index: include/llvm/Attributes.h
===================================================================
--- include/llvm/Attributes.h	(revision 56886)
+++ include/llvm/Attributes.h	(working copy)
@@ -47,6 +47,7 @@
  const Attributes NoInline        = 1<<11; // inline=never
  const Attributes AlwaysInline    = 1<<12; // inline=always
  const Attributes OptimizeForSize = 1<<13; // opt_size
+const Attributes NoBuiltin       = 1<<14; // Do not use builtins
  const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter  
(16 bits)
                                      // 0 = unknown, else in clear  
(not log)

Index: lib/VMCore/Attributes.cpp
===================================================================
--- lib/VMCore/Attributes.cpp	(revision 56886)
+++ lib/VMCore/Attributes.cpp	(working copy)
@@ -53,6 +53,8 @@
      Result += "noinline ";
    if (Attrs & Attribute::AlwaysInline)
      Result += "alwaysinline ";
+  if (Attrs & Attribute::NoBuiltIn)
+    Result += "nobuiltin ";
    if (Attrs & Attribute::Alignment) {
      Result += "align ";
      Result += utostr((Attrs & Attribute::Alignment) >> 16);
Index: lib/AsmParser/llvmAsmParser.y
===================================================================
--- lib/AsmParser/llvmAsmParser.y	(revision 56886)
+++ lib/AsmParser/llvmAsmParser.y	(working copy)
@@ -1121,7 +1121,7 @@

  // Function Attributes
  %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
-%token READNONE READONLY GC OPTSIZE NOINLINE ALWAYSINLINE
+%token READNONE READONLY GC OPTSIZE NOINLINE ALWAYSINLINE NOBUILTIN

  // Visibility Styles
  %token DEFAULT HIDDEN PROTECTED
@@ -1293,8 +1293,9 @@
                | READNONE { $$ = Attribute::ReadNone; }
                | READONLY { $$ = Attribute::ReadOnly; }
                | NOINLINE { $$ = Attribute::NoInline }
-              | ALWAYSINLINE { $$ = Attribute::AlwaysInline }
-              | OPTSIZE { $$ = Attribute::OptimizeForSize }
+              | ALWAYSINLINE { $$ = Attribute::AlwaysInline; }
+              | OPTSIZE { $$ = Attribute::OptimizeForSize; }
+              | NOBUILTIN { $$ = Attribute::NoBuiltin; }
                ;

  OptFuncAttrs  : /* empty */ { $$ = Attribute::None; }
Index: lib/AsmParser/LLLexer.cpp
===================================================================
--- lib/AsmParser/LLLexer.cpp	(revision 56886)
+++ lib/AsmParser/LLLexer.cpp	(working copy)
@@ -499,6 +499,7 @@
    KEYWORD("noinline", NOINLINE);
    KEYWORD("alwaysinline", ALWAYSINLINE);
    KEYWORD("optsize", OPTSIZE);
+  KEYWORD("nobuiltin", NOBUILTIN);

    KEYWORD("type", TYPE);
    KEYWORD("opaque", OPAQUE);




More information about the llvm-commits mailing list