aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Basic/FileManager.cpp
diff options
context:
space:
mode:
authorJacob Lambert <jacob.lambert@amd.com>2024-02-14 10:39:21 -0800
committerGitHub <noreply@github.com>2024-02-14 10:39:21 -0800
commit6d4ffbdfa8ff90e4ee6081ad8dbb8ec24e982a02 (patch)
treedebbfdb627a498626e0e69a32a8c290c3ee6d1a5 /clang/lib/Basic/FileManager.cpp
parent16e7d6842ef6a5c904422c6dba034e0888ea8b7b (diff)
downloadllvm-6d4ffbdfa8ff90e4ee6081ad8dbb8ec24e982a02.zip
llvm-6d4ffbdfa8ff90e4ee6081ad8dbb8ec24e982a02.tar.gz
llvm-6d4ffbdfa8ff90e4ee6081ad8dbb8ec24e982a02.tar.bz2
[clang][CodeGen] Shift relink option implementation away from module cloning (#81693)
We recently implemented a new option allowing relinking of bitcode modules via the "-mllvm -relink-builtin-bitcode-postop" option. This implementation relied on llvm::CloneModule() in order to pass copies to modules and preserve the original modules for later relinking. However, cloning modules has been found to be prohibitively expensive, significantly increasing compilation time for large bitcode libraries. In this patch, we shift the relink option implementation to instead link the original modules initially, and reload modules from the file system if relinking is requested. This approach results in significantly reduced overhead. We accomplish this by creating a new ReloadModules() routine that can be called from a BackendConsumer class, to mimic the behavior of ASTConsumer's loadLinkModules(), but without access to the CompilerInstance. Because loading the bitcodes from the filesystem requires access to the FileManager class, we also forward a reference to the CompilerInstance class to the BackendConsumer. This mirrors what is already done for several CompilerInstance members, such as TargetOptions and CodeGenOptions. Finally, we needed to add a const specifier to the FileManager::getBufferForFile() routine to allow it to be called using the const reference returned from CompilerInstance::getFileManager()
Diffstat (limited to 'clang/lib/Basic/FileManager.cpp')
-rw-r--r--clang/lib/Basic/FileManager.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index 6097a27..cd520a6 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -547,7 +547,7 @@ FileManager::getBufferForFile(FileEntryRef FE, bool isVolatile,
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>>
FileManager::getBufferForFileImpl(StringRef Filename, int64_t FileSize,
bool isVolatile,
- bool RequiresNullTerminator) {
+ bool RequiresNullTerminator) const {
if (FileSystemOpts.WorkingDir.empty())
return FS->getBufferForFile(Filename, FileSize, RequiresNullTerminator,
isVolatile);