From 7aaf024dac719d6cc73e15074ec8c9ad804229ad Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 31 Jan 2022 16:46:11 -0800 Subject: [PATCH] [BitcodeWriter] Fix cases of some functions `WriteIndexToFile` is used by external projects so I do not touch it. --- clang/lib/CodeGen/BackendUtil.cpp | 2 +- lld/ELF/LTO.cpp | 2 +- llvm/include/llvm/Bitcode/BitcodeWriter.h | 6 +++--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp | 6 +++--- llvm/lib/LTO/LTO.cpp | 2 +- llvm/lib/LTO/LTOBackend.cpp | 6 +++--- llvm/lib/LTO/ThinLTOCodeGenerator.cpp | 2 +- llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp | 2 +- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp | 2 +- llvm/tools/gold/gold-plugin.cpp | 2 +- llvm/tools/llvm-as/llvm-as.cpp | 2 +- llvm/tools/llvm-lto/llvm-lto.cpp | 6 +++--- 12 files changed, 20 insertions(+), 20 deletions(-) diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index da7fed8..a4d330c 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -1746,7 +1746,7 @@ void clang::EmbedBitcode(llvm::Module *M, const CodeGenOptions &CGOpts, llvm::MemoryBufferRef Buf) { if (CGOpts.getEmbedBitcode() == CodeGenOptions::Embed_Off) return; - llvm::EmbedBitcodeInModule( + llvm::embedBitcodeInModule( *M, Buf, CGOpts.getEmbedBitcode() != CodeGenOptions::Embed_Marker, CGOpts.getEmbedBitcode() != CodeGenOptions::Embed_Bitcode, CGOpts.CmdArgs); diff --git a/lld/ELF/LTO.cpp b/lld/ELF/LTO.cpp index 5b7ac6a..88fcd8b 100644 --- a/lld/ELF/LTO.cpp +++ b/lld/ELF/LTO.cpp @@ -292,7 +292,7 @@ static void thinLTOCreateEmptyIndexFiles() { ModuleSummaryIndex m(/*HaveGVs*/ false); m.setSkipModuleByDistributedBackend(); - WriteIndexToFile(m, *os); + writeIndexToFile(m, *os); if (config->thinLTOEmitImportsFiles) openFile(path + ".imports"); } diff --git a/llvm/include/llvm/Bitcode/BitcodeWriter.h b/llvm/include/llvm/Bitcode/BitcodeWriter.h index 7ad2d37..96f25fc 100644 --- a/llvm/include/llvm/Bitcode/BitcodeWriter.h +++ b/llvm/include/llvm/Bitcode/BitcodeWriter.h @@ -139,7 +139,7 @@ class raw_ostream; /// /// ModHash is for use in ThinLTO incremental build, generated while the IR /// bitcode file writing. - void WriteThinLinkBitcodeToFile(const Module &M, raw_ostream &Out, + void writeThinLinkBitcodeToFile(const Module &M, raw_ostream &Out, const ModuleSummaryIndex &Index, const ModuleHash &ModHash); @@ -148,7 +148,7 @@ class raw_ostream; /// writing the combined index file for ThinLTO. When writing a subset of the /// index for a distributed backend, provide the \p ModuleToSummariesForIndex /// map. - void WriteIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, + void writeIndexToFile(const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map *ModuleToSummariesForIndex = nullptr); @@ -161,7 +161,7 @@ class raw_ostream; /// If EmbedCmdline is set, the command line is also exported in /// the corresponding section (__LLVM,_cmdline / .llvmcmd) - even if CmdArgs /// were empty. - void EmbedBitcodeInModule(Module &M, MemoryBufferRef Buf, bool EmbedBitcode, + void embedBitcodeInModule(Module &M, MemoryBufferRef Buf, bool EmbedBitcode, bool EmbedCmdline, const std::vector &CmdArgs); diff --git a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp index eb4e09e..4bba0b3 100644 --- a/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/llvm/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -4669,7 +4669,7 @@ void IndexBitcodeWriter::write() { // where it will be written in a new bitcode block. This is used when // writing the combined index file for ThinLTO. When writing a subset of the // index for a distributed backend, provide a \p ModuleToSummariesForIndex map. -void llvm::WriteIndexToFile( +void llvm::writeIndexToFile( const ModuleSummaryIndex &Index, raw_ostream &Out, const std::map *ModuleToSummariesForIndex) { SmallVector Buffer; @@ -4829,7 +4829,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 Buffer; @@ -4881,7 +4881,7 @@ static const char *getSectionNameForCommandline(const Triple &T) { llvm_unreachable("Unimplemented ObjectFormatType"); } -void llvm::EmbedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, +void llvm::embedBitcodeInModule(llvm::Module &M, llvm::MemoryBufferRef Buf, bool EmbedBitcode, bool EmbedCmdline, const std::vector &CmdArgs) { // Save llvm.compiler.used and remove it. diff --git a/llvm/lib/LTO/LTO.cpp b/llvm/lib/LTO/LTO.cpp index f26ef4b..882e043 100644 --- a/llvm/lib/LTO/LTO.cpp +++ b/llvm/lib/LTO/LTO.cpp @@ -1372,7 +1372,7 @@ public: sys::fs::OpenFlags::OF_None); if (EC) return errorCodeToError(EC); - WriteIndexToFile(CombinedIndex, OS, &ModuleToSummariesForIndex); + writeIndexToFile(CombinedIndex, OS, &ModuleToSummariesForIndex); if (ShouldEmitImportsFiles) { EC = EmitImportsFiles(ModulePath, NewModulePath + ".imports", diff --git a/llvm/lib/LTO/LTOBackend.cpp b/llvm/lib/LTO/LTOBackend.cpp index 7694c98..91487fa 100644 --- a/llvm/lib/LTO/LTOBackend.cpp +++ b/llvm/lib/LTO/LTOBackend.cpp @@ -144,7 +144,7 @@ Error Config::addSaveTemps(std::string OutputFileName, // directly and exit. if (EC) reportOpenError(Path, EC.message()); - WriteIndexToFile(Index, OS); + writeIndexToFile(Index, OS); Path = OutputFileName + "index.dot"; raw_fd_ostream OSDot(Path, EC, sys::fs::OpenFlags::OF_None); @@ -359,7 +359,7 @@ bool lto::opt(const Config &Conf, TargetMachine *TM, unsigned Task, Module &Mod, LLVM_DEBUG( dbgs() << "Post-(Thin)LTO merge bitcode embedding was requested, but " "command line arguments are not available"); - llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(), + llvm::embedBitcodeInModule(Mod, llvm::MemoryBufferRef(), /*EmbedBitcode*/ true, /*EmbedCmdline*/ true, /*Cmdline*/ CmdArgs); } @@ -380,7 +380,7 @@ static void codegen(const Config &Conf, TargetMachine *TM, return; if (EmbedBitcode == LTOBitcodeEmbedding::EmbedOptimized) - llvm::EmbedBitcodeInModule(Mod, llvm::MemoryBufferRef(), + llvm::embedBitcodeInModule(Mod, llvm::MemoryBufferRef(), /*EmbedBitcode*/ true, /*EmbedCmdline*/ false, /*CmdArgs*/ std::vector()); diff --git a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp index 9aea27f..37e85b6 100644 --- a/llvm/lib/LTO/ThinLTOCodeGenerator.cpp +++ b/llvm/lib/LTO/ThinLTOCodeGenerator.cpp @@ -1052,7 +1052,7 @@ void ThinLTOCodeGenerator::run() { if (EC) report_fatal_error(Twine("Failed to open ") + SaveTempPath + " to save optimized bitcode\n"); - WriteIndexToFile(*Index, OS); + writeIndexToFile(*Index, OS); } diff --git a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp index daaf6cb..52708ff 100644 --- a/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp +++ b/llvm/lib/Transforms/IPO/ThinLTOBitcodeWriter.cpp @@ -535,7 +535,7 @@ void writeThinLTOBitcode(raw_ostream &OS, raw_ostream *ThinLinkOS, // 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 { diff --git a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp index 6acace1..8b30f0e 100644 --- a/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp +++ b/llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp @@ -970,7 +970,7 @@ bool DevirtModule::runForTesting( if (StringRef(ClWriteSummary).endswith(".bc")) { raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::OF_None); ExitOnErr(errorCodeToError(EC)); - WriteIndexToFile(*Summary, OS); + writeIndexToFile(*Summary, OS); } else { raw_fd_ostream OS(ClWriteSummary, EC, sys::fs::OF_TextWithCRLF); ExitOnErr(errorCodeToError(EC)); diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 8d35dfe..180c181 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -995,7 +995,7 @@ static void writeEmptyDistributedBuildOutputs(const std::string &ModulePath, if (SkipModule) { ModuleSummaryIndex Index(/*HaveGVs*/ false); Index.setSkipModuleByDistributedBackend(); - WriteIndexToFile(Index, OS, nullptr); + writeIndexToFile(Index, OS, nullptr); } } if (options::thinlto_emit_imports_files) { diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp index 307a7f9..11dad0d 100644 --- a/llvm/tools/llvm-as/llvm-as.cpp +++ b/llvm/tools/llvm-as/llvm-as.cpp @@ -106,7 +106,7 @@ static void WriteOutputFile(const Module *M, const ModuleSummaryIndex *Index) { else // Otherwise, with an empty Module but non-empty Index, we write a // combined index. - WriteIndexToFile(*IndexToWrite, Out->os()); + writeIndexToFile(*IndexToWrite, Out->os()); } // Declare success. diff --git a/llvm/tools/llvm-lto/llvm-lto.cpp b/llvm/tools/llvm-lto/llvm-lto.cpp index d78c4df..8fc3a5d 100644 --- a/llvm/tools/llvm-lto/llvm-lto.cpp +++ b/llvm/tools/llvm-lto/llvm-lto.cpp @@ -497,7 +497,7 @@ static void createCombinedModuleSummaryIndex() { raw_fd_ostream OS(OutputFilename + ".thinlto.bc", EC, sys::fs::OpenFlags::OF_None); error(EC, "error opening the file '" + OutputFilename + ".thinlto.bc'"); - WriteIndexToFile(CombinedIndex, OS); + writeIndexToFile(CombinedIndex, OS); OS.close(); } @@ -660,7 +660,7 @@ private: std::error_code EC; raw_fd_ostream OS(OutputFilename, EC, sys::fs::OpenFlags::OF_None); error(EC, "error opening the file '" + OutputFilename + "'"); - WriteIndexToFile(*CombinedIndex, OS); + writeIndexToFile(*CombinedIndex, OS); } /// Load the combined index from disk, then compute and generate @@ -698,7 +698,7 @@ private: std::error_code EC; raw_fd_ostream OS(OutputName, EC, sys::fs::OpenFlags::OF_None); error(EC, "error opening the file '" + OutputName + "'"); - WriteIndexToFile(*Index, OS, &ModuleToSummariesForIndex); + writeIndexToFile(*Index, OS, &ModuleToSummariesForIndex); } } -- 2.7.4