forked from OSchip/llvm-project
parent
d2517d6767
commit
f5599efb00
|
@ -20,9 +20,7 @@
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Assembly/Parser.h"
|
#include "llvm/Assembly/Parser.h"
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Compressor.h"
|
|
||||||
#include "llvm/Support/FileUtilities.h"
|
#include "llvm/Support/FileUtilities.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -75,16 +73,13 @@ BugDriver::BugDriver(const char *toolname, bool as_child, bool find_bugs,
|
||||||
/// return it, or return null if not possible.
|
/// return it, or return null if not possible.
|
||||||
///
|
///
|
||||||
Module *llvm::ParseInputFile(const std::string &InputFilename) {
|
Module *llvm::ParseInputFile(const std::string &InputFilename) {
|
||||||
ParseError Err;
|
std::auto_ptr<MemoryBuffer> Buffer(
|
||||||
Module *Result = ParseBytecodeFile(InputFilename,
|
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
|
||||||
Compressor::decompressToNewBuffer);
|
Module *Result = 0;
|
||||||
if (!Result) {
|
if (Buffer.get())
|
||||||
std::auto_ptr<MemoryBuffer> Buffer(
|
Result = ParseBitcodeFile(Buffer.get());
|
||||||
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
|
|
||||||
if (Buffer.get())
|
|
||||||
Result = ParseBitcodeFile(Buffer.get());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
ParseError Err;
|
||||||
if (!Result && !(Result = ParseAssemblyFile(InputFilename,&Err))) {
|
if (!Result && !(Result = ParseAssemblyFile(InputFilename,&Err))) {
|
||||||
std::cerr << "bugpoint: " << Err.getMessage() << "\n";
|
std::cerr << "bugpoint: " << Err.getMessage() << "\n";
|
||||||
Result = 0;
|
Result = 0;
|
||||||
|
|
|
@ -10,7 +10,7 @@ LEVEL = ../..
|
||||||
|
|
||||||
TOOLNAME = bugpoint
|
TOOLNAME = bugpoint
|
||||||
|
|
||||||
LINK_COMPONENTS := bcreader bcwriter asmparser instrumentation scalaropts ipo \
|
LINK_COMPONENTS := asmparser instrumentation scalaropts ipo \
|
||||||
linker bitreader bitwriter
|
linker bitreader bitwriter
|
||||||
REQUIRES_EH := 1
|
REQUIRES_EH := 1
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Analysis/Verifier.h"
|
#include "llvm/Analysis/Verifier.h"
|
||||||
#include "llvm/Bytecode/WriteBytecodePass.h"
|
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Target/TargetData.h"
|
#include "llvm/Target/TargetData.h"
|
||||||
#include "llvm/Support/FileUtilities.h"
|
#include "llvm/Support/FileUtilities.h"
|
||||||
|
@ -39,8 +38,6 @@
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static bool Bitcode = false;
|
|
||||||
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
// ChildOutput - This option captures the name of the child output file that
|
// ChildOutput - This option captures the name of the child output file that
|
||||||
|
@ -59,12 +56,8 @@ bool BugDriver::writeProgramToFile(const std::string &Filename,
|
||||||
std::ios::binary;
|
std::ios::binary;
|
||||||
std::ofstream Out(Filename.c_str(), io_mode);
|
std::ofstream Out(Filename.c_str(), io_mode);
|
||||||
if (!Out.good()) return true;
|
if (!Out.good()) return true;
|
||||||
try {
|
|
||||||
OStream L(Out);
|
WriteBitcodeToFile(M, Out);
|
||||||
WriteBytecodeToFile(M ? M : Program, L, /*compression=*/false);
|
|
||||||
} catch (...) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,11 +106,7 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
|
||||||
PM.add(createVerifierPass());
|
PM.add(createVerifierPass());
|
||||||
|
|
||||||
// Write bytecode out to disk as the last step...
|
// Write bytecode out to disk as the last step...
|
||||||
OStream L(OutFile);
|
PM.add(CreateBitcodeWriterPass(OutFile));
|
||||||
if (Bitcode)
|
|
||||||
PM.add(CreateBitcodeWriterPass(OutFile));
|
|
||||||
else
|
|
||||||
PM.add(new WriteBytecodePass(&L));
|
|
||||||
|
|
||||||
// Run all queued passes.
|
// Run all queued passes.
|
||||||
PM.run(*Program);
|
PM.run(*Program);
|
||||||
|
@ -161,8 +150,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
||||||
cerr << "Error opening bytecode file: " << inputFilename << "\n";
|
cerr << "Error opening bytecode file: " << inputFilename << "\n";
|
||||||
return(1);
|
return(1);
|
||||||
}
|
}
|
||||||
OStream L(InFile);
|
WriteBitcodeToFile(Program, InFile);
|
||||||
WriteBytecodeToFile(Program,L,false);
|
|
||||||
InFile.close();
|
InFile.close();
|
||||||
|
|
||||||
// setup the child process' arguments
|
// setup the child process' arguments
|
||||||
|
|
|
@ -15,7 +15,7 @@ TOOLNAME = llc
|
||||||
# early so we can set up LINK_COMPONENTS before including Makefile.rules
|
# early so we can set up LINK_COMPONENTS before including Makefile.rules
|
||||||
include $(LEVEL)/Makefile.config
|
include $(LEVEL)/Makefile.config
|
||||||
|
|
||||||
LINK_COMPONENTS := $(TARGETS_TO_BUILD) bcreader bitreader
|
LINK_COMPONENTS := $(TARGETS_TO_BUILD) bitreader
|
||||||
|
|
||||||
include $(LLVM_SRC_ROOT)/Makefile.rules
|
include $(LLVM_SRC_ROOT)/Makefile.rules
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
|
||||||
#include "llvm/CodeGen/FileWriters.h"
|
#include "llvm/CodeGen/FileWriters.h"
|
||||||
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
||||||
#include "llvm/Target/SubtargetFeature.h"
|
#include "llvm/Target/SubtargetFeature.h"
|
||||||
|
@ -23,10 +22,10 @@
|
||||||
#include "llvm/Target/TargetMachineRegistry.h"
|
#include "llvm/Target/TargetMachineRegistry.h"
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
|
#include "llvm/ModuleProvider.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Pass.h"
|
#include "llvm/Pass.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Compressor.h"
|
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/PluginLoader.h"
|
#include "llvm/Support/PluginLoader.h"
|
||||||
|
@ -40,9 +39,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
cl::opt<bool> Bitcode("bitcode");
|
|
||||||
|
|
||||||
|
|
||||||
// General options for llc. Other pass-specific options are specified
|
// General options for llc. Other pass-specific options are specified
|
||||||
// within the corresponding llc passes, and target-specific options
|
// within the corresponding llc passes, and target-specific options
|
||||||
// and back-end code generation options are specified with the target machine.
|
// and back-end code generation options are specified with the target machine.
|
||||||
|
@ -183,17 +179,13 @@ int main(int argc, char **argv) {
|
||||||
std::string ErrorMessage;
|
std::string ErrorMessage;
|
||||||
std::auto_ptr<Module> M;
|
std::auto_ptr<Module> M;
|
||||||
|
|
||||||
if (Bitcode) {
|
{
|
||||||
std::auto_ptr<MemoryBuffer> Buffer(
|
std::auto_ptr<MemoryBuffer> Buffer(
|
||||||
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
|
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
|
||||||
if (Buffer.get())
|
if (Buffer.get())
|
||||||
M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
|
M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
|
||||||
else
|
else
|
||||||
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
||||||
} else {
|
|
||||||
M.reset(ParseBytecodeFile(InputFilename,
|
|
||||||
Compressor::decompressToNewBuffer,
|
|
||||||
&ErrorMessage));
|
|
||||||
}
|
}
|
||||||
if (M.get() == 0) {
|
if (M.get() == 0) {
|
||||||
std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
|
std::cerr << argv[0] << ": bytecode didn't read correctly.\n";
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
LEVEL := ../..
|
LEVEL := ../..
|
||||||
TOOLNAME := lli
|
TOOLNAME := lli
|
||||||
LINK_COMPONENTS := jit interpreter native bcreader bitreader selectiondag
|
LINK_COMPONENTS := jit interpreter native bitreader selectiondag
|
||||||
|
|
||||||
# Enable JIT support
|
# Enable JIT support
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
|
@ -17,13 +17,11 @@
|
||||||
#include "llvm/ModuleProvider.h"
|
#include "llvm/ModuleProvider.h"
|
||||||
#include "llvm/Type.h"
|
#include "llvm/Type.h"
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
|
||||||
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
||||||
#include "llvm/ExecutionEngine/JIT.h"
|
#include "llvm/ExecutionEngine/JIT.h"
|
||||||
#include "llvm/ExecutionEngine/Interpreter.h"
|
#include "llvm/ExecutionEngine/Interpreter.h"
|
||||||
#include "llvm/ExecutionEngine/GenericValue.h"
|
#include "llvm/ExecutionEngine/GenericValue.h"
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/Compressor.h"
|
|
||||||
#include "llvm/Support/ManagedStatic.h"
|
#include "llvm/Support/ManagedStatic.h"
|
||||||
#include "llvm/Support/MemoryBuffer.h"
|
#include "llvm/Support/MemoryBuffer.h"
|
||||||
#include "llvm/Support/PluginLoader.h"
|
#include "llvm/Support/PluginLoader.h"
|
||||||
|
@ -34,8 +32,6 @@
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
cl::opt<bool> Bitcode("bitcode");
|
|
||||||
|
|
||||||
cl::opt<std::string>
|
cl::opt<std::string>
|
||||||
InputFile(cl::desc("<input bytecode>"), cl::Positional, cl::init("-"));
|
InputFile(cl::desc("<input bytecode>"), cl::Positional, cl::init("-"));
|
||||||
|
|
||||||
|
@ -81,19 +77,13 @@ int main(int argc, char **argv, char * const *envp) {
|
||||||
// Load the bytecode...
|
// Load the bytecode...
|
||||||
std::string ErrorMsg;
|
std::string ErrorMsg;
|
||||||
ModuleProvider *MP = 0;
|
ModuleProvider *MP = 0;
|
||||||
if (Bitcode) {
|
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFile[0],
|
||||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFile[0],
|
InputFile.size());
|
||||||
InputFile.size());
|
if (Buffer == 0)
|
||||||
if (Buffer == 0)
|
ErrorMsg = "Error reading file '" + InputFile + "'";
|
||||||
ErrorMsg = "Error reading file '" + InputFile + "'";
|
else {
|
||||||
else {
|
MP = getBitcodeModuleProvider(Buffer, &ErrorMsg);
|
||||||
MP = getBitcodeModuleProvider(Buffer, &ErrorMsg);
|
if (!MP) delete Buffer;
|
||||||
if (!MP) delete Buffer;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
MP = getBytecodeModuleProvider(InputFile,
|
|
||||||
Compressor::decompressToNewBuffer,
|
|
||||||
&ErrorMsg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!MP) {
|
if (!MP) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ else
|
||||||
BUILD_ARCHIVE = 1
|
BUILD_ARCHIVE = 1
|
||||||
endif
|
endif
|
||||||
|
|
||||||
LINK_COMPONENTS := $(TARGETS_TO_BUILD) ipo scalaropts linker bcreader bcwriter bitreader bitwriter
|
LINK_COMPONENTS := $(TARGETS_TO_BUILD) ipo scalaropts linker bitreader bitwriter
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
||||||
|
|
|
@ -17,9 +17,8 @@
|
||||||
#include "llvm/Linker.h"
|
#include "llvm/Linker.h"
|
||||||
#include "llvm/Constants.h"
|
#include "llvm/Constants.h"
|
||||||
#include "llvm/DerivedTypes.h"
|
#include "llvm/DerivedTypes.h"
|
||||||
|
#include "llvm/ModuleProvider.h"
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
|
||||||
#include "llvm/Bytecode/Writer.h"
|
|
||||||
#include "llvm/Support/CommandLine.h"
|
#include "llvm/Support/CommandLine.h"
|
||||||
#include "llvm/Support/FileUtilities.h"
|
#include "llvm/Support/FileUtilities.h"
|
||||||
#include "llvm/Support/SystemUtils.h"
|
#include "llvm/Support/SystemUtils.h"
|
||||||
|
@ -40,7 +39,6 @@
|
||||||
#include "llvm/Transforms/Scalar.h"
|
#include "llvm/Transforms/Scalar.h"
|
||||||
#include "llvm/Analysis/LoadValueNumbering.h"
|
#include "llvm/Analysis/LoadValueNumbering.h"
|
||||||
#include "llvm/Support/MathExtras.h"
|
#include "llvm/Support/MathExtras.h"
|
||||||
#include "llvm/Support/Streams.h"
|
|
||||||
#include "llvm/LinkTimeOptimizer.h"
|
#include "llvm/LinkTimeOptimizer.h"
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
@ -53,8 +51,6 @@ llvm::LinkTimeOptimizer *createLLVMOptimizer()
|
||||||
return l;
|
return l;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool Bitcode = false;
|
|
||||||
|
|
||||||
/// If symbol is not used then make it internal and let optimizer takes
|
/// If symbol is not used then make it internal and let optimizer takes
|
||||||
/// care of it.
|
/// care of it.
|
||||||
void LLVMSymbol::mayBeNotUsed() {
|
void LLVMSymbol::mayBeNotUsed() {
|
||||||
|
@ -121,16 +117,13 @@ LTO::getModule(const std::string &InputFilename)
|
||||||
NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str());
|
NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str());
|
||||||
if (pos != allModules.end())
|
if (pos != allModules.end())
|
||||||
m = allModules[InputFilename.c_str()];
|
m = allModules[InputFilename.c_str()];
|
||||||
else if (Bitcode) {
|
else {
|
||||||
if (MemoryBuffer *Buffer
|
if (MemoryBuffer *Buffer
|
||||||
= MemoryBuffer::getFile(&InputFilename[0], InputFilename.size())) {
|
= MemoryBuffer::getFile(&InputFilename[0], InputFilename.size())) {
|
||||||
m = ParseBitcodeFile(Buffer);
|
m = ParseBitcodeFile(Buffer);
|
||||||
delete Buffer;
|
delete Buffer;
|
||||||
}
|
}
|
||||||
allModules[InputFilename.c_str()] = m;
|
allModules[InputFilename.c_str()] = m;
|
||||||
} else {
|
|
||||||
m = ParseBytecodeFile(InputFilename);
|
|
||||||
allModules[InputFilename.c_str()] = m;
|
|
||||||
}
|
}
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
@ -385,12 +378,7 @@ LTO::optimizeModules(const std::string &OutputFilename,
|
||||||
std::string tempFileName(FinalOutputPath.c_str());
|
std::string tempFileName(FinalOutputPath.c_str());
|
||||||
tempFileName += "0.bc";
|
tempFileName += "0.bc";
|
||||||
std::ofstream Out(tempFileName.c_str(), io_mode);
|
std::ofstream Out(tempFileName.c_str(), io_mode);
|
||||||
if (Bitcode) {
|
WriteBitcodeToFile(bigOne, Out);
|
||||||
WriteBitcodeToFile(bigOne, Out);
|
|
||||||
} else {
|
|
||||||
OStream L(Out);
|
|
||||||
WriteBytecodeToFile(bigOne, L);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Strip leading underscore because it was added to match names
|
// Strip leading underscore because it was added to match names
|
||||||
|
@ -443,12 +431,7 @@ LTO::optimizeModules(const std::string &OutputFilename,
|
||||||
std::string tempFileName(FinalOutputPath.c_str());
|
std::string tempFileName(FinalOutputPath.c_str());
|
||||||
tempFileName += "1.bc";
|
tempFileName += "1.bc";
|
||||||
std::ofstream Out(tempFileName.c_str(), io_mode);
|
std::ofstream Out(tempFileName.c_str(), io_mode);
|
||||||
if (Bitcode) {
|
WriteBitcodeToFile(bigOne, Out);
|
||||||
WriteBitcodeToFile(bigOne, Out);
|
|
||||||
} else {
|
|
||||||
OStream L(Out);
|
|
||||||
WriteBytecodeToFile(bigOne, L);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
targetTriple = bigOne->getTargetTriple();
|
targetTriple = bigOne->getTargetTriple();
|
||||||
|
|
|
@ -10,6 +10,6 @@ LEVEL = ../..
|
||||||
TOOLNAME = opt
|
TOOLNAME = opt
|
||||||
REQUIRES_EH := 1
|
REQUIRES_EH := 1
|
||||||
|
|
||||||
LINK_COMPONENTS := bcreader bcwriter bitreader bitwriter instrumentation scalaropts ipo
|
LINK_COMPONENTS := bitreader bitwriter instrumentation scalaropts ipo
|
||||||
|
|
||||||
include $(LEVEL)/Makefile.common
|
include $(LEVEL)/Makefile.common
|
||||||
|
|
|
@ -14,8 +14,6 @@
|
||||||
|
|
||||||
#include "llvm/Module.h"
|
#include "llvm/Module.h"
|
||||||
#include "llvm/PassManager.h"
|
#include "llvm/PassManager.h"
|
||||||
#include "llvm/Bytecode/Reader.h"
|
|
||||||
#include "llvm/Bytecode/WriteBytecodePass.h"
|
|
||||||
#include "llvm/Bitcode/ReaderWriter.h"
|
#include "llvm/Bitcode/ReaderWriter.h"
|
||||||
#include "llvm/Assembly/PrintModulePass.h"
|
#include "llvm/Assembly/PrintModulePass.h"
|
||||||
#include "llvm/Analysis/Verifier.h"
|
#include "llvm/Analysis/Verifier.h"
|
||||||
|
@ -37,17 +35,12 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
using namespace llvm;
|
using namespace llvm;
|
||||||
|
|
||||||
static cl::opt<bool> Bitcode("bitcode");
|
|
||||||
|
|
||||||
// The OptimizationList is automatically populated with registered Passes by the
|
// The OptimizationList is automatically populated with registered Passes by the
|
||||||
// PassNameParser.
|
// PassNameParser.
|
||||||
//
|
//
|
||||||
static cl::list<const PassInfo*, bool, PassNameParser>
|
static cl::list<const PassInfo*, bool, PassNameParser>
|
||||||
PassList(cl::desc("Optimizations available:"));
|
PassList(cl::desc("Optimizations available:"));
|
||||||
|
|
||||||
static cl::opt<bool> NoCompress("disable-compression", cl::init(true),
|
|
||||||
cl::desc("Don't compress the generated bytecode"));
|
|
||||||
|
|
||||||
// Other command line options...
|
// Other command line options...
|
||||||
//
|
//
|
||||||
static cl::opt<std::string>
|
static cl::opt<std::string>
|
||||||
|
@ -267,21 +260,15 @@ int main(int argc, char **argv) {
|
||||||
|
|
||||||
// Load the input module...
|
// Load the input module...
|
||||||
std::auto_ptr<Module> M;
|
std::auto_ptr<Module> M;
|
||||||
if (Bitcode) {
|
MemoryBuffer *Buffer
|
||||||
MemoryBuffer *Buffer
|
= MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
|
||||||
= MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
|
|
||||||
|
if (Buffer == 0)
|
||||||
if (Buffer == 0)
|
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
||||||
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
else
|
||||||
else
|
M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
|
||||||
M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
|
|
||||||
|
delete Buffer;
|
||||||
delete Buffer;
|
|
||||||
} else {
|
|
||||||
M.reset(ParseBytecodeFile(InputFilename,
|
|
||||||
Compressor::decompressToNewBuffer,
|
|
||||||
&ErrorMessage));
|
|
||||||
}
|
|
||||||
if (M.get() == 0) {
|
if (M.get() == 0) {
|
||||||
cerr << argv[0] << ": ";
|
cerr << argv[0] << ": ";
|
||||||
if (ErrorMessage.size())
|
if (ErrorMessage.size())
|
||||||
|
@ -372,13 +359,8 @@ int main(int argc, char **argv) {
|
||||||
Passes.add(createVerifierPass());
|
Passes.add(createVerifierPass());
|
||||||
|
|
||||||
// Write bytecode out to disk or cout as the last step...
|
// Write bytecode out to disk or cout as the last step...
|
||||||
OStream L(*Out);
|
if (!NoOutput && !AnalyzeOnly)
|
||||||
if (!NoOutput && !AnalyzeOnly) {
|
Passes.add(CreateBitcodeWriterPass(*Out));
|
||||||
if (Bitcode)
|
|
||||||
Passes.add(CreateBitcodeWriterPass(*Out));
|
|
||||||
else
|
|
||||||
Passes.add(new WriteBytecodePass(&L, false, !NoCompress));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Now that we have all of the passes ready, run them.
|
// Now that we have all of the passes ready, run them.
|
||||||
Passes.run(*M.get());
|
Passes.run(*M.get());
|
||||||
|
|
Loading…
Reference in New Issue