Skip to content

[clang][CodeGen] Remove unnecessary ShouldLinkFiles conditional #96951

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/BackendConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class BackendConsumer : public ASTConsumer {
void HandleVTable(CXXRecordDecl *RD) override;

// Links each entry in LinkModules into our module. Returns true on error.
bool LinkInModules(llvm::Module *M, bool ShouldLinkFiles = true);
bool LinkInModules(llvm::Module *M);

/// Get the best possible source location to represent a diagnostic that
/// may have associated debug info.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1035,7 +1035,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(

// Link against bitcodes supplied via the -mlink-builtin-bitcode option
if (CodeGenOpts.LinkBitcodePostopt)
MPM.addPass(LinkInModulesPass(BC, false));
MPM.addPass(LinkInModulesPass(BC));

// Add a verifier pass if requested. We don't have to do this if the action
// requires code generation because there will already be a verifier pass in
Expand Down
9 changes: 2 additions & 7 deletions clang/lib/CodeGen/CodeGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,16 +226,11 @@ void BackendConsumer::HandleInterestingDecl(DeclGroupRef D) {
HandleTopLevelDecl(D);
}

// Links each entry in LinkModules into our module. Returns true on error.
bool BackendConsumer::LinkInModules(llvm::Module *M, bool ShouldLinkFiles) {
// Links each entry in LinkModules into our module. Returns true on error.
bool BackendConsumer::LinkInModules(llvm::Module *M) {
for (auto &LM : LinkModules) {
assert(LM.Module && "LinkModule does not actually have a module");

// If ShouldLinkFiles is not set, skip files added via the
// -mlink-bitcode-files, only linking -mlink-builtin-bitcode
if (!LM.Internalize && !ShouldLinkFiles)
continue;

if (LM.PropagateAttrs)
for (Function &F : *LM.Module) {
// Skip intrinsics. Keep consistent with how intrinsics are created
Expand Down
7 changes: 3 additions & 4 deletions clang/lib/CodeGen/LinkInModulesPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,14 @@

using namespace llvm;

LinkInModulesPass::LinkInModulesPass(clang::BackendConsumer *BC,
bool ShouldLinkFiles)
: BC(BC), ShouldLinkFiles(ShouldLinkFiles) {}
LinkInModulesPass::LinkInModulesPass(clang::BackendConsumer *BC) : BC(BC),
ShouldLinkFiles(ShouldLinkFiles) {}

PreservedAnalyses LinkInModulesPass::run(Module &M, ModuleAnalysisManager &AM) {
if (!BC)
return PreservedAnalyses::all();

if (BC->LinkInModules(&M, ShouldLinkFiles))
if (BC->LinkInModules(&M))
report_fatal_error("Bitcode module postopt linking failed, aborted!");

return PreservedAnalyses::none();
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/LinkInModulesPass.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LinkInModulesPass : public PassInfoMixin<LinkInModulesPass> {
bool ShouldLinkFiles;

public:
LinkInModulesPass(clang::BackendConsumer *BC, bool ShouldLinkFiles = true);
LinkInModulesPass(clang::BackendConsumer *BC);

PreservedAnalyses run(Module &M, AnalysisManager<Module> &);
static bool isRequired() { return true; }
Expand Down
Loading