[llvm-commits] [llvm] r110752 - /llvm/trunk/tools/lto/LTOModule.cpp

Daniel Dunbar daniel at zuster.org
Tue Aug 10 16:46:46 PDT 2010


Author: ddunbar
Date: Tue Aug 10 18:46:46 2010
New Revision: 110752

URL: http://llvm.org/viewvc/llvm-project?rev=110752&view=rev
Log:
lto: Reduce nesting.

Modified:
    llvm/trunk/tools/lto/LTOModule.cpp

Modified: llvm/trunk/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOModule.cpp?rev=110752&r1=110751&r2=110752&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOModule.cpp (original)
+++ llvm/trunk/tools/lto/LTOModule.cpp Tue Aug 10 18:46:46 2010
@@ -420,65 +420,66 @@
 }
 
 void LTOModule::lazyParseSymbols() {
-  if (!_symbolsParsed) {
-    _symbolsParsed = true;
+  if (_symbolsParsed)
+    return;
 
-    // Use mangler to add GlobalPrefix to names to match linker names.
-    MCContext Context(*_target->getMCAsmInfo());
-    Mangler mangler(Context, *_target->getTargetData());
-
-    // add functions
-    for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
-      if (f->isDeclaration())
-        addPotentialUndefinedSymbol(f, mangler);
-      else
-        addDefinedFunctionSymbol(f, mangler);
-    }
+  _symbolsParsed = true;
 
-    // add data
-    for (Module::global_iterator v = _module->global_begin(),
-           e = _module->global_end(); v !=  e; ++v) {
-      if (v->isDeclaration())
-        addPotentialUndefinedSymbol(v, mangler);
-      else
-        addDefinedDataSymbol(v, mangler);
-    }
+  // Use mangler to add GlobalPrefix to names to match linker names.
+  MCContext Context(*_target->getMCAsmInfo());
+  Mangler mangler(Context, *_target->getTargetData());
+
+  // add functions
+  for (Module::iterator f = _module->begin(); f != _module->end(); ++f) {
+    if (f->isDeclaration())
+      addPotentialUndefinedSymbol(f, mangler);
+    else
+      addDefinedFunctionSymbol(f, mangler);
+  }
 
-    // add asm globals
-    const std::string &inlineAsm = _module->getModuleInlineAsm();
-    const std::string glbl = ".globl";
-    std::string asmSymbolName;
-    std::string::size_type pos = inlineAsm.find(glbl, 0);
-    while (pos != std::string::npos) {
-      // eat .globl
-      pos = pos + 6;
-
-      // skip white space between .globl and symbol name
-      std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos);
-      if (pbegin == std::string::npos)
-        break;
-
-      // find end-of-line
-      std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin);
-      if (pend == std::string::npos)
-        break;
+  // add data
+  for (Module::global_iterator v = _module->global_begin(),
+         e = _module->global_end(); v !=  e; ++v) {
+    if (v->isDeclaration())
+      addPotentialUndefinedSymbol(v, mangler);
+    else
+      addDefinedDataSymbol(v, mangler);
+  }
 
-      asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin);
-      addAsmGlobalSymbol(asmSymbolName.c_str());
+  // add asm globals
+  const std::string &inlineAsm = _module->getModuleInlineAsm();
+  const std::string glbl = ".globl";
+  std::string asmSymbolName;
+  std::string::size_type pos = inlineAsm.find(glbl, 0);
+  while (pos != std::string::npos) {
+    // eat .globl
+    pos = pos + 6;
+
+    // skip white space between .globl and symbol name
+    std::string::size_type pbegin = inlineAsm.find_first_not_of(' ', pos);
+    if (pbegin == std::string::npos)
+      break;
+
+    // find end-of-line
+    std::string::size_type pend = inlineAsm.find_first_of('\n', pbegin);
+    if (pend == std::string::npos)
+      break;
 
-      // search next .globl
-      pos = inlineAsm.find(glbl, pend);
-    }
+    asmSymbolName.assign(inlineAsm, pbegin, pend - pbegin);
+    addAsmGlobalSymbol(asmSymbolName.c_str());
+
+    // search next .globl
+    pos = inlineAsm.find(glbl, pend);
+  }
 
-    // make symbols for all undefines
-    for (StringMap<NameAndAttributes>::iterator it=_undefines.begin();
-         it != _undefines.end(); ++it) {
-      // if this symbol also has a definition, then don't make an undefine
-      // because it is a tentative definition
-      if (_defines.count(it->getKey()) == 0) {
-        NameAndAttributes info = it->getValue();
-        _symbols.push_back(info);
-      }
+  // make symbols for all undefines
+  for (StringMap<NameAndAttributes>::iterator it=_undefines.begin();
+       it != _undefines.end(); ++it) {
+    // if this symbol also has a definition, then don't make an undefine
+    // because it is a tentative definition
+    if (_defines.count(it->getKey()) == 0) {
+      NameAndAttributes info = it->getValue();
+      _symbols.push_back(info);
     }
   }
 }





More information about the llvm-commits mailing list