Re: [PATCH] D20454: Eliminate unnecessary file access checks in Clang driver on Windows
This revision was automatically updated to reflect the committed changes. Closed by commit rL270226: Eliminate unnecessary file access checks in Clang driver on Windows (authored by amccarth). Changed prior to commit: http://reviews.llvm.org/D20454?vs=57872&id=57936#toc Repository: rL LLVM http://reviews.llvm.org/D20454 Files: cfe/trunk/lib/Driver/MSVCToolChain.cpp Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp === --- cfe/trunk/lib/Driver/MSVCToolChain.cpp +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp @@ -408,7 +408,10 @@ SmallString<128> FilePath(PathSegment); llvm::sys::path::append(FilePath, "cl.exe"); -if (llvm::sys::fs::can_execute(FilePath.c_str()) && +// Checking if cl.exe exists is a small optimization over calling +// can_execute, which really only checks for existence but will also do +// extra checks for cl.exe.exe. These add up when walking a long path. +if (llvm::sys::fs::exists(FilePath.c_str()) && !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) { // If we found it on the PATH, use it exactly as is with no // modifications. Index: cfe/trunk/lib/Driver/MSVCToolChain.cpp === --- cfe/trunk/lib/Driver/MSVCToolChain.cpp +++ cfe/trunk/lib/Driver/MSVCToolChain.cpp @@ -408,7 +408,10 @@ SmallString<128> FilePath(PathSegment); llvm::sys::path::append(FilePath, "cl.exe"); -if (llvm::sys::fs::can_execute(FilePath.c_str()) && +// Checking if cl.exe exists is a small optimization over calling +// can_execute, which really only checks for existence but will also do +// extra checks for cl.exe.exe. These add up when walking a long path. +if (llvm::sys::fs::exists(FilePath.c_str()) && !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) { // If we found it on the PATH, use it exactly as is with no // modifications. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D20454: Eliminate unnecessary file access checks in Clang driver on Windows
majnemer accepted this revision. majnemer added a comment. This revision is now accepted and ready to land. LGTM http://reviews.llvm.org/D20454 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D20454: Eliminate unnecessary file access checks in Clang driver on Windows
amccarth created this revision. amccarth added a reviewer: majnemer. amccarth added a subscriber: cfe-commits. This fixes the problem where the driver will look for cl.exe.exe while walking the PATH. I looked into changing the Windows implementation of llvm::sys::fs::can_execute(), but there wasn't a satisfying way to preserve the extra checks for the callers that depend on it. I also looked into having it actually check that the file is an executable, but this seemed to add little value at the cost of more file i/o. http://reviews.llvm.org/D20454 Files: lib/Driver/MSVCToolChain.cpp Index: lib/Driver/MSVCToolChain.cpp === --- lib/Driver/MSVCToolChain.cpp +++ lib/Driver/MSVCToolChain.cpp @@ -408,7 +408,10 @@ SmallString<128> FilePath(PathSegment); llvm::sys::path::append(FilePath, "cl.exe"); -if (llvm::sys::fs::can_execute(FilePath.c_str()) && +// Checking if cl.exe exists is a small optimization over calling +// can_execute, which really only checks for existence but will also do +// extra checks for cl.exe.exe. These add up when walking a long path. +if (llvm::sys::fs::exists(FilePath.c_str()) && !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) { // If we found it on the PATH, use it exactly as is with no // modifications. Index: lib/Driver/MSVCToolChain.cpp === --- lib/Driver/MSVCToolChain.cpp +++ lib/Driver/MSVCToolChain.cpp @@ -408,7 +408,10 @@ SmallString<128> FilePath(PathSegment); llvm::sys::path::append(FilePath, "cl.exe"); -if (llvm::sys::fs::can_execute(FilePath.c_str()) && +// Checking if cl.exe exists is a small optimization over calling +// can_execute, which really only checks for existence but will also do +// extra checks for cl.exe.exe. These add up when walking a long path. +if (llvm::sys::fs::exists(FilePath.c_str()) && !llvm::sys::fs::equivalent(FilePath.c_str(), clangProgramPath)) { // If we found it on the PATH, use it exactly as is with no // modifications. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits