[llvm] r269383 - dsymutil: Fix the DWOId mismatch check for cached modules.

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Thu May 12 17:17:59 PDT 2016


Author: adrian
Date: Thu May 12 19:17:58 2016
New Revision: 269383

URL: http://llvm.org/viewvc/llvm-project?rev=269383&view=rev
Log:
dsymutil: Fix the DWOId mismatch check for cached modules.

In verbose mode, we emit a warning if the DWOId of a skeleton CU
mismatches the DWOId of the referenced module. This patch updates the
cached DWOId after a module has been loaded to the DWOId of the module
on disk (instead of storing the DWOId we expected to load). This
allows us to correctly emit the mismatch warning for all subsequent
object files that want to import the same module. This patch also
ensures both warnings are only emitted in verbose mode.

rdar://problem/26214027

Modified:
    llvm/trunk/test/tools/dsymutil/X86/mismatch.m
    llvm/trunk/tools/dsymutil/DwarfLinker.cpp

Modified: llvm/trunk/test/tools/dsymutil/X86/mismatch.m
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/dsymutil/X86/mismatch.m?rev=269383&r1=269382&r2=269383&view=diff
==============================================================================
--- llvm/trunk/test/tools/dsymutil/X86/mismatch.m (original)
+++ llvm/trunk/test/tools/dsymutil/X86/mismatch.m Thu May 12 19:17:58 2016
@@ -14,10 +14,17 @@
       -fdisable-module-hash mismatch.m -o /dev/null
 */
 
-// RUN: llvm-dsymutil --verbose -f -oso-prepend-path=%p/../Inputs/mismatch \
+// RUN: rm -rf %t.dir && mkdir %t.dir
+// RUN: cp %p/../Inputs/mismatch/1.o %p/../Inputs/mismatch/mismatch.pcm %t.dir
+// RUN: cp %p/../Inputs/mismatch/1.o %t.dir/2.o
+// RUN: llvm-dsymutil --verbose -f -oso-prepend-path=%t.dir \
 // RUN:   -y %p/dummy-debug-map.map -o %t.bin 2>&1 | FileCheck %s
 
 @import mismatch;
 
 void f() {}
+// Mismatch after importing the module.
 // CHECK: warning: hash mismatch
+// Mismatch in the cache.
+// CHECK: warning: hash mismatch
+// CHECK: cached

Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=269383&r1=269382&r2=269383&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Thu May 12 19:17:58 2016
@@ -3249,7 +3249,10 @@ bool DwarfLinker::registerModuleReferenc
 
   auto Cached = ClangModules.find(PCMfile);
   if (Cached != ClangModules.end()) {
-    if (Cached->second != DwoId)
+    // FIXME: Until PR27449 (https://llvm.org/bugs/show_bug.cgi?id=27449) is
+    // fixed in clang, only warn about DWO_id mismatches in verbose mode.
+    // ASTFileSignatures will change randomly when a module is rebuilt.
+    if (Options.Verbose && (Cached->second != DwoId))
       reportWarning(Twine("hash mismatch: this object file was built against a "
                           "different version of the module ") + PCMfile);
     if (Options.Verbose)
@@ -3343,10 +3346,15 @@ void DwarfLinker::loadClangModule(String
       // FIXME: Until PR27449 (https://llvm.org/bugs/show_bug.cgi?id=27449) is
       // fixed in clang, only warn about DWO_id mismatches in verbose mode.
       // ASTFileSignatures will change randomly when a module is rebuilt.
-      if (Options.Verbose && (getDwoId(*CUDie, *CU) != DwoId))
-        reportWarning(
-            Twine("hash mismatch: this object file was built against a "
-                  "different version of the module ") + Filename);
+      uint64_t PCMDwoId = getDwoId(*CUDie, *CU);
+      if (PCMDwoId != DwoId) {
+        if (Options.Verbose)
+          reportWarning(
+              Twine("hash mismatch: this object file was built against a "
+                    "different version of the module ") + Filename);
+        // Update the cache entry with the DwoId of the module loaded from disk.
+        ClangModules[Filename] = PCMDwoId;
+      }
 
       // Add this module.
       Unit = llvm::make_unique<CompileUnit>(*CU, UnitID++, !Options.NoODR,




More information about the llvm-commits mailing list