Implement function notes as function attributes. 



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56716 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AsmParser/LLLexer.cpp b/lib/AsmParser/LLLexer.cpp
index 16f4e15..39d62bf 100644
--- a/lib/AsmParser/LLLexer.cpp
+++ b/lib/AsmParser/LLLexer.cpp
@@ -496,11 +496,9 @@
   KEYWORD("readnone", READNONE);
   KEYWORD("readonly", READONLY);
 
-  KEYWORD("notes",  FNNOTE);
-  KEYWORD("inline", INLINE);
-  KEYWORD("always", ALWAYS);
-  KEYWORD("never", NEVER);
-  KEYWORD("opt_size", OPTIMIZEFORSIZE);
+  KEYWORD("noinline", NOINLINE);
+  KEYWORD("alwaysinline", ALWAYSINLINE);
+  KEYWORD("optsize", OPTSIZE);
 
   KEYWORD("type", TYPE);
   KEYWORD("opaque", OPAQUE);
diff --git a/lib/AsmParser/llvmAsmParser.h.cvs b/lib/AsmParser/llvmAsmParser.h.cvs
index 59f18dd..6caebc8 100644
--- a/lib/AsmParser/llvmAsmParser.h.cvs
+++ b/lib/AsmParser/llvmAsmParser.h.cvs
@@ -189,14 +189,12 @@
      READNONE = 405,
      READONLY = 406,
      GC = 407,
-     FNNOTE = 408,
-     INLINE = 409,
-     ALWAYS = 410,
-     NEVER = 411,
-     OPTIMIZEFORSIZE = 412,
-     DEFAULT = 413,
-     HIDDEN = 414,
-     PROTECTED = 415
+     OPTSIZE = 408,
+     NOINLINE = 409,
+     ALWAYSINLINE = 410,
+     DEFAULT = 411,
+     HIDDEN = 412,
+     PROTECTED = 413
    };
 #endif
 /* Tokens.  */
@@ -350,21 +348,19 @@
 #define READNONE 405
 #define READONLY 406
 #define GC 407
-#define FNNOTE 408
-#define INLINE 409
-#define ALWAYS 410
-#define NEVER 411
-#define OPTIMIZEFORSIZE 412
-#define DEFAULT 413
-#define HIDDEN 414
-#define PROTECTED 415
+#define OPTSIZE 408
+#define NOINLINE 409
+#define ALWAYSINLINE 410
+#define DEFAULT 411
+#define HIDDEN 412
+#define PROTECTED 413
 
 
 
 
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 typedef union YYSTYPE
-#line 970 "/Volumes/MacOS9/gcc/llvm/lib/AsmParser/llvmAsmParser.y"
+#line 970 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
 {
   llvm::Module                           *ModuleVal;
   llvm::Function                         *FunctionVal;
@@ -413,7 +409,7 @@
   llvm::FCmpInst::Predicate         FPredicate;
 }
 /* Line 1529 of yacc.c.  */
-#line 417 "llvmAsmParser.tab.h"
+#line 413 "llvmAsmParser.tab.h"
 	YYSTYPE;
 # define yystype YYSTYPE /* obsolescent; will be withdrawn */
 # define YYSTYPE_IS_DECLARED 1
diff --git a/lib/AsmParser/llvmAsmParser.y b/lib/AsmParser/llvmAsmParser.y
index a049cea..fa86c18 100644
--- a/lib/AsmParser/llvmAsmParser.y
+++ b/lib/AsmParser/llvmAsmParser.y
@@ -1089,8 +1089,6 @@
 %type <UIntVal> OptCallingConv LocalNumber
 %type <Attributes> OptAttributes Attribute
 %type <Attributes> OptFuncAttrs  FuncAttr
-%type <Attributes> OptFuncNotes FuncNote
-%type <Attributes> FuncNoteList
 
 // Basic Block Terminating Operators
 %token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
@@ -1122,10 +1120,7 @@
 
 // Function Attributes
 %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
-%token READNONE READONLY GC
-
-// Function Notes
-%token FNNOTE INLINE ALWAYS NEVER OPTIMIZEFORSIZE
+%token READNONE READONLY GC OPTSIZE NOINLINE ALWAYSINLINE
 
 // Visibility Styles
 %token DEFAULT HIDDEN PROTECTED
@@ -1284,6 +1279,9 @@
               | SIGNEXT  { $$ = Attribute::SExt;     }
               | READNONE { $$ = Attribute::ReadNone; }
               | READONLY { $$ = Attribute::ReadOnly; }
+              | NOINLINE { $$ = Attribute::NoInline }
+              | ALWAYSINLINE { $$ = Attribute::AlwaysInline }
+              | OPTSIZE { $$ = Attribute::OptimizeForSize }
               ;
 
 OptFuncAttrs  : /* empty */ { $$ = Attribute::None; }
@@ -1292,31 +1290,6 @@
               }
               ;
 
-FuncNoteList  : FuncNote { $$ = $1; }
-              | FuncNoteList ',' FuncNote {
-                unsigned tmp = $1 | $3;
-                if ($3 == Attribute::NoInline
-                    && ($1 & Attribute::AlwaysInline))
-                  GEN_ERROR("Function Notes may include only one inline notes!")
-                    if ($3 == Attribute::AlwaysInline
-                        && ($1 & Attribute::NoInline))
-                  GEN_ERROR("Function Notes may include only one inline notes!")
-                $$ = tmp;
-                CHECK_FOR_ERROR
-              }
-              ;
-
-FuncNote      : INLINE '=' NEVER { $$ = Attribute::NoInline; }
-              | INLINE '=' ALWAYS { $$ = Attribute::AlwaysInline; }
-              | OPTIMIZEFORSIZE { $$ = Attribute::OptimizeForSize; }
-              ;
-
-OptFuncNotes  : /* empty */ { $$ = Attribute::None; }
-              | FNNOTE '(' FuncNoteList  ')' {
-                $$ =  $3;
-              }
-              ;
-
 OptGC         : /* empty */ { $$ = 0; }
               | GC STRINGCONSTANT {
                 $$ = $2;
@@ -2332,7 +2305,7 @@
   };
 
 FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
-                  OptFuncAttrs OptSection OptAlign OptGC OptFuncNotes {
+                  OptFuncAttrs OptSection OptAlign OptGC {
   std::string FunctionName(*$3);
   delete $3;  // Free strdup'd memory!
 
@@ -2453,9 +2426,6 @@
     Fn->setGC($10->c_str());
     delete $10;
   }
-  if ($11) {
-    Fn->setNotes($11);
-  }
 
   // Add all of the arguments we parsed to the function...
   if ($5) {                     // Is null if empty...
diff --git a/lib/AsmParser/llvmAsmParser.y.cvs b/lib/AsmParser/llvmAsmParser.y.cvs
index a049cea..fa86c18 100644
--- a/lib/AsmParser/llvmAsmParser.y.cvs
+++ b/lib/AsmParser/llvmAsmParser.y.cvs
@@ -1089,8 +1089,6 @@
 %type <UIntVal> OptCallingConv LocalNumber
 %type <Attributes> OptAttributes Attribute
 %type <Attributes> OptFuncAttrs  FuncAttr
-%type <Attributes> OptFuncNotes FuncNote
-%type <Attributes> FuncNoteList
 
 // Basic Block Terminating Operators
 %token <TermOpVal> RET BR SWITCH INVOKE UNWIND UNREACHABLE
@@ -1122,10 +1120,7 @@
 
 // Function Attributes
 %token SIGNEXT ZEROEXT NORETURN INREG SRET NOUNWIND NOALIAS BYVAL NEST
-%token READNONE READONLY GC
-
-// Function Notes
-%token FNNOTE INLINE ALWAYS NEVER OPTIMIZEFORSIZE
+%token READNONE READONLY GC OPTSIZE NOINLINE ALWAYSINLINE
 
 // Visibility Styles
 %token DEFAULT HIDDEN PROTECTED
@@ -1284,6 +1279,9 @@
               | SIGNEXT  { $$ = Attribute::SExt;     }
               | READNONE { $$ = Attribute::ReadNone; }
               | READONLY { $$ = Attribute::ReadOnly; }
+              | NOINLINE { $$ = Attribute::NoInline }
+              | ALWAYSINLINE { $$ = Attribute::AlwaysInline }
+              | OPTSIZE { $$ = Attribute::OptimizeForSize }
               ;
 
 OptFuncAttrs  : /* empty */ { $$ = Attribute::None; }
@@ -1292,31 +1290,6 @@
               }
               ;
 
-FuncNoteList  : FuncNote { $$ = $1; }
-              | FuncNoteList ',' FuncNote {
-                unsigned tmp = $1 | $3;
-                if ($3 == Attribute::NoInline
-                    && ($1 & Attribute::AlwaysInline))
-                  GEN_ERROR("Function Notes may include only one inline notes!")
-                    if ($3 == Attribute::AlwaysInline
-                        && ($1 & Attribute::NoInline))
-                  GEN_ERROR("Function Notes may include only one inline notes!")
-                $$ = tmp;
-                CHECK_FOR_ERROR
-              }
-              ;
-
-FuncNote      : INLINE '=' NEVER { $$ = Attribute::NoInline; }
-              | INLINE '=' ALWAYS { $$ = Attribute::AlwaysInline; }
-              | OPTIMIZEFORSIZE { $$ = Attribute::OptimizeForSize; }
-              ;
-
-OptFuncNotes  : /* empty */ { $$ = Attribute::None; }
-              | FNNOTE '(' FuncNoteList  ')' {
-                $$ =  $3;
-              }
-              ;
-
 OptGC         : /* empty */ { $$ = 0; }
               | GC STRINGCONSTANT {
                 $$ = $2;
@@ -2332,7 +2305,7 @@
   };
 
 FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
-                  OptFuncAttrs OptSection OptAlign OptGC OptFuncNotes {
+                  OptFuncAttrs OptSection OptAlign OptGC {
   std::string FunctionName(*$3);
   delete $3;  // Free strdup'd memory!
 
@@ -2453,9 +2426,6 @@
     Fn->setGC($10->c_str());
     delete $10;
   }
-  if ($11) {
-    Fn->setNotes($11);
-  }
 
   // Add all of the arguments we parsed to the function...
   if ($5) {                     // Is null if empty...
diff --git a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
index eb66a4f..6e596b4 100644
--- a/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
@@ -154,7 +154,7 @@
   SwitchToSection(TAI->SectionForGlobal(F));
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize))
+  if (!F->isDeclaration() && F->hasFnAttr(Attribute::OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
diff --git a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
index d2521d0..c8199c5 100644
--- a/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
+++ b/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
@@ -141,7 +141,7 @@
   SwitchToTextSection("_text", F);
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize))
+  if (!F->isDeclaration() && F->hasFnAttr(Attribute::OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unsupported linkage type!");
diff --git a/lib/Transforms/IPO/InlineAlways.cpp b/lib/Transforms/IPO/InlineAlways.cpp
index 448f246..1079c4a 100644
--- a/lib/Transforms/IPO/InlineAlways.cpp
+++ b/lib/Transforms/IPO/InlineAlways.cpp
@@ -63,7 +63,7 @@
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
-    if (!I->isDeclaration() && !I->hasNote(Attribute::AlwaysInline))
+    if (!I->isDeclaration() && !I->hasFnAttr(Attribute::AlwaysInline))
       NeverInline.insert(I);
 
   return false;
diff --git a/lib/Transforms/IPO/InlineSimple.cpp b/lib/Transforms/IPO/InlineSimple.cpp
index b19494a..02cae2a 100644
--- a/lib/Transforms/IPO/InlineSimple.cpp
+++ b/lib/Transforms/IPO/InlineSimple.cpp
@@ -65,7 +65,7 @@
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
-    if (!I->isDeclaration() && I->hasNote(Attribute::NoInline))
+    if (!I->isDeclaration() && I->hasFnAttr(Attribute::NoInline))
       NeverInline.insert(I);
 
   // Get llvm.noinline
diff --git a/lib/Transforms/IPO/Inliner.cpp b/lib/Transforms/IPO/Inliner.cpp
index abc1094..c267272 100644
--- a/lib/Transforms/IPO/Inliner.cpp
+++ b/lib/Transforms/IPO/Inliner.cpp
@@ -141,7 +141,8 @@
         
         int CurrentThreshold = InlineThreshold;
         Function *Fn = CS.getCaller();
-        if (Fn && !Fn->isDeclaration() && Fn->hasNote(Attribute::OptimizeForSize)
+        if (Fn && !Fn->isDeclaration() 
+            && Fn->hasFnAttr(Attribute::OptimizeForSize)
             && InlineThreshold != 50) {
           CurrentThreshold = 50;
         }
diff --git a/lib/Transforms/Scalar/LoopUnswitch.cpp b/lib/Transforms/Scalar/LoopUnswitch.cpp
index 15eaa78..fbfe297 100644
--- a/lib/Transforms/Scalar/LoopUnswitch.cpp
+++ b/lib/Transforms/Scalar/LoopUnswitch.cpp
@@ -430,7 +430,7 @@
   Function *F = loopHeader->getParent();
 
   // Do not unswitch if the function is optimized for size.
-  if (!F->isDeclaration() && F->hasNote(Attribute::OptimizeForSize))
+  if (!F->isDeclaration() && F->hasFnAttr(Attribute::OptimizeForSize))
     return false;
 
   // Check to see if it would be profitable to unswitch current loop.
diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp
index 55755c1..d0b5185 100644
--- a/lib/Transforms/Utils/InlineCost.cpp
+++ b/lib/Transforms/Utils/InlineCost.cpp
@@ -222,7 +222,7 @@
   if (CalleeFI.NeverInline)
     return 2000000000;
 
-  if (!Callee->isDeclaration() && Callee->hasNote(Attribute::AlwaysInline))
+  if (!Callee->isDeclaration() && Callee->hasFnAttr(Attribute::AlwaysInline))
     return -2000000000;
     
   // Add to the inline quality for properties that make the call valuable to
diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp
index e186985..14c8274 100644
--- a/lib/VMCore/AsmWriter.cpp
+++ b/lib/VMCore/AsmWriter.cpp
@@ -1413,34 +1413,6 @@
   if (F->isDeclaration()) {
     Out << "\n";
   } else {
-
-    bool insideNotes = false;
-    if (F->hasNote(Attribute::AlwaysInline)) {
-      Out << " notes(";
-      insideNotes = true;
-      Out << "inline=always";
-    }
-    if (F->hasNote(Attribute::NoInline)) {
-      if (insideNotes) 
-        Out << ",";
-      else {
-        Out << " notes(";
-        insideNotes = true;
-      }
-      Out << "inline=never";
-    }
-    if (F->hasNote(Attribute::OptimizeForSize)) {
-      if (insideNotes) 
-        Out << ",";
-      else {
-        Out << " notes(";
-        insideNotes = true;
-      }
-      Out << "opt_size";
-    }
-    if (insideNotes)
-      Out << ")";
-    
     Out << " {";
 
     // Output all of its basic blocks... for the function