Index: tools/pnacl-llc/pnacl-llc.cpp |
diff --git a/tools/pnacl-llc/pnacl-llc.cpp b/tools/pnacl-llc/pnacl-llc.cpp |
index 27c7a07ac690dd820d42c9486d1380f0f346d7c9..c02f1ef4179cfbafe8382bef52965ad5a9644e2b 100644 |
--- a/tools/pnacl-llc/pnacl-llc.cpp |
+++ b/tools/pnacl-llc/pnacl-llc.cpp |
@@ -16,7 +16,6 @@ |
#include "llvm/Bitcode/NaCl/NaClReaderWriter.h" |
#include "llvm/Bitcode/ReaderWriter.h" |
#include "llvm/CodeGen/CommandFlags.h" |
-#include "llvm/CodeGen/LinkAllAsmWriterComponents.h" |
#include "llvm/CodeGen/LinkAllCodegenComponents.h" |
#include "llvm/IR/DataLayout.h" |
#include "llvm/IR/LLVMContext.h" |
@@ -34,16 +33,16 @@ |
#include "llvm/Support/FormattedStream.h" |
#include "llvm/Support/Host.h" |
#include "llvm/Support/ManagedStatic.h" |
-#include "llvm/Support/Mutex.h" |
#include "llvm/Support/PrettyStackTrace.h" |
#include "llvm/Support/Signals.h" |
#include "llvm/Support/SourceMgr.h" |
-#include "llvm/Support/StreamableMemoryObject.h" |
+#include "llvm/Support/StreamingMemoryObject.h" |
#include "llvm/Support/TargetRegistry.h" |
#include "llvm/Support/TargetSelect.h" |
#include "llvm/Support/ToolOutputFile.h" |
#include "llvm/Target/TargetLibraryInfo.h" |
#include "llvm/Target/TargetMachine.h" |
+#include "llvm/Target/TargetSubtargetInfo.h" |
#include "llvm/Transforms/NaCl.h" |
#include "ThreadedFunctionQueue.h" |
@@ -226,14 +225,13 @@ static tool_output_file *GetOutputStream(const char *TargetName, |
} |
// Open the file. |
- std::string error; |
+ std::error_code EC; |
sys::fs::OpenFlags OpenFlags = sys::fs::F_None; |
if (!Binary) |
OpenFlags |= sys::fs::F_Text; |
- tool_output_file *FDOut = |
- new tool_output_file(Filename.c_str(), error, OpenFlags); |
- if (!error.empty()) { |
- errs() << error << '\n'; |
+ tool_output_file *FDOut = new tool_output_file(Filename, EC, OpenFlags); |
+ if (EC) { |
+ errs() << EC.message() << '\n'; |
delete FDOut; |
return nullptr; |
} |
@@ -321,7 +319,7 @@ static void CheckABIVerifyErrors(PNaClABIErrorReporter &Reporter, |
static Module* getModule(StringRef ProgramName, LLVMContext &Context, |
JF
2015/02/24 05:35:37
This could now be a unique_ptr. One of the two use
jvoung (off chromium)
2015/02/24 18:38:48
Converted the function to return a unique_ptr.
Th
JF
2015/02/24 19:32:55
sgtm
|
StreamingMemoryObject *StreamingObject) { |
- Module *M = nullptr; |
+ std::unique_ptr<Module> M; |
SMDiagnostic Err; |
std::string VerboseBuffer; |
raw_string_ostream VerboseStrm(VerboseBuffer); |
@@ -329,15 +327,15 @@ static Module* getModule(StringRef ProgramName, LLVMContext &Context, |
std::string StrError; |
switch (InputFileFormat) { |
case PNaClFormat: |
- M = getNaClStreamedBitcodeModule( |
+ M.reset(getNaClStreamedBitcodeModule( |
InputFilename, |
new ThreadedStreamingCache(StreamingObject), Context, &VerboseStrm, |
- &StrError); |
+ &StrError)); |
break; |
case LLVMFormat: |
- M = getStreamedBitcodeModule( |
+ M.reset(getStreamedBitcodeModule( |
InputFilename, |
- new ThreadedStreamingCache(StreamingObject), Context, &StrError); |
+ new ThreadedStreamingCache(StreamingObject), Context, &StrError)); |
break; |
case AutodetectFileFormat: |
report_fatal_error("Command can't autodetect file format!"); |
@@ -364,7 +362,7 @@ static Module* getModule(StringRef ProgramName, LLVMContext &Context, |
return nullptr; |
#endif |
} |
- return M; |
+ return M.release(); |
} |
static cl::opt<bool> |
@@ -436,9 +434,9 @@ static int runCompilePasses(Module *mod, |
PM.reset(new PassManager()); |
// Add the target data from the target machine, if it exists, or the module. |
- if (const DataLayout *DL = Target.getDataLayout()) |
+ if (const DataLayout *DL = Target.getSubtargetImpl()->getDataLayout()) |
mod->setDataLayout(DL); |
- PM->add(new DataLayoutPass(mod)); |
+ PM->add(new DataLayoutPass()); |
// For conformance with llc, we let the user disable LLVM IR verification with |
// -disable-verify. Unlike llc, when LLVM IR verification is enabled we only |
@@ -592,7 +590,7 @@ static int compileSplitModule(const TargetOptions &Options, |
if (!Out) return 1; |
formatted_raw_ostream FOS(Out->os()); |
#else |
- raw_fd_ostream ROS(getObjectFileFD(ModuleIndex), true, sys::fs::F_None); |
+ raw_fd_ostream ROS(getObjectFileFD(ModuleIndex), /* ShouldClose */ true); |
ROS.SetBufferSize(1 << 20); |
formatted_raw_ostream FOS(ROS); |
#endif |