Repository navigation
[Passes] Make runCodeGenPipeline take raw_pwrite_stream for DwoOS - #235339
Merged
boomanaiden154 merged 2 commits intoOct 24, 2026
Merged
Conversation
The std::unique_ptr reference was mostly cargo-culting from clang/flang that does not necessarily make sense for other frontends (case study right now is rustc). Change to a raw_pwrite_stream given that makes more sense internally and gives frontends more flexibility.
|
@llvm/pr-subscribers-clang-codegen @llvm/pr-subscribers-flang-driver Author: Aiden Grossman (boomanaiden154) ChangesThe std::unique_ptr reference was mostly cargo-culting from clang/flang that does not necessarily make sense for other frontends (case study right now is rustc). Change to a raw_pwrite_stream given that makes more sense internally and gives frontends more flexibility. 4 Files Affected:
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 8331ad64df3dff..fe1454026f569d 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1282,7 +1282,8 @@ void EmitAssemblyHelper::RunCodegenPipeline(
TimeCodegenPasses([&]() {
Error CodeGenError = runCodeGenPipeline(
- *TM, *TheModule, *OS, DwoOS, CGFT, !CodeGenOpts.VerifyModule,
+ *TM, *TheModule, *OS, DwoOS ? &DwoOS->os() : nullptr, CGFT,
+ !CodeGenOpts.VerifyModule,
/*DisableSimplifyLibCalls=*/false, CI.getVirtualFileSystemPtr());
if (CodeGenError)
Diags.Report(diag::err_fe_unable_to_interface_with_target);
diff --git a/flang/lib/Frontend/FrontendActions.cpp b/flang/lib/Frontend/FrontendActions.cpp
index 8ebcafa9426aa1..9191f22b7024e8 100644
--- a/flang/lib/Frontend/FrontendActions.cpp
+++ b/flang/lib/Frontend/FrontendActions.cpp
@@ -937,8 +937,8 @@ static void generateMachineCodeOrAssemblyImpl(
return;
}
}
- llvm::Error codeGenError =
- runCodeGenPipeline(tm, llvmModule, os, dwoOS, cgft);
+ llvm::Error codeGenError = runCodeGenPipeline(
+ tm, llvmModule, os, dwoOS ? &dwoOS->os() : nullptr, cgft);
if (codeGenError) {
unsigned diagID =
diags.getCustomDiagID(clang::DiagnosticsEngine::Error,
diff --git a/llvm/include/llvm/Passes/RunCodeGen.h b/llvm/include/llvm/Passes/RunCodeGen.h
index 39f06746817c8f..87db2562b7acae 100644
--- a/llvm/include/llvm/Passes/RunCodeGen.h
+++ b/llvm/include/llvm/Passes/RunCodeGen.h
@@ -10,16 +10,16 @@
#define LLVM_PASSES_RUN_CODEGEN_H
#include "llvm/IR/Module.h"
-#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/Support/raw_ostream.h"
#include "llvm/Target/TargetMachine.h"
namespace llvm {
LLVM_ABI Error runCodeGenPipeline(
TargetMachine &TM, Module &M, raw_pwrite_stream &OS,
- std::unique_ptr<ToolOutputFile> &DwoOS, CodeGenFileType CGFT,
- bool DisableVerify = true, bool DisableSimplifyLibCalls = false,
+ raw_pwrite_stream *DwoOS, CodeGenFileType CGFT, bool DisableVerify = true,
+ bool DisableSimplifyLibCalls = false,
IntrusiveRefCntPtr<vfs::FileSystem> VFS = vfs::getRealFileSystem());
} // namespace llvm
diff --git a/llvm/lib/Passes/RunCodeGen.cpp b/llvm/lib/Passes/RunCodeGen.cpp
index 7dd4a02c778ca6..9d47115caadbea 100644
--- a/llvm/lib/Passes/RunCodeGen.cpp
+++ b/llvm/lib/Passes/RunCodeGen.cpp
@@ -28,7 +28,7 @@ using namespace llvm;
static Error runCodeGenPipelineLegacy(TargetMachine &TM, Module &M,
raw_pwrite_stream &OS,
- std::unique_ptr<ToolOutputFile> &DwoOS,
+ raw_pwrite_stream *DwoOS,
CodeGenFileType CGFT, bool DisableVerify,
bool DisableSimplifyLibCalls) {
legacy::PassManager CodeGenPasses;
@@ -44,8 +44,7 @@ static Error runCodeGenPipelineLegacy(TargetMachine &TM, Module &M,
CodeGenPasses.add(
new RuntimeLibraryInfoWrapper(Options.MCOptions.ABIName, Options.VecLib));
- if (TM.addPassesToEmitFile(CodeGenPasses, OS, DwoOS ? &DwoOS->os() : nullptr,
- CGFT, DisableVerify))
+ if (TM.addPassesToEmitFile(CodeGenPasses, OS, DwoOS, CGFT, DisableVerify))
return createStringError("Failed to construct CodeGen pipeline");
CodeGenPasses.run(M);
@@ -54,7 +53,7 @@ static Error runCodeGenPipelineLegacy(TargetMachine &TM, Module &M,
static Error runCodeGenPipelineNewPM(TargetMachine &TM, Module &M,
raw_pwrite_stream &OS,
- std::unique_ptr<ToolOutputFile> &DwoOS,
+ raw_pwrite_stream *DwoOS,
CodeGenFileType CGFT, bool DisableVerify,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
ModulePassManager MPM;
@@ -79,9 +78,8 @@ static Error runCodeGenPipelineNewPM(TargetMachine &TM, Module &M,
MAM.registerPass([&] { return MachineModuleAnalysis(MMI); });
- Error BuildPipelineError =
- TM.buildCodeGenPipeline(MPM, MAM, OS, DwoOS ? &DwoOS->os() : nullptr,
- CGFT, Opt, MMI.getContext(), &PIC);
+ Error BuildPipelineError = TM.buildCodeGenPipeline(
+ MPM, MAM, OS, DwoOS, CGFT, Opt, MMI.getContext(), &PIC);
if (BuildPipelineError)
return BuildPipelineError;
@@ -90,8 +88,7 @@ static Error runCodeGenPipelineNewPM(TargetMachine &TM, Module &M,
}
Error llvm::runCodeGenPipeline(TargetMachine &TM, Module &M,
- raw_pwrite_stream &OS,
- std::unique_ptr<ToolOutputFile> &DwoOS,
+ raw_pwrite_stream &OS, raw_pwrite_stream *DwoOS,
CodeGenFileType CGFT, bool DisableVerify,
bool DisableSimplifyLibCalls,
IntrusiveRefCntPtr<vfs::FileSystem> VFS) {
|
boomanaiden154
enabled auto-merge (squash)
October 24, 2026 21:15
boomanaiden154
added a commit
to boomanaiden154/rust
that referenced
this pull request
Oct 24, 2026
After llvm/llvm-project#235339 we can just use a raw_pwrite_stream.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The std::unique_ptr reference was mostly cargo-culting from clang/flang that does not necessarily make sense for other frontends (case study right now is rustc, rust-lang/rust#163672). Change to a raw_pwrite_stream given that makes more sense internally and gives frontends more flexibility.