[llvm] r265907 - Plumb the option to emit the `ModuleHash` in the bitcode through the bitcode writer APIs
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 10 14:07:19 PDT 2016
Author: mehdi_amini
Date: Sun Apr 10 16:07:19 2016
New Revision: 265907
URL: http://llvm.org/viewvc/llvm-project?rev=265907&view=rev
Log:
Plumb the option to emit the `ModuleHash` in the bitcode through the bitcode writer APIs
From: Mehdi Amini <mehdi.amini at apple.com>
Modified:
llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h
llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp
Modified: llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h?rev=265907&r1=265906&r2=265907&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h (original)
+++ llvm/trunk/include/llvm/Bitcode/BitcodeWriterPass.h Sun Apr 10 16:07:19 2016
@@ -30,11 +30,15 @@ class PreservedAnalyses;
/// If \c ShouldPreserveUseListOrder, encode use-list order so it can be
/// reproduced when deserialized.
///
-/// If \c EmitSummaryIndex, emit the summary index (currently
-/// for use in ThinLTO optimization).
+/// If \c EmitSummaryIndex, emit the summary index (currently for use in ThinLTO
+/// optimization).
+///
+/// If \c EmitModuleHash, compute and emit the module hash in the bitcode
+/// (currently for use in ThinLTO incremental build).
ModulePass *createBitcodeWriterPass(raw_ostream &Str,
bool ShouldPreserveUseListOrder = false,
- bool EmitSummaryIndex = false);
+ bool EmitSummaryIndex = false,
+ bool EmitModuleHash = false);
/// \brief Pass for writing a module of IR out to a bitcode file.
///
@@ -44,6 +48,7 @@ class BitcodeWriterPass {
raw_ostream &OS;
bool ShouldPreserveUseListOrder;
bool EmitSummaryIndex;
+ bool EmitModuleHash;
public:
/// \brief Construct a bitcode writer pass around a particular output stream.
@@ -55,9 +60,10 @@ public:
/// for use in ThinLTO optimization).
explicit BitcodeWriterPass(raw_ostream &OS,
bool ShouldPreserveUseListOrder = false,
- bool EmitSummaryIndex = false)
+ bool EmitSummaryIndex = false,
+ bool EmitModuleHash = false)
: OS(OS), ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
- EmitSummaryIndex(EmitSummaryIndex) {}
+ EmitSummaryIndex(EmitSummaryIndex), EmitModuleHash(EmitModuleHash) {}
/// \brief Run the bitcode writer pass, and output the module to the selected
/// output stream.
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp?rev=265907&r1=265906&r2=265907&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriterPass.cpp Sun Apr 10 16:07:19 2016
@@ -19,7 +19,7 @@
using namespace llvm;
PreservedAnalyses BitcodeWriterPass::run(Module &M) {
- WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, EmitSummaryIndex);
+ WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, EmitSummaryIndex, EmitModuleHash);
return PreservedAnalyses::all();
}
@@ -28,19 +28,20 @@ namespace {
raw_ostream &OS; // raw_ostream to print on
bool ShouldPreserveUseListOrder;
bool EmitSummaryIndex;
+ bool EmitModuleHash;
public:
static char ID; // Pass identification, replacement for typeid
explicit WriteBitcodePass(raw_ostream &o, bool ShouldPreserveUseListOrder,
- bool EmitSummaryIndex)
+ bool EmitSummaryIndex, bool EmitModuleHash)
: ModulePass(ID), OS(o),
ShouldPreserveUseListOrder(ShouldPreserveUseListOrder),
- EmitSummaryIndex(EmitSummaryIndex) {}
+ EmitSummaryIndex(EmitSummaryIndex), EmitModuleHash(EmitModuleHash) {}
const char *getPassName() const override { return "Bitcode Writer"; }
bool runOnModule(Module &M) override {
- WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, EmitSummaryIndex);
+ WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, EmitSummaryIndex, EmitModuleHash);
return false;
}
};
@@ -50,7 +51,7 @@ char WriteBitcodePass::ID = 0;
ModulePass *llvm::createBitcodeWriterPass(raw_ostream &Str,
bool ShouldPreserveUseListOrder,
- bool EmitSummaryIndex) {
+ bool EmitSummaryIndex, bool EmitModuleHash) {
return new WriteBitcodePass(Str, ShouldPreserveUseListOrder,
- EmitSummaryIndex);
+ EmitSummaryIndex, EmitModuleHash);
}
More information about the llvm-commits
mailing list