[llvm-branch-commits] [llvm-branch] r111404 - /llvm/branches/Apple/williamson/tools/lto/LTOModule.cpp

Daniel Dunbar daniel at zuster.org
Wed Aug 18 13:33:06 PDT 2010


Author: ddunbar
Date: Wed Aug 18 15:33:06 2010
New Revision: 111404

URL: http://llvm.org/viewvc/llvm-project?rev=111404&view=rev
Log:
Merge r110752:
--
Author: Daniel Dunbar <daniel at zuster.org>
Date:   Tue Aug 10 23:46:46 2010 +0000

    lto: Reduce nesting.

Modified:
    llvm/branches/Apple/williamson/tools/lto/LTOModule.cpp

Modified: llvm/branches/Apple/williamson/tools/lto/LTOModule.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/williamson/tools/lto/LTOModule.cpp?rev=111404&r1=111403&r2=111404&view=diff
==============================================================================
--- llvm/branches/Apple/williamson/tools/lto/LTOModule.cpp (original)
+++ llvm/branches/Apple/williamson/tools/lto/LTOModule.cpp Wed Aug 18 15:33:06 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-branch-commits mailing list