| Index: tools/llvm-dis/llvm-dis.cpp
|
| diff --git a/tools/llvm-dis/llvm-dis.cpp b/tools/llvm-dis/llvm-dis.cpp
|
| index fb73717376165f31975bb5f6f493c9ac487eb0c4..8aa8b9242ea4f561b941dcdf724a5f462373a022 100644
|
| --- a/tools/llvm-dis/llvm-dis.cpp
|
| +++ b/tools/llvm-dis/llvm-dis.cpp
|
| @@ -18,11 +18,13 @@
|
|
|
| #include "llvm/IR/LLVMContext.h"
|
| #include "llvm/Bitcode/ReaderWriter.h"
|
| +#include "llvm/Bitcode/NaCl/NaClReaderWriter.h" // @LOCALMOD
|
| #include "llvm/IR/AssemblyAnnotationWriter.h"
|
| #include "llvm/IR/DebugInfo.h"
|
| #include "llvm/IR/IntrinsicInst.h"
|
| #include "llvm/IR/Module.h"
|
| #include "llvm/IR/Type.h"
|
| +#include "llvm/IRReader/IRReader.h" // @LOCALMOD
|
| #include "llvm/Support/CommandLine.h"
|
| #include "llvm/Support/DataStream.h"
|
| #include "llvm/Support/FileSystem.h"
|
| @@ -31,6 +33,7 @@
|
| #include "llvm/Support/MemoryBuffer.h"
|
| #include "llvm/Support/PrettyStackTrace.h"
|
| #include "llvm/Support/Signals.h"
|
| +#include "llvm/Support/StreamingMemoryObject.h" // @LOCALMOD
|
| #include "llvm/Support/ToolOutputFile.h"
|
| #include <system_error>
|
| using namespace llvm;
|
| @@ -52,6 +55,18 @@ static cl::opt<bool>
|
| ShowAnnotations("show-annotations",
|
| cl::desc("Add informational comments to the .ll file"));
|
|
|
| +// @LOCALMOD-BEGIN
|
| +static cl::opt<NaClFileFormat>
|
| +InputFileFormat(
|
| + "bitcode-format",
|
| + cl::desc("Define format of input bitcode file:"),
|
| + cl::values(
|
| + clEnumValN(LLVMFormat, "llvm", "LLVM bitcode file (default)"),
|
| + clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
|
| + clEnumValEnd),
|
| + cl::init(LLVMFormat));
|
| +// @LOCALMOD-END
|
| +
|
| namespace {
|
|
|
| static void printDebugLoc(const DebugLoc &DL, formatted_raw_ostream &OS) {
|
| @@ -127,15 +142,35 @@ int main(int argc, char **argv) {
|
| std::unique_ptr<Module> M;
|
|
|
| // Use the bitcode streaming interface
|
| - DataStreamer *streamer = getDataFileStreamer(InputFilename, &ErrorMessage);
|
| + DataStreamer *streamer(getDataFileStreamer(InputFilename, &ErrorMessage));
|
| if (streamer) {
|
| + std::unique_ptr<StreamingMemoryObject> Buffer(
|
| + new StreamingMemoryObjectImpl(streamer)); // @LOCALMOD
|
| std::string DisplayFilename;
|
| if (InputFilename == "-")
|
| DisplayFilename = "<stdin>";
|
| else
|
| DisplayFilename = InputFilename;
|
| - M.reset(getStreamedBitcodeModule(DisplayFilename, streamer, Context,
|
| - &ErrorMessage));
|
| +
|
| + // @LOCALMOD-BEGIN
|
| + switch (InputFileFormat) {
|
| + case LLVMFormat:
|
| + // The Module's BitcodeReader's BitstreamReader takes ownership
|
| + // of the StreamingMemoryObject.
|
| + M.reset(getStreamedBitcodeModule(
|
| + DisplayFilename, Buffer.release(), Context, &ErrorMessage));
|
| + break;
|
| + case PNaClFormat: {
|
| + M.reset(getNaClStreamedBitcodeModule(
|
| + DisplayFilename, Buffer.release(), Context, nullptr,
|
| + &ErrorMessage));
|
| + break;
|
| + case AutodetectFileFormat:
|
| + report_fatal_error("Command can't autodetect file format!");
|
| + }
|
| + }
|
| + // @LOCALMOD-END
|
| +
|
| if(M.get()) {
|
| if (std::error_code EC = M->materializeAllPermanently()) {
|
| ErrorMessage = EC.message();
|
|
|