summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
diff options
context:
space:
mode:
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>2017-03-13 18:45:08 +0000
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>2017-03-13 18:45:08 +0000
commit60fa28882eda2a05576e94690a586940ba9ca43c (patch)
treef96f8f1f6610cde2c0f267d531326ce362c47976 /clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
parent75a7e6589f643f6ed47d1fc04339696e7fb1e120 (diff)
downloadbcm5719-llvm-60fa28882eda2a05576e94690a586940ba9ca43c.tar.gz
bcm5719-llvm-60fa28882eda2a05576e94690a586940ba9ca43c.zip
Modules: Use hash of PCM content for SIGNATURE
Change ASTFileSignature from a random 32-bit number to the hash of the PCM content. - Move definition ASTFileSignature to Basic/Module.h so Module and ASTSourceDescriptor can use it. - Change the signature from uint64_t to std::array<uint32_t,5>. - Stop using (saving/reading) the size and modification time of PCM files when there is a valid SIGNATURE. - Add UNHASHED_CONTROL_BLOCK, and use it to store the SIGNATURE record and other records that shouldn't affect the hash. Because implicit modules reuses the same file for multiple levels of -Werror, this includes DIAGNOSTIC_OPTIONS and DIAG_PRAGMA_MAPPINGS. This helps to solve a PCH + implicit Modules dependency issue: PCH files are handled by the external build system, whereas implicit modules are handled by internal compiler build system. This prevents invalidating a PCH when the compiler overwrites a PCM file with the same content (modulo the diagnostic differences). Design and original patch by Manman Ren! llvm-svn: 297655
Diffstat (limited to 'clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp')
-rw-r--r--clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
index 754f9968b67..37ecc05aa1e 100644
--- a/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
+++ b/clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
@@ -171,7 +171,8 @@ public:
// Prepare CGDebugInfo to emit debug info for a clang module.
auto *DI = Builder->getModuleDebugInfo();
StringRef ModuleName = llvm::sys::path::filename(MainFileName);
- DI->setPCHDescriptor({ModuleName, "", OutputFileName, ~1ULL});
+ DI->setPCHDescriptor({ModuleName, "", OutputFileName,
+ ASTFileSignature{{{~0U, ~0U, ~0U, ~0U, ~1U}}}});
DI->setModuleMap(MMap);
}
@@ -241,7 +242,11 @@ public:
// PCH files don't have a signature field in the control block,
// but LLVM detects DWO CUs by looking for a non-zero DWO id.
- uint64_t Signature = Buffer->Signature ? Buffer->Signature : ~1ULL;
+ // We use the lower 64 bits for debug info.
+ uint64_t Signature =
+ Buffer->Signature
+ ? (uint64_t)Buffer->Signature[1] << 32 | Buffer->Signature[0]
+ : ~1ULL;
Builder->getModuleDebugInfo()->setDwoId(Signature);
// Finalize the Builder.
OpenPOWER on IntegriCloud