diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitWriter.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 31 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/CodeGen/ParallelCG.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/FuzzMutate/FuzzerCLI.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/LTO/LTOBackend.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 4 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp | 17 |
9 files changed, 36 insertions, 38 deletions
diff --git a/llvm/lib/Bitcode/Writer/BitWriter.cpp b/llvm/lib/Bitcode/Writer/BitWriter.cpp index e0388418a3d..763cd12aa2d 100644 --- a/llvm/lib/Bitcode/Writer/BitWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitWriter.cpp @@ -25,7 +25,7 @@ int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path) { if (EC) return -1; - WriteBitcodeToFile(unwrap(M), OS); + WriteBitcodeToFile(*unwrap(M), OS); return 0; } @@ -33,7 +33,7 @@ int LLVMWriteBitcodeToFD(LLVMModuleRef M, int FD, int ShouldClose, int Unbuffered) { raw_fd_ostream OS(FD, ShouldClose, Unbuffered); - WriteBitcodeToFile(unwrap(M), OS); + WriteBitcodeToFile(*unwrap(M), OS); return 0; } @@ -45,6 +45,6 @@ LLVMMemoryBufferRef LLVMWriteBitcodeToMemoryBuffer(LLVMModuleRef M) { std::string Data; raw_string_ostream OS(Data); - WriteBitcodeToFile(unwrap(M), OS); + WriteBitcodeToFile(*unwrap(M), OS); return wrap(MemoryBuffer::getMemBufferCopy(OS.str()).release()); } diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index 10620113386..b087f010de1 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -170,12 +170,12 @@ protected: public: /// Constructs a ModuleBitcodeWriterBase object for the given Module, /// writing to the provided \p Buffer. - ModuleBitcodeWriterBase(const Module *M, StringTableBuilder &StrtabBuilder, + ModuleBitcodeWriterBase(const Module &M, StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream, bool ShouldPreserveUseListOrder, const ModuleSummaryIndex *Index) - : BitcodeWriterBase(Stream, StrtabBuilder), M(*M), - VE(*M, ShouldPreserveUseListOrder), Index(Index) { + : BitcodeWriterBase(Stream, StrtabBuilder), M(M), + VE(M, ShouldPreserveUseListOrder), Index(Index) { // Assign ValueIds to any callee values in the index that came from // indirect call profiles and were recorded as a GUID not a Value* // (which would have been assigned an ID by the ValueEnumerator). @@ -254,7 +254,7 @@ class ModuleBitcodeWriter : public ModuleBitcodeWriterBase { public: /// Constructs a ModuleBitcodeWriter object for the given Module, /// writing to the provided \p Buffer. - ModuleBitcodeWriter(const Module *M, SmallVectorImpl<char> &Buffer, + ModuleBitcodeWriter(const Module &M, SmallVectorImpl<char> &Buffer, StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream, bool ShouldPreserveUseListOrder, const ModuleSummaryIndex *Index, bool GenerateHash, @@ -4038,7 +4038,7 @@ void BitcodeWriter::copyStrtab(StringRef Strtab) { WroteStrtab = true; } -void BitcodeWriter::writeModule(const Module *M, +void BitcodeWriter::writeModule(const Module &M, bool ShouldPreserveUseListOrder, const ModuleSummaryIndex *Index, bool GenerateHash, ModuleHash *ModHash) { @@ -4048,8 +4048,8 @@ void BitcodeWriter::writeModule(const Module *M, // Modules in case it needs to materialize metadata. But the bitcode writer // requires that the module is materialized, so we can cast to non-const here, // after checking that it is in fact materialized. - assert(M->isMaterialized()); - Mods.push_back(const_cast<Module *>(M)); + assert(M.isMaterialized()); + Mods.push_back(const_cast<Module *>(&M)); ModuleBitcodeWriter ModuleWriter(M, Buffer, StrtabBuilder, *Stream, ShouldPreserveUseListOrder, Index, @@ -4065,9 +4065,8 @@ void BitcodeWriter::writeIndex( IndexWriter.write(); } -/// WriteBitcodeToFile - Write the specified module to the specified output -/// stream. -void llvm::WriteBitcodeToFile(const Module *M, raw_ostream &Out, +/// Write the specified module to the specified output stream. +void llvm::WriteBitcodeToFile(const Module &M, raw_ostream &Out, bool ShouldPreserveUseListOrder, const ModuleSummaryIndex *Index, bool GenerateHash, ModuleHash *ModHash) { @@ -4076,7 +4075,7 @@ void llvm::WriteBitcodeToFile(const Module *M, raw_ostream &Out, // If this is darwin or another generic macho target, reserve space for the // header. - Triple TT(M->getTargetTriple()); + Triple TT(M.getTargetTriple()); if (TT.isOSDarwin() || TT.isOSBinFormatMachO()) Buffer.insert(Buffer.begin(), BWH_HeaderSize, 0); @@ -4133,7 +4132,7 @@ class ThinLinkBitcodeWriter : public ModuleBitcodeWriterBase { const ModuleHash *ModHash; public: - ThinLinkBitcodeWriter(const Module *M, StringTableBuilder &StrtabBuilder, + ThinLinkBitcodeWriter(const Module &M, StringTableBuilder &StrtabBuilder, BitstreamWriter &Stream, const ModuleSummaryIndex &Index, const ModuleHash &ModHash) @@ -4251,7 +4250,7 @@ void ThinLinkBitcodeWriter::write() { Stream.ExitBlock(); } -void BitcodeWriter::writeThinLinkBitcode(const Module *M, +void BitcodeWriter::writeThinLinkBitcode(const Module &M, const ModuleSummaryIndex &Index, const ModuleHash &ModHash) { assert(!WroteStrtab); @@ -4260,8 +4259,8 @@ void BitcodeWriter::writeThinLinkBitcode(const Module *M, // Modules in case it needs to materialize metadata. But the bitcode writer // requires that the module is materialized, so we can cast to non-const here, // after checking that it is in fact materialized. - assert(M->isMaterialized()); - Mods.push_back(const_cast<Module *>(M)); + assert(M.isMaterialized()); + Mods.push_back(const_cast<Module *>(&M)); ThinLinkBitcodeWriter ThinLinkWriter(M, StrtabBuilder, *Stream, Index, ModHash); @@ -4271,7 +4270,7 @@ void BitcodeWriter::writeThinLinkBitcode(const Module *M, // Write the specified thin link bitcode file to the given raw output stream, // where it will be written in a new bitcode block. This is used when // writing the per-module index file for ThinLTO. -void llvm::WriteThinLinkBitcodeToFile(const Module *M, raw_ostream &Out, +void llvm::WriteThinLinkBitcodeToFile(const Module &M, raw_ostream &Out, const ModuleSummaryIndex &Index, const ModuleHash &ModHash) { SmallVector<char, 0> Buffer; diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp index 80cab762a68..cbed3d4495a 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriterPass.cpp @@ -23,7 +23,7 @@ PreservedAnalyses BitcodeWriterPass::run(Module &M, ModuleAnalysisManager &AM) { const ModuleSummaryIndex *Index = EmitSummaryIndex ? &(AM.getResult<ModuleSummaryIndexAnalysis>(M)) : nullptr; - WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, Index, EmitModuleHash); + WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, Index, EmitModuleHash); return PreservedAnalyses::all(); } @@ -55,7 +55,7 @@ namespace { EmitSummaryIndex ? &(getAnalysis<ModuleSummaryIndexWrapperPass>().getIndex()) : nullptr; - WriteBitcodeToFile(&M, OS, ShouldPreserveUseListOrder, Index, + WriteBitcodeToFile(M, OS, ShouldPreserveUseListOrder, Index, EmitModuleHash); return false; } diff --git a/llvm/lib/CodeGen/ParallelCG.cpp b/llvm/lib/CodeGen/ParallelCG.cpp index ff8680a0540..4624b224b95 100644 --- a/llvm/lib/CodeGen/ParallelCG.cpp +++ b/llvm/lib/CodeGen/ParallelCG.cpp @@ -44,7 +44,7 @@ std::unique_ptr<Module> llvm::splitCodeGen( if (OSs.size() == 1) { if (!BCOSs.empty()) - WriteBitcodeToFile(M.get(), *BCOSs[0]); + WriteBitcodeToFile(*M, *BCOSs[0]); codegen(M.get(), *OSs[0], TMFactory, FileType); return M; } @@ -66,7 +66,7 @@ std::unique_ptr<Module> llvm::splitCodeGen( // FIXME: Provide a more direct way to do this in LLVM. SmallString<0> BC; raw_svector_ostream BCOS(BC); - WriteBitcodeToFile(MPart.get(), BCOS); + WriteBitcodeToFile(*MPart, BCOS); if (!BCOSs.empty()) { BCOSs[ThreadCount]->write(BC.begin(), BC.size()); diff --git a/llvm/lib/FuzzMutate/FuzzerCLI.cpp b/llvm/lib/FuzzMutate/FuzzerCLI.cpp index 43698c605a2..04939023e26 100644 --- a/llvm/lib/FuzzMutate/FuzzerCLI.cpp +++ b/llvm/lib/FuzzMutate/FuzzerCLI.cpp @@ -169,7 +169,7 @@ size_t llvm::writeModule(const Module &M, uint8_t *Dest, size_t MaxSize) { std::string Buf; { raw_string_ostream OS(Buf); - WriteBitcodeToFile(&M, OS); + WriteBitcodeToFile(M, OS); } if (Buf.size() > MaxSize) return 0; diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 4dbdd26be9d..074a3986015 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -82,7 +82,7 @@ Error Config::addSaveTemps(std::string OutputFileName, // directly and exit. if (EC) reportOpenError(Path, EC.message()); - WriteBitcodeToFile(&M, OS, /*ShouldPreserveUseListOrder=*/false); + WriteBitcodeToFile(M, OS, /*ShouldPreserveUseListOrder=*/false); return true; }; }; @@ -309,7 +309,7 @@ void splitCodeGen(Config &C, TargetMachine *TM, AddStreamFn AddStream, // FIXME: Provide a more direct way to do this in LLVM. SmallString<0> BC; raw_svector_ostream BCOS(BC); - WriteBitcodeToFile(MPart.get(), BCOS); + WriteBitcodeToFile(*MPart, BCOS); // Enqueue the task CodegenThreadPool.async( diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index c7306df95d3..ffe9af74cdc 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -220,7 +220,7 @@ bool LTOCodeGenerator::writeMergedModules(StringRef Path) { } // write bitcode to it - WriteBitcodeToFile(MergedModule.get(), Out.os(), ShouldEmbedUselists); + WriteBitcodeToFile(*MergedModule, Out.os(), ShouldEmbedUselists); Out.os().close(); if (Out.os().has_error()) { diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index b2e34c54428..92cc2450773 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -82,7 +82,7 @@ static void saveTempBitcode(const Module &TheModule, StringRef TempDir, if (EC) report_fatal_error(Twine("Failed to open ") + SaveTempPath + " to save optimized bitcode\n"); - WriteBitcodeToFile(&TheModule, OS, /* ShouldPreserveUseListOrder */ true); + WriteBitcodeToFile(TheModule, OS, /* ShouldPreserveUseListOrder */ true); } static const GlobalValueSummary * @@ -476,7 +476,7 @@ ProcessThinLTOModule(Module &TheModule, ModuleSummaryIndex &Index, raw_svector_ostream OS(OutputBuffer); ProfileSummaryInfo PSI(TheModule); auto Index = buildModuleSummaryIndex(TheModule, nullptr, &PSI); - WriteBitcodeToFile(&TheModule, OS, true, &Index); + WriteBitcodeToFile(TheModule, OS, true, &Index); } return make_unique<ObjectMemoryBuffer>(std::move(OutputBuffer)); } diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp index 7cc1e06964b..5c1f678b4d9 100644 --- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp +++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp @@ -202,11 +202,11 @@ void splitAndWriteThinLTOBitcode( if (ModuleId.empty()) { // We couldn't generate a module ID for this module, just write it out as a // regular LTO module. - WriteBitcodeToFile(&M, OS); + WriteBitcodeToFile(M, OS); if (ThinLinkOS) // We don't have a ThinLTO part, but still write the module to the // ThinLinkOS if requested so that the expected output file is produced. - WriteBitcodeToFile(&M, *ThinLinkOS); + WriteBitcodeToFile(M, *ThinLinkOS); return; } @@ -374,10 +374,9 @@ void splitAndWriteThinLTOBitcode( // be used in the backends, and use that in the minimized bitcode // produced for the full link. ModuleHash ModHash = {{0}}; - W.writeModule(&M, /*ShouldPreserveUseListOrder=*/false, &Index, + W.writeModule(M, /*ShouldPreserveUseListOrder=*/false, &Index, /*GenerateHash=*/true, &ModHash); - W.writeModule(MergedM.get(), /*ShouldPreserveUseListOrder=*/false, - &MergedMIndex); + W.writeModule(*MergedM, /*ShouldPreserveUseListOrder=*/false, &MergedMIndex); W.writeSymtab(); W.writeStrtab(); OS << Buffer; @@ -389,8 +388,8 @@ void splitAndWriteThinLTOBitcode( Buffer.clear(); BitcodeWriter W2(Buffer); StripDebugInfo(M); - W2.writeThinLinkBitcode(&M, Index, ModHash); - W2.writeModule(MergedM.get(), /*ShouldPreserveUseListOrder=*/false, + W2.writeThinLinkBitcode(M, Index, ModHash); + W2.writeModule(*MergedM, /*ShouldPreserveUseListOrder=*/false, &MergedMIndex); W2.writeSymtab(); W2.writeStrtab(); @@ -423,13 +422,13 @@ void writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS, // be used in the backends, and use that in the minimized bitcode // produced for the full link. ModuleHash ModHash = {{0}}; - WriteBitcodeToFile(&M, OS, /*ShouldPreserveUseListOrder=*/false, Index, + WriteBitcodeToFile(M, OS, /*ShouldPreserveUseListOrder=*/false, Index, /*GenerateHash=*/true, &ModHash); // If a minimized bitcode module was requested for the thin link, only // the information that is needed by thin link will be written in the // given OS. if (ThinLinkOS && Index) - WriteThinLinkBitcodeToFile(&M, *ThinLinkOS, *Index, ModHash); + WriteThinLinkBitcodeToFile(M, *ThinLinkOS, *Index, ModHash); } class WriteThinLTOBitcode : public ModulePass { |