[cfe-commits] r143864 - /cfe/trunk/lib/Driver/ToolChains.cpp

Chandler Carruth chandlerc at gmail.com
Sun Nov 6 00:31:36 PDT 2011


Author: chandlerc
Date: Sun Nov  6 01:31:36 2011
New Revision: 143864

URL: http://llvm.org/viewvc/llvm-project?rev=143864&view=rev
Log:
Start pruning down the set of flags passed to CC1 for header search.
This cleans up the CC1 invocations, and reduces the overhead there.
We're still hammering the filesystem looking for the C++ standard
libraries though.

The only reservation I have about this policy is the case of virtualized
files inside of CC1, but it's not clear what the best way to solve that
is. The Driver consistently queries the actual filesystem to make its
decisions. Changing that would be a very large undertaking. It might be
worthwhile, but it's not an immediate goal.

Modified:
    cfe/trunk/lib/Driver/ToolChains.cpp

Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=143864&r1=143863&r2=143864&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Sun Nov  6 01:31:36 2011
@@ -56,6 +56,10 @@
 /// \brief Utility function to add a system include directory to CC1 arguments.
 static void addSystemInclude(const ArgList &DriverArgs, ArgStringList &CC1Args,
                              const Twine &Path) {
+  // Prune out non-existent directories to minimize the number of flags.
+  if (!llvm::sys::fs::exists(Path))
+    return;
+
   CC1Args.push_back("-internal-isystem");
   CC1Args.push_back(DriverArgs.MakeArgString(Path));
 }
@@ -70,6 +74,10 @@
 /// classification.
 static void addExternCSystemInclude(const ArgList &DriverArgs,
                                     ArgStringList &CC1Args, const Twine &Path) {
+  // Prune out non-existent directories to minimize the number of flags.
+  if (!llvm::sys::fs::exists(Path))
+    return;
+
   CC1Args.push_back("-internal-externc-isystem");
   CC1Args.push_back(DriverArgs.MakeArgString(Path));
 }
@@ -80,6 +88,10 @@
                               ArrayRef<StringRef> Paths) {
   for (ArrayRef<StringRef>::iterator I = Paths.begin(), E = Paths.end();
        I != E; ++I) {
+    // Prune out non-existent directories to minimize the number of flags.
+    if (!llvm::sys::fs::exists(*I))
+      continue;
+
     CC1Args.push_back("-internal-isystem");
     CC1Args.push_back(DriverArgs.MakeArgString(*I));
   }





More information about the cfe-commits mailing list