diff options
author | Adrian Prantl <aprantl@apple.com> | 2016-05-13 00:17:58 +0000 |
---|---|---|
committer | Adrian Prantl <aprantl@apple.com> | 2016-05-13 00:17:58 +0000 |
commit | e1bc3e2027b7e9f9bcf3d0a658d940eac73eda66 (patch) | |
tree | 1a06af0d6d30d2c32dcb83afa260b81c1c757b00 | |
parent | 55c28889c19a2ad60a511b91e4864cbc07db9454 (diff) | |
download | bcm5719-llvm-e1bc3e2027b7e9f9bcf3d0a658d940eac73eda66.tar.gz bcm5719-llvm-e1bc3e2027b7e9f9bcf3d0a658d940eac73eda66.zip |
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
llvm-svn: 269383
-rw-r--r-- | llvm/test/tools/dsymutil/X86/mismatch.m | 9 | ||||
-rw-r--r-- | llvm/tools/dsymutil/DwarfLinker.cpp | 18 |
2 files changed, 21 insertions, 6 deletions
diff --git a/llvm/test/tools/dsymutil/X86/mismatch.m b/llvm/test/tools/dsymutil/X86/mismatch.m index 821097a31ba..0bebe70c12d 100644 --- a/llvm/test/tools/dsymutil/X86/mismatch.m +++ b/llvm/test/tools/dsymutil/X86/mismatch.m @@ -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 diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index b93cac37c33..f4868f35fca 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -3249,7 +3249,10 @@ bool DwarfLinker::registerModuleReference( 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(StringRef Filename, StringRef ModulePath, // 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, |