[llvm] r263777 - Always cache resolved paths as it even saves on StringMap lookups.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 17 22:04:04 PDT 2016


Author: pete
Date: Fri Mar 18 00:04:04 2016
New Revision: 263777

URL: http://llvm.org/viewvc/llvm-project?rev=263777&view=rev
Log:
Always cache resolved paths as it even saves on StringMap lookups.

Now that the resolved path cache stores the StringRef's, its
best to just always cache the results, even when realpath isn't
used.  This way we'll still avoid the StringMap hashing and lookup.

This also conveniently reorganises this code in a way I need for
a future patch.

Modified:
    llvm/trunk/tools/dsymutil/DwarfLinker.cpp

Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=263777&r1=263776&r2=263777&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Fri Mar 18 00:04:04 2016
@@ -1640,22 +1640,20 @@ PointerIntPair<DeclContext *, 1> DeclCon
                   File)) {
             Line = DIE->getAttributeValueAsUnsignedConstant(
                 &U.getOrigUnit(), dwarf::DW_AT_decl_line, 0);
-#ifdef HAVE_REALPATH
             // Cache the resolved paths, because calling realpath is expansive.
             StringRef ResolvedPath = U.getResolvedPath(FileNum);
             if (!ResolvedPath.empty()) {
               FileRef = ResolvedPath;
             } else {
+#ifdef HAVE_REALPATH
               char RealPath[PATH_MAX + 1];
               RealPath[PATH_MAX] = 0;
               if (::realpath(File.c_str(), RealPath))
                 File = RealPath;
+#endif
               FileRef = StringPool.internString(File);
               U.setResolvedPath(FileNum, FileRef);
             }
-#else
-            FileRef = StringPool.internString(File);
-#endif
           }
         }
       }




More information about the llvm-commits mailing list