Move FN_NOTE_AlwaysInline and other out of ParamAttrs namespace.
authorDevang Patel <dpatel@apple.com>
Tue, 23 Sep 2008 23:52:03 +0000 (23:52 +0000)
committerDevang Patel <dpatel@apple.com>
Tue, 23 Sep 2008 23:52:03 +0000 (23:52 +0000)
Do not check isDeclaration() in hasNote(). It is clients' responsibility.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@56524 91177308-0d34-0410-b5e6-96231b3b80d8

13 files changed:
include/llvm/Attributes.h
include/llvm/Function.h
lib/AsmParser/llvmAsmParser.cpp.cvs
lib/AsmParser/llvmAsmParser.y
lib/AsmParser/llvmAsmParser.y.cvs
lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
lib/Transforms/IPO/InlineAlways.cpp
lib/Transforms/IPO/InlineSimple.cpp
lib/Transforms/IPO/Inliner.cpp
lib/Transforms/Scalar/LoopUnswitch.cpp
lib/Transforms/Utils/InlineCost.cpp
lib/VMCore/AsmWriter.cpp

index fbedb723811ba140d2509d77d0577a868a94f58a..a503354567c47a9dec71bf5a1a2576ad58e73ca4 100644 (file)
@@ -46,13 +46,6 @@ const Attributes ReadOnly  = 1<<10; ///< Function only reads from memory
 const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter (16 bits)
                                     // 0 = unknown, else in clear (not log)
                                     
 const Attributes Alignment = 0xffff<<16; ///< Alignment of parameter (16 bits)
                                     // 0 = unknown, else in clear (not log)
                                     
-/// Function notes are implemented as attributes stored at index ~0 in 
-/// parameter attribute list.
-const Attributes FN_NOTE_None            = 0;    
-const Attributes FN_NOTE_NoInline        = 1<<0; // inline=never 
-const Attributes FN_NOTE_AlwaysInline    = 1<<1; // inline=always
-const Attributes FN_NOTE_OptimizeForSize = 1<<2; // opt_size
-
 /// @brief Attributes that only apply to function parameters.
 const Attributes ParameterOnly = ByVal | Nest | StructRet;
 
 /// @brief Attributes that only apply to function parameters.
 const Attributes ParameterOnly = ByVal | Nest | StructRet;
 
@@ -85,6 +78,12 @@ inline Attributes constructAlignmentFromInt(unsigned i) {
 std::string getAsString(Attributes Attrs);
 } // end namespace ParamAttr
 
 std::string getAsString(Attributes Attrs);
 } // end namespace ParamAttr
 
+/// Function notes are implemented as attributes stored at index ~0 in 
+/// parameter attribute list.
+const Attributes FN_NOTE_None            = 0;    
+const Attributes FN_NOTE_NoInline        = 1<<0; // inline=never 
+const Attributes FN_NOTE_AlwaysInline    = 1<<1; // inline=always
+const Attributes FN_NOTE_OptimizeForSize = 1<<2; // opt_size
 
 /// This is just a pair of values to associate a set of parameter attributes
 /// with a parameter index. 
 
 /// This is just a pair of values to associate a set of parameter attributes
 /// with a parameter index. 
index b80090942300fa67f119a6fa1e86278cc04f38df..7a39f92282341d4421a9db321e1a8354851945f3 100644 (file)
@@ -152,7 +152,7 @@ public:
   /// hasNote - Return true if this function has given note.
   bool hasNote(Attributes N) const {
     // Notes are stored at ~0 index in parameter attribute list
   /// hasNote - Return true if this function has given note.
   bool hasNote(Attributes N) const {
     // Notes are stored at ~0 index in parameter attribute list
-    return (!isDeclaration() && paramHasAttr(~0, N));
+    return (paramHasAttr(~0, N));
   }
 
   /// setNotes - Set notes for this function
   }
 
   /// setNotes - Set notes for this function
index 5e536f8717dcd61278fc48173a6d7a3a4c3540cd..4d8ab7445caf7223b9e9f7f44348c24f77ed53bc 100644 (file)
@@ -4125,11 +4125,11 @@ yyreduce:
 #line 1298 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
     { 
                 unsigned tmp = (yyvsp[(1) - (3)].ParamAttrs) | (yyvsp[(3) - (3)].ParamAttrs);
 #line 1298 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
     { 
                 unsigned tmp = (yyvsp[(1) - (3)].ParamAttrs) | (yyvsp[(3) - (3)].ParamAttrs);
-                if ((yyvsp[(3) - (3)].ParamAttrs) == ParamAttr::FN_NOTE_NoInline 
-                    && ((yyvsp[(1) - (3)].ParamAttrs) & ParamAttr::FN_NOTE_AlwaysInline))
+                if ((yyvsp[(3) - (3)].ParamAttrs) == FN_NOTE_NoInline 
+                    && ((yyvsp[(1) - (3)].ParamAttrs) & FN_NOTE_AlwaysInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                   GEN_ERROR("Function Notes may include only one inline notes!")
-                    if ((yyvsp[(3) - (3)].ParamAttrs) == ParamAttr::FN_NOTE_AlwaysInline 
-                        && ((yyvsp[(1) - (3)].ParamAttrs) & ParamAttr::FN_NOTE_NoInline))
+                    if ((yyvsp[(3) - (3)].ParamAttrs) == FN_NOTE_AlwaysInline 
+                        && ((yyvsp[(1) - (3)].ParamAttrs) & FN_NOTE_NoInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 (yyval.ParamAttrs) = tmp;
                 CHECK_FOR_ERROR 
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 (yyval.ParamAttrs) = tmp;
                 CHECK_FOR_ERROR 
@@ -4138,22 +4138,22 @@ yyreduce:
 
   case 131:
 #line 1311 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
 
   case 131:
 #line 1311 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::FN_NOTE_NoInline; ;}
+    { (yyval.ParamAttrs) = FN_NOTE_NoInline; ;}
     break;
 
   case 132:
 #line 1312 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
     break;
 
   case 132:
 #line 1312 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::FN_NOTE_AlwaysInline; ;}
+    { (yyval.ParamAttrs) = FN_NOTE_AlwaysInline; ;}
     break;
 
   case 133:
 #line 1313 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
     break;
 
   case 133:
 #line 1313 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::FN_NOTE_OptimizeForSize; ;}
+    { (yyval.ParamAttrs) = FN_NOTE_OptimizeForSize; ;}
     break;
 
   case 134:
 #line 1316 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
     break;
 
   case 134:
 #line 1316 "/Volumes/Nanpura/mainline/llvm/lib/AsmParser/llvmAsmParser.y"
-    { (yyval.ParamAttrs) = ParamAttr::FN_NOTE_None; ;}
+    { (yyval.ParamAttrs) = FN_NOTE_None; ;}
     break;
 
   case 135:
     break;
 
   case 135:
index e2671232feeda0013ddf1f38467258be73d28c2c..5de34a722c7b8e793da8b2a0393e049a868bb4d5 100644 (file)
@@ -1297,23 +1297,23 @@ OptFuncAttrs  : /* empty */ { $$ = ParamAttr::None; }
 FuncNoteList  : FuncNote { $$ = $1; }
               | FuncNoteList ',' FuncNote { 
                 unsigned tmp = $1 | $3;
 FuncNoteList  : FuncNote { $$ = $1; }
               | FuncNoteList ',' FuncNote { 
                 unsigned tmp = $1 | $3;
-                if ($3 == ParamAttr::FN_NOTE_NoInline 
-                    && ($1 & ParamAttr::FN_NOTE_AlwaysInline))
+                if ($3 == FN_NOTE_NoInline 
+                    && ($1 & FN_NOTE_AlwaysInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                   GEN_ERROR("Function Notes may include only one inline notes!")
-                    if ($3 == ParamAttr::FN_NOTE_AlwaysInline 
-                        && ($1 & ParamAttr::FN_NOTE_NoInline))
+                    if ($3 == FN_NOTE_AlwaysInline 
+                        && ($1 & FN_NOTE_NoInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 $$ = tmp;
                 CHECK_FOR_ERROR 
               }
               ;
 
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 $$ = tmp;
                 CHECK_FOR_ERROR 
               }
               ;
 
-FuncNote      : INLINE '=' NEVER { $$ = ParamAttr::FN_NOTE_NoInline; }
-              | INLINE '=' ALWAYS { $$ = ParamAttr::FN_NOTE_AlwaysInline; }
-              | OPTIMIZEFORSIZE { $$ = ParamAttr::FN_NOTE_OptimizeForSize; }
+FuncNote      : INLINE '=' NEVER { $$ = FN_NOTE_NoInline; }
+              | INLINE '=' ALWAYS { $$ = FN_NOTE_AlwaysInline; }
+              | OPTIMIZEFORSIZE { $$ = FN_NOTE_OptimizeForSize; }
               ;
 
               ;
 
-OptFuncNotes  : /* empty */ { $$ = ParamAttr::FN_NOTE_None; }
+OptFuncNotes  : /* empty */ { $$ = FN_NOTE_None; }
               | FNNOTE '(' FuncNoteList  ')' {
                 $$ =  $3;
               }
               | FNNOTE '(' FuncNoteList  ')' {
                 $$ =  $3;
               }
index e2671232feeda0013ddf1f38467258be73d28c2c..5de34a722c7b8e793da8b2a0393e049a868bb4d5 100644 (file)
@@ -1297,23 +1297,23 @@ OptFuncAttrs  : /* empty */ { $$ = ParamAttr::None; }
 FuncNoteList  : FuncNote { $$ = $1; }
               | FuncNoteList ',' FuncNote { 
                 unsigned tmp = $1 | $3;
 FuncNoteList  : FuncNote { $$ = $1; }
               | FuncNoteList ',' FuncNote { 
                 unsigned tmp = $1 | $3;
-                if ($3 == ParamAttr::FN_NOTE_NoInline 
-                    && ($1 & ParamAttr::FN_NOTE_AlwaysInline))
+                if ($3 == FN_NOTE_NoInline 
+                    && ($1 & FN_NOTE_AlwaysInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                   GEN_ERROR("Function Notes may include only one inline notes!")
-                    if ($3 == ParamAttr::FN_NOTE_AlwaysInline 
-                        && ($1 & ParamAttr::FN_NOTE_NoInline))
+                    if ($3 == FN_NOTE_AlwaysInline 
+                        && ($1 & FN_NOTE_NoInline))
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 $$ = tmp;
                 CHECK_FOR_ERROR 
               }
               ;
 
                   GEN_ERROR("Function Notes may include only one inline notes!")
                 $$ = tmp;
                 CHECK_FOR_ERROR 
               }
               ;
 
-FuncNote      : INLINE '=' NEVER { $$ = ParamAttr::FN_NOTE_NoInline; }
-              | INLINE '=' ALWAYS { $$ = ParamAttr::FN_NOTE_AlwaysInline; }
-              | OPTIMIZEFORSIZE { $$ = ParamAttr::FN_NOTE_OptimizeForSize; }
+FuncNote      : INLINE '=' NEVER { $$ = FN_NOTE_NoInline; }
+              | INLINE '=' ALWAYS { $$ = FN_NOTE_AlwaysInline; }
+              | OPTIMIZEFORSIZE { $$ = FN_NOTE_OptimizeForSize; }
               ;
 
               ;
 
-OptFuncNotes  : /* empty */ { $$ = ParamAttr::FN_NOTE_None; }
+OptFuncNotes  : /* empty */ { $$ = FN_NOTE_None; }
               | FNNOTE '(' FuncNoteList  ')' {
                 $$ =  $3;
               }
               | FNNOTE '(' FuncNoteList  ')' {
                 $$ =  $3;
               }
index a783bd279aadb69a4516532f5566aeead9ccf502..2c9975eb73b379af1475dea7c9bc692dab00bfd3 100644 (file)
@@ -160,7 +160,7 @@ void X86ATTAsmPrinter::emitFunctionHeader(const MachineFunction &MF) {
   SwitchToTextSection(SectionName.c_str());
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
   SwitchToTextSection(SectionName.c_str());
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize))
+  if (!F->isDeclaration() && F->hasNote(FN_NOTE_OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unknown linkage type!");
index 559e9ebd5b37d4ed0b7b8f0f40fc3f20bd77603c..7c2713cf1169e4844f4b4226b1656afa7526e9fd 100644 (file)
@@ -147,7 +147,7 @@ bool X86IntelAsmPrinter::runOnMachineFunction(MachineFunction &MF) {
   SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
   SwitchToTextSection(getSectionForFunction(*F).c_str(), F);
 
   unsigned FnAlign = OptimizeForSize ? 1 : 4;
-  if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize))
+  if (!F->isDeclaration() && F->hasNote(FN_NOTE_OptimizeForSize))
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unsupported linkage type!");
     FnAlign = 1;
   switch (F->getLinkage()) {
   default: assert(0 && "Unsupported linkage type!");
index 4793a17b84236f00ab49aa02fdb239f19752fee5..ddcc79cf59be994e2dfb4d52ac60ac653867f0e8 100644 (file)
@@ -63,7 +63,7 @@ bool AlwaysInliner::doInitialization(CallGraph &CG) {
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
-    if (!I->isDeclaration() && !I->hasNote(ParamAttr::FN_NOTE_AlwaysInline))
+    if (!I->isDeclaration() && !I->hasNote(FN_NOTE_AlwaysInline))
       NeverInline.insert(I);
 
   return false;
       NeverInline.insert(I);
 
   return false;
index 6db4c908b772afd676798c6d0759f12f3f499f97..42897676418fa9d1803f89ebf5bcaa63d91dcd7f 100644 (file)
@@ -65,7 +65,7 @@ bool SimpleInliner::doInitialization(CallGraph &CG) {
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
   
   for (Module::iterator I = M.begin(), E = M.end();
        I != E; ++I)
-    if (I->hasNote(ParamAttr::FN_NOTE_NoInline))
+    if (!I->isDeclaration() && I->hasNote(FN_NOTE_NoInline))
       NeverInline.insert(I);
 
   // Get llvm.noinline
       NeverInline.insert(I);
 
   // Get llvm.noinline
index 2af5a7264df69bc7bfc1cd5b1fce8bc35588af2a..7922d6e7a9453f9aced49f10332c62d2cdf1c56f 100644 (file)
@@ -141,7 +141,7 @@ bool Inliner::runOnSCC(const std::vector<CallGraphNode*> &SCC) {
         
         int CurrentThreshold = InlineThreshold;
         Function *Fn = CS.getCaller();
         
         int CurrentThreshold = InlineThreshold;
         Function *Fn = CS.getCaller();
-        if (Fn && Fn->hasNote(ParamAttr::FN_NOTE_OptimizeForSize)
+        if (Fn && !Fn->isDeclaration() && Fn->hasNote(FN_NOTE_OptimizeForSize)
             && InlineThreshold != 50) {
           CurrentThreshold = 50;
         }
             && InlineThreshold != 50) {
           CurrentThreshold = 50;
         }
index 178bf783971a96cc6401defec4373bce608c7bf5..4fd3d031a1a2a66d031ed07e307e87a00c77cb95 100644 (file)
@@ -430,7 +430,7 @@ bool LoopUnswitch::UnswitchIfProfitable(Value *LoopCond, Constant *Val){
   Function *F = loopHeader->getParent();
 
   // Do not unswitch if the function is optimized for size.
   Function *F = loopHeader->getParent();
 
   // Do not unswitch if the function is optimized for size.
-  if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize))
+  if (!F->isDeclaration() && F->hasNote(FN_NOTE_OptimizeForSize))
     return false;
 
   // Check to see if it would be profitable to unswitch current loop.
     return false;
 
   // Check to see if it would be profitable to unswitch current loop.
index eb825287be6ea0298b70018913f9264f4ae77dc2..6ecd060991238c9f46ff137f400a09ef0db616aa 100644 (file)
@@ -222,7 +222,7 @@ int InlineCostAnalyzer::getInlineCost(CallSite CS,
   if (CalleeFI.NeverInline)
     return 2000000000;
 
   if (CalleeFI.NeverInline)
     return 2000000000;
 
-  if (Callee->hasNote(ParamAttr::FN_NOTE_AlwaysInline))
+  if (!Callee->isDeclaration() && Callee->hasNote(FN_NOTE_AlwaysInline))
     return -2000000000;
     
   // Add to the inline quality for properties that make the call valuable to
     return -2000000000;
     
   // Add to the inline quality for properties that make the call valuable to
index 68335974d45176f80164b6aa11b9d251e28c69d6..3b9b6690fe94b3352a981bd1203f62a451cec6c7 100644 (file)
@@ -1412,12 +1412,12 @@ void AssemblyWriter::printFunction(const Function *F) {
   } else {
 
     bool insideNotes = false;
   } else {
 
     bool insideNotes = false;
-    if (F->hasNote(ParamAttr::FN_NOTE_AlwaysInline)) {
+    if (F->hasNote(FN_NOTE_AlwaysInline)) {
       Out << "notes(";
       insideNotes = true;
       Out << "inline=always";
     }
       Out << "notes(";
       insideNotes = true;
       Out << "inline=always";
     }
-    if (F->hasNote(ParamAttr::FN_NOTE_NoInline)) {
+    if (F->hasNote(FN_NOTE_NoInline)) {
       if (insideNotes) 
         Out << ",";
       else {
       if (insideNotes) 
         Out << ",";
       else {
@@ -1426,7 +1426,7 @@ void AssemblyWriter::printFunction(const Function *F) {
       }
       Out << "inline=never";
     }
       }
       Out << "inline=never";
     }
-    if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize)) {
+    if (F->hasNote(FN_NOTE_OptimizeForSize)) {
       if (insideNotes) 
         Out << ",";
       else {
       if (insideNotes) 
         Out << ",";
       else {