diff options
| -rw-r--r-- | llvm/tools/opt/opt.cpp | 13 | 
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/tools/opt/opt.cpp b/llvm/tools/opt/opt.cpp index e701000f697..1cfc56e1f56 100644 --- a/llvm/tools/opt/opt.cpp +++ b/llvm/tools/opt/opt.cpp @@ -901,8 +901,10 @@ int main(int argc, char **argv) {    std::unique_ptr<raw_svector_ostream> BOS;    raw_ostream *OS = nullptr; +  const bool ShouldEmitOutput = !NoOutput && !AnalyzeOnly; +    // Write bitcode or assembly to the output as the last step... -  if (!NoOutput && !AnalyzeOnly) { +  if (ShouldEmitOutput || RunTwice) {      assert(Out);      OS = &Out->os();      if (RunTwice) { @@ -950,13 +952,16 @@ int main(int argc, char **argv) {               "Writing the result of the second run to the specified output.\n"               "To generate the one-run comparison binary, just run without\n"               "the compile-twice option\n"; -      Out->os() << BOS->str(); -      Out->keep(); +      if (ShouldEmitOutput) { +        Out->os() << BOS->str(); +        Out->keep(); +      }        if (RemarksFile)          RemarksFile->keep();        return 1;      } -    Out->os() << BOS->str(); +    if (ShouldEmitOutput) +      Out->os() << BOS->str();    }    if (DebugifyEach && !DebugifyExport.empty())  | 

