[llvm-commits] [llvm] r56524 - in /llvm/trunk: 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

Devang Patel dpatel at apple.com
Tue Sep 23 16:52:04 PDT 2008


Author: dpatel
Date: Tue Sep 23 18:52:03 2008
New Revision: 56524

URL: http://llvm.org/viewvc/llvm-project?rev=56524&view=rev
Log:
Move FN_NOTE_AlwaysInline and other out of ParamAttrs namespace.
Do not check isDeclaration() in hasNote(). It is clients' responsibility.

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

Modified: llvm/trunk/include/llvm/Attributes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Attributes.h (original)
+++ llvm/trunk/include/llvm/Attributes.h Tue Sep 23 18:52:03 2008
@@ -46,13 +46,6 @@
 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;
 
@@ -85,6 +78,12 @@
 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. 

Modified: llvm/trunk/include/llvm/Function.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Function.h?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Function.h (original)
+++ llvm/trunk/include/llvm/Function.h Tue Sep 23 18:52:03 2008
@@ -152,7 +152,7 @@
   /// 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

Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.cpp.cvs Tue Sep 23 18:52:03 2008
@@ -4125,11 +4125,11 @@
 #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!")
-                    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 
@@ -4138,22 +4138,22 @@
 
   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"
-    { (yyval.ParamAttrs) = ParamAttr::FN_NOTE_AlwaysInline; ;}
+    { (yyval.ParamAttrs) = FN_NOTE_AlwaysInline; ;}
     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"
-    { (yyval.ParamAttrs) = ParamAttr::FN_NOTE_None; ;}
+    { (yyval.ParamAttrs) = FN_NOTE_None; ;}
     break;
 
   case 135:

Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y Tue Sep 23 18:52:03 2008
@@ -1297,23 +1297,23 @@
 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!")
-                    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 
               }
               ;
 
-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;
               }

Modified: llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs (original)
+++ llvm/trunk/lib/AsmParser/llvmAsmParser.y.cvs Tue Sep 23 18:52:03 2008
@@ -1297,23 +1297,23 @@
 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!")
-                    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 
               }
               ;
 
-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;
               }

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Sep 23 18:52:03 2008
@@ -160,7 +160,7 @@
   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!");

Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86IntelAsmPrinter.cpp Tue Sep 23 18:52:03 2008
@@ -147,7 +147,7 @@
   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!");

Modified: llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineAlways.cpp Tue Sep 23 18:52:03 2008
@@ -63,7 +63,7 @@
   
   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;

Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Tue Sep 23 18:52:03 2008
@@ -65,7 +65,7 @@
   
   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

Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Tue Sep 23 18:52:03 2008
@@ -141,7 +141,7 @@
         
         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;
         }

Modified: llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopUnswitch.cpp Tue Sep 23 18:52:03 2008
@@ -430,7 +430,7 @@
   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.

Modified: llvm/trunk/lib/Transforms/Utils/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/InlineCost.cpp?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Utils/InlineCost.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/InlineCost.cpp Tue Sep 23 18:52:03 2008
@@ -222,7 +222,7 @@
   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

Modified: llvm/trunk/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/AsmWriter.cpp?rev=56524&r1=56523&r2=56524&view=diff

==============================================================================
--- llvm/trunk/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/trunk/lib/VMCore/AsmWriter.cpp Tue Sep 23 18:52:03 2008
@@ -1412,12 +1412,12 @@
   } else {
 
     bool insideNotes = false;
-    if (F->hasNote(ParamAttr::FN_NOTE_AlwaysInline)) {
+    if (F->hasNote(FN_NOTE_AlwaysInline)) {
       Out << "notes(";
       insideNotes = true;
       Out << "inline=always";
     }
-    if (F->hasNote(ParamAttr::FN_NOTE_NoInline)) {
+    if (F->hasNote(FN_NOTE_NoInline)) {
       if (insideNotes) 
         Out << ",";
       else {
@@ -1426,7 +1426,7 @@
       }
       Out << "inline=never";
     }
-    if (F->hasNote(ParamAttr::FN_NOTE_OptimizeForSize)) {
+    if (F->hasNote(FN_NOTE_OptimizeForSize)) {
       if (insideNotes) 
         Out << ",";
       else {





More information about the llvm-commits mailing list