summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/include/llvm/Bitcode/BitcodeWriterPass.h16
-rw-r--r--llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp13
2 files changed, 18 insertions, 11 deletions
diff --git a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
index a4521bfc563..dd0d5771196 100644
--- a/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
+++ b/llvm/include/llvm/Bitcode/BitcodeWriterPass.h
@@ -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.
diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
index 85b9bd83c13..7dbede4a847 100644
--- a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
+++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp
@@ -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);
}
OpenPOWER on IntegriCloud