[PATCH] D51707: [llvm-dwp] Use buffer_stream if output file is not seekable (e.g. "-")
Fangrui Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 5 15:53:26 PDT 2018
MaskRay created this revision.
MaskRay added reviewers: dblaikie, pcc.
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D51707
Files:
test/tools/llvm-dwp/X86/merge.test
tools/llvm-dwp/llvm-dwp.cpp
Index: tools/llvm-dwp/llvm-dwp.cpp
===================================================================
--- tools/llvm-dwp/llvm-dwp.cpp
+++ tools/llvm-dwp/llvm-dwp.cpp
@@ -697,13 +697,21 @@
// Create the output file.
std::error_code EC;
raw_fd_ostream OutFile(OutputFilename, EC, sys::fs::F_None);
+ std::unique_ptr<buffer_ostream> BOS;
+ raw_pwrite_stream *OS;
if (EC)
return error(Twine(OutputFilename) + ": " + EC.message(), Context);
+ if (OutFile.supportsSeeking()) {
+ OS = &OutFile;
+ } else {
+ BOS = make_unique<buffer_ostream>(OutFile);
+ OS = BOS.get();
+ }
MCTargetOptions MCOptions = InitMCTargetOptionsFromFlags();
std::unique_ptr<MCStreamer> MS(TheTarget->createMCObjectStreamer(
TheTriple, MC, std::unique_ptr<MCAsmBackend>(MAB),
- MAB->createObjectWriter(OutFile), std::unique_ptr<MCCodeEmitter>(MCE),
+ MAB->createObjectWriter(*OS), std::unique_ptr<MCCodeEmitter>(MCE),
*MSTI, MCOptions.MCRelaxAll, MCOptions.MCIncrementalLinkerCompatible,
/*DWARFMustBeAtTheEnd*/ false));
if (!MS)
Index: test/tools/llvm-dwp/X86/merge.test
===================================================================
--- test/tools/llvm-dwp/X86/merge.test
+++ test/tools/llvm-dwp/X86/merge.test
@@ -1,5 +1,5 @@
-RUN: llvm-dwp %p/../Inputs/merge/notypes/c.dwo %p/../Inputs/merge/notypes/ab.dwp -o %t
-RUN: llvm-dwarfdump -v %t | FileCheck --check-prefix=CHECK --check-prefix=NOTYP %s
+RUN: llvm-dwp %p/../Inputs/merge/notypes/c.dwo %p/../Inputs/merge/notypes/ab.dwp -o - | \
+RUN: llvm-dwarfdump -v - | FileCheck --check-prefix=CHECK --check-prefix=NOTYP %s
FIXME: For some reason, piping straight from llvm-dwp to llvm-dwarfdump -v doesn't behave well - looks like dwarfdump is reading/closes before dwp has finished.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51707.164120.patch
Type: text/x-patch
Size: 1790 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180905/971549fd/attachment.bin>
More information about the llvm-commits
mailing list