[llvm-commits] [llvm] r52820 - /llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp

Bill Wendling isanbard at gmail.com
Fri Jun 27 00:13:44 PDT 2008


Author: void
Date: Fri Jun 27 02:13:44 2008
New Revision: 52820

URL: http://llvm.org/viewvc/llvm-project?rev=52820&view=rev
Log:
Reduce number of times .size() is called on a vector. Rename some variables to
match normal naming scheme.


Modified:
    llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp

Modified: llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp?rev=52820&r1=52819&r2=52820&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineModuleInfo.cpp Fri Jun 27 02:13:44 2008
@@ -306,7 +306,7 @@
     ArrayType *AT = ArrayType::get(EmptyTy, N);
     std::vector<Constant *> ArrayElements;
 
-    for (unsigned i = 0, N = Field.size(); i < N; ++i) {
+    for (unsigned i = 0; i < N; ++i) {
       if (DebugInfoDesc *Element = Field[i]) {
         GlobalVariable *GVE = SR.Serialize(Element);
         Constant *CE = ConstantExpr::getBitCast(GVE, EmptyTy);
@@ -711,8 +711,8 @@
 //===----------------------------------------------------------------------===//
 
 DebugScope::~DebugScope() {
-  for (unsigned i = 0, N = Scopes.size(); i < N; ++i) delete Scopes[i];
-  for (unsigned j = 0, M = Variables.size(); j < M; ++j) delete Variables[j];
+  for (unsigned i = 0, e = Scopes.size(); i < e; ++i) delete Scopes[i];
+  for (unsigned i = 0, e = Variables.size(); i < e; ++i) delete Variables[i];
 }
 
 //===----------------------------------------------------------------------===//
@@ -819,7 +819,7 @@
   CompileUnitDesc CUD;
   getAnchoredDescriptors(M, &CUD, CUList);
   
-  for (unsigned i = 0, N = CUList.size(); i < N; i++)
+  for (unsigned i = 0, e = CUList.size(); i < e; i++)
     CompileUnits.insert((CompileUnitDesc*)CUList[i]);
 }
 
@@ -837,7 +837,7 @@
   std::vector<GlobalVariable*> Globals;
   getGlobalVariablesUsing(M, Desc->getAnchorString(), Globals);
 
-  for (unsigned i = 0, N = Globals.size(); i < N; ++i) {
+  for (unsigned i = 0, e = Globals.size(); i < e; ++i) {
     GlobalVariable *GV = Globals[i];
 
     // FIXME - In the short term, changes are too drastic to continue.
@@ -939,9 +939,10 @@
 
 /// getOrCreateLandingPadInfo - Find or create an LandingPadInfo for the
 /// specified MachineBasicBlock.
-LandingPadInfo &MachineModuleInfo::getOrCreateLandingPadInfo
-    (MachineBasicBlock *LandingPad) {
+LandingPadInfo &
+MachineModuleInfo::getOrCreateLandingPadInfo(MachineBasicBlock *LandingPad) {
   unsigned N = LandingPads.size();
+
   for (unsigned i = 0; i < N; ++i) {
     LandingPadInfo &LP = LandingPads[i];
     if (LP.LandingPadBlock == LandingPad)
@@ -977,7 +978,7 @@
   LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
   LP.Personality = Personality;
 
-  for (unsigned i = 0; i < Personalities.size(); ++i)
+  for (unsigned i = 0, e = Personalities.size(); i < e; ++i)
     if (Personalities[i] == Personality)
       return;
   
@@ -998,9 +999,12 @@
 void MachineModuleInfo::addFilterTypeInfo(MachineBasicBlock *LandingPad,
                                         std::vector<GlobalVariable *> &TyInfo) {
   LandingPadInfo &LP = getOrCreateLandingPadInfo(LandingPad);
-  std::vector<unsigned> IdsInFilter (TyInfo.size());
-  for (unsigned I = 0, E = TyInfo.size(); I != E; ++I)
+  unsigned TyInfoSize = TyInfo.size();
+  std::vector<unsigned> IdsInFilter(TyInfoSize);
+
+  for (unsigned I = 0; I != TyInfoSize; ++I)
     IdsInFilter[I] = getTypeIDFor(TyInfo[I]);
+
   LP.TypeIds.push_back(getFilterIDFor(IdsInFilter));
 }
 
@@ -1025,7 +1029,7 @@
       continue;
     }
 
-    for (unsigned j=0; j != LandingPads[i].BeginLabels.size(); ) {
+    for (unsigned j = 0; j != LandingPads[i].BeginLabels.size(); ) {
       unsigned BeginLabel = MappedLabel(LandingPad.BeginLabels[j]);
       unsigned EndLabel = MappedLabel(LandingPad.EndLabels[j]);
 
@@ -1059,8 +1063,9 @@
 /// getTypeIDFor - Return the type id for the specified typeinfo.  This is 
 /// function wide.
 unsigned MachineModuleInfo::getTypeIDFor(GlobalVariable *TI) {
-  for (unsigned i = 0, N = TypeInfos.size(); i != N; ++i)
-    if (TypeInfos[i] == TI) return i + 1;
+  for (unsigned i = 0, e = TypeInfos.size(); i != e; ++i)
+    if (TypeInfos[i] == TI)
+      return i + 1;
 
   TypeInfos.push_back(TI);
   return TypeInfos.size();
@@ -1090,8 +1095,10 @@
   // Add the new filter.
   int FilterID = -(1 + FilterIds.size());
   FilterIds.reserve(FilterIds.size() + TyIds.size() + 1);
+
   for (unsigned I = 0, N = TyIds.size(); I != N; ++I)
     FilterIds.push_back(TyIds[I]);
+
   FilterEnds.push_back(FilterIds.size());
   FilterIds.push_back(0); // terminator
   return FilterID;
@@ -1110,16 +1117,15 @@
   const Function* Personality = NULL;
   
   // Scan landing pads. If there is at least one non-NULL personality - use it.
-  for (unsigned i = 0; i != LandingPads.size(); ++i)
+  for (unsigned i = 0, e = LandingPads.size(); i != e; ++i)
     if (LandingPads[i].Personality) {
       Personality = LandingPads[i].Personality;
       break;
     }
   
-  for (unsigned i = 0; i < Personalities.size(); ++i) {
+  for (unsigned i = 0, e = Personalities.size(); i < e; ++i)
     if (Personalities[i] == Personality)
       return i;
-  }
 
   // This should never happen
   assert(0 && "Personality function should be set!");





More information about the llvm-commits mailing list