[llvm-commits] CVS: llvm/tools/gccld/GenerateCode.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Sep 22 23:11:36 PDT 2005



Changes in directory llvm/tools/gccld:

GenerateCode.cpp updated: 1.52 -> 1.53
---
Log message:

Speed up isBytecodeLPath from 20s to .01s in common cases.  This makes -native
not completely painful to use.  Once we decide a directory has a bytecode 
library, we know it this function returns true, no need to scan entire directories.


---
Diffs of the changes:  (+11 -17)

 GenerateCode.cpp |   28 +++++++++++-----------------
 1 files changed, 11 insertions(+), 17 deletions(-)


Index: llvm/tools/gccld/GenerateCode.cpp
diff -u llvm/tools/gccld/GenerateCode.cpp:1.52 llvm/tools/gccld/GenerateCode.cpp:1.53
--- llvm/tools/gccld/GenerateCode.cpp:1.52	Fri Sep 23 01:05:46 2005
+++ llvm/tools/gccld/GenerateCode.cpp	Fri Sep 23 01:11:24 2005
@@ -148,49 +148,43 @@
 }
 
 static bool isBytecodeLPath(const std::string &LibPath) {
-  bool isBytecodeLPath = false;
-
   sys::Path LPath(LibPath);
 
-  // Make sure it exists
-  if (!LPath.exists())
-    return isBytecodeLPath;
-
-  // Make sure its a directory
+  // Make sure it exists and is a directory
   try {
-    if (!LPath.isDirectory())
-      return isBytecodeLPath;
+    if (!LPath.exists() || !LPath.isDirectory())
+      return false;
   } catch (std::string& xcptn) {
-    return isBytecodeLPath;
+    return false;
   }
-
+  
   // Grab the contents of the -L path
   std::set<sys::Path> Files;
   LPath.getDirectoryContents(Files);
-
+  
   // Iterate over the contents one by one to determine
   // if this -L path has any bytecode shared libraries
   // or archives
   std::set<sys::Path>::iterator File = Files.begin();
+  std::string dllsuffix = sys::Path::GetDLLSuffix();
   for (; File != Files.end(); ++File) {
 
     if ( File->isDirectory() )
       continue;
 
     std::string path = File->toString();
-    std::string dllsuffix = sys::Path::GetDLLSuffix();
 
     // Check for an ending '.dll,.so' or '.a' suffix as all
     // other files are not of interest to us here
-    if ( path.find(dllsuffix, path.size()-dllsuffix.size()) == std::string::npos
-        && path.find(".a", path.size()-2) == std::string::npos )
+    if (path.find(dllsuffix, path.size()-dllsuffix.size()) == std::string::npos
+        && path.find(".a", path.size()-2) == std::string::npos)
       continue;
 
     // Finally, check to see if the file is a true bytecode file
     if (isBytecodeLibrary(*File))
-      isBytecodeLPath = true;
+      return true;
   }
-  return isBytecodeLPath;
+  return false;
 }
 
 /// GenerateBytecode - generates a bytecode file from the specified module.






More information about the llvm-commits mailing list