Skip to content

Commit

Permalink
Update for LLVM api changes.
Browse files Browse the repository at this point in the history
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@234536 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
espindola committed Apr 9, 2015
1 parent 4a0690e commit e983438
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
13 changes: 4 additions & 9 deletions lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "llvm/IR/Verifier.h"
#include "llvm/MC/SubtargetFeature.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormattedStream.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/TargetRegistry.h"
#include "llvm/Support/Timer.h"
Expand Down Expand Up @@ -110,7 +109,7 @@ class EmitAssemblyHelper {
/// AddEmitPasses - Add passes necessary to emit assembly or LLVM IR.
///
/// \return True on success.
bool AddEmitPasses(BackendAction Action, formatted_raw_ostream &OS);
bool AddEmitPasses(BackendAction Action, raw_ostream &OS);

public:
EmitAssemblyHelper(DiagnosticsEngine &_Diags,
Expand Down Expand Up @@ -548,8 +547,7 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
return TM;
}

bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,
formatted_raw_ostream &OS) {
bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action, raw_ostream &OS) {

// Create the code generator passes.
legacy::PassManager *PM = getCodeGenPasses();
Expand Down Expand Up @@ -588,7 +586,6 @@ bool EmitAssemblyHelper::AddEmitPasses(BackendAction Action,

void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) {
TimeRegion Region(llvm::TimePassesIsEnabled ? &CodeGenerationTime : nullptr);
llvm::formatted_raw_ostream FormattedOS;

bool UsesCodeGen = (Action != Backend_EmitNothing &&
Action != Backend_EmitBC &&
Expand All @@ -608,13 +605,11 @@ void EmitAssemblyHelper::EmitAssembly(BackendAction Action, raw_ostream *OS) {
break;

case Backend_EmitLL:
FormattedOS.setStream(*OS, formatted_raw_ostream::PRESERVE_STREAM);
getPerModulePasses()->add(createPrintModulePass(FormattedOS));
getPerModulePasses()->add(createPrintModulePass(*OS));
break;

default:
FormattedOS.setStream(*OS, formatted_raw_ostream::PRESERVE_STREAM);
if (!AddEmitPasses(Action, FormattedOS))
if (!AddEmitPasses(Action, *OS))
return;
}

Expand Down
19 changes: 9 additions & 10 deletions tools/driver/cc1as_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "clang/Frontend/FrontendDiagnostic.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
#include "clang/Frontend/Utils.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/ADT/Triple.h"
#include "llvm/IR/DataLayout.h"
Expand Down Expand Up @@ -254,9 +255,8 @@ bool AssemblerInvocation::CreateFromArgs(AssemblerInvocation &Opts,
return Success;
}

static formatted_raw_ostream *GetOutputStream(AssemblerInvocation &Opts,
DiagnosticsEngine &Diags,
bool Binary) {
static raw_ostream *GetOutputStream(AssemblerInvocation &Opts,
DiagnosticsEngine &Diags, bool Binary) {
if (Opts.OutputPath.empty())
Opts.OutputPath = "-";

Expand All @@ -275,7 +275,7 @@ static formatted_raw_ostream *GetOutputStream(AssemblerInvocation &Opts,
return nullptr;
}

return new formatted_raw_ostream(*Out, formatted_raw_ostream::DELETE_STREAM);
return Out;
}

static bool ExecuteAssembler(AssemblerInvocation &Opts,
Expand Down Expand Up @@ -315,8 +315,7 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
MAI->setCompressDebugSections(true);

bool IsBinary = Opts.OutputType == AssemblerInvocation::FT_Obj;
std::unique_ptr<formatted_raw_ostream> Out(
GetOutputStream(Opts, Diags, IsBinary));
std::unique_ptr<raw_ostream> Out(GetOutputStream(Opts, Diags, IsBinary));
if (!Out)
return true;

Expand Down Expand Up @@ -366,10 +365,10 @@ static bool ExecuteAssembler(AssemblerInvocation &Opts,
CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU);
}
Str.reset(TheTarget->createAsmStreamer(Ctx, *Out, /*asmverbose*/true,
/*useDwarfDirectory*/ true,
IP, CE, MAB,
Opts.ShowInst));
auto FOut = llvm::make_unique<formatted_raw_ostream>(*Out);
Str.reset(TheTarget->createAsmStreamer(
Ctx, std::move(FOut), /*asmverbose*/ true,
/*useDwarfDirectory*/ true, IP, CE, MAB, Opts.ShowInst));
} else if (Opts.OutputType == AssemblerInvocation::FT_Null) {
Str.reset(createNullStreamer(Ctx));
} else {
Expand Down

0 comments on commit e983438

Please sign in to comment.