[all-commits] [llvm/llvm-project] 6d4ffb: [clang][CodeGen] Shift relink option implementatio...
Jacob Lambert via All-commits
all-commits at lists.llvm.org
Wed Feb 14 10:39:33 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6d4ffbdfa8ff90e4ee6081ad8dbb8ec24e982a02
https://github.com/llvm/llvm-project/commit/6d4ffbdfa8ff90e4ee6081ad8dbb8ec24e982a02
Author: Jacob Lambert <jacob.lambert at amd.com>
Date: 2024-02-14 (Wed, 14 Feb 2024)
Changed paths:
M clang/include/clang/Basic/FileManager.h
M clang/lib/Basic/FileManager.cpp
M clang/lib/CodeGen/BackendConsumer.h
M clang/lib/CodeGen/CodeGenAction.cpp
M clang/lib/CodeGen/LinkInModulesPass.cpp
Log Message:
-----------
[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()
More information about the All-commits
mailing list