[llvm] r341586 - Reland rL341509: "[llvm-dwp] Use buffer_stream if output file is not seekable (e.g. "-")"

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 6 13:26:54 PDT 2018


Author: maskray
Date: Thu Sep  6 13:26:54 2018
New Revision: 341586

URL: http://llvm.org/viewvc/llvm-project?rev=341586&view=rev
Log:
Reland rL341509: "[llvm-dwp] Use buffer_stream if output file is not seekable (e.g. "-")"

It caused ambiguity between llvm::cl::Optional and llvm::Optional, which
has been fixed by dropping `using namespace cl;` in favor of explicit
cl:: qualified names.

Modified:
    llvm/trunk/test/tools/llvm-dwp/X86/merge.test
    llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp

Modified: llvm/trunk/test/tools/llvm-dwp/X86/merge.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/tools/llvm-dwp/X86/merge.test?rev=341586&r1=341585&r2=341586&view=diff
==============================================================================
--- llvm/trunk/test/tools/llvm-dwp/X86/merge.test (original)
+++ llvm/trunk/test/tools/llvm-dwp/X86/merge.test Thu Sep  6 13:26:54 2018
@@ -1,7 +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
-
-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.
+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
 
 DWP from a DWO (c.dwo) and a DWP (ab.dwp, created from a.dwo and b.dwo)
 Make sure the entries for A and B are updated correctly when read/processed from ab.dwp

Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=341586&r1=341585&r2=341586&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Thu Sep  6 13:26:54 2018
@@ -697,13 +697,21 @@ int main(int argc, char **argv) {
   // Create the output file.
   std::error_code EC;
   raw_fd_ostream OutFile(OutputFilename, EC, sys::fs::F_None);
+  Optional<buffer_ostream> BOS;
+  raw_pwrite_stream *OS;
   if (EC)
     return error(Twine(OutputFilename) + ": " + EC.message(), Context);
+  if (OutFile.supportsSeeking()) {
+    OS = &OutFile;
+  } else {
+    BOS.emplace(OutFile);
+    OS = BOS.getPointer();
+  }
 
   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)




More information about the llvm-commits mailing list