forked from OSchip/llvm-project
switch tools to bitcode instead of bytecode
llvm-svn: 36868
This commit is contained in:
parent
41528e6e42
commit
6d80e21a1d
|
@ -13,9 +13,8 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Bytecode/Archive.h"
|
||||
#include "llvm/Bitcode/Archive.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Compressor.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
#include <iostream>
|
||||
|
@ -364,14 +363,8 @@ bool doPrint(std::string* ErrMsg) {
|
|||
if (Verbose)
|
||||
std::cout << "Printing " << I->getPath().toString() << "\n";
|
||||
|
||||
if (I->isCompressedBytecode())
|
||||
Compressor::decompressToStream(data+4,I->getSize()-4,std::cout);
|
||||
else if (I->isCompressed()) {
|
||||
Compressor::decompressToStream(data,I->getSize(),std::cout);
|
||||
} else {
|
||||
unsigned len = I->getSize();
|
||||
std::cout.write(data, len);
|
||||
}
|
||||
unsigned len = I->getSize();
|
||||
std::cout.write(data, len);
|
||||
} else {
|
||||
countDown--;
|
||||
}
|
||||
|
@ -469,12 +462,8 @@ doExtract(std::string* ErrMsg) {
|
|||
const char* data = reinterpret_cast<const char*>(I->getData());
|
||||
unsigned len = I->getSize();
|
||||
|
||||
// Write the data, making sure to uncompress things first
|
||||
if (I->isCompressed()) {
|
||||
Compressor::decompressToStream(data,len,file);
|
||||
} else {
|
||||
file.write(data,len);
|
||||
}
|
||||
// Write the data.
|
||||
file.write(data,len);
|
||||
file.close();
|
||||
|
||||
// If we're supposed to retain the original modification times, etc. do so
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
LEVEL = ../..
|
||||
TOOLNAME = llvm-as
|
||||
LINK_COMPONENTS := asmparser bcwriter bitwriter
|
||||
LINK_COMPONENTS := asmparser bitwriter
|
||||
REQUIRES_EH := 1
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
|
|
@ -9,15 +9,14 @@
|
|||
//
|
||||
// This utility may be invoked in the following manner:
|
||||
// llvm-as --help - Output information about command line switches
|
||||
// llvm-as [options] - Read LLVM asm from stdin, write bytecode to stdout
|
||||
// llvm-as [options] x.ll - Read LLVM asm from the x.ll file, write bytecode
|
||||
// llvm-as [options] - Read LLVM asm from stdin, write bitcode to stdout
|
||||
// llvm-as [options] x.ll - Read LLVM asm from the x.ll file, write bitcode
|
||||
// to the x.bc file.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Assembly/Parser.h"
|
||||
#include "llvm/Bytecode/Writer.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
|
@ -43,18 +42,10 @@ Force("f", cl::desc("Overwrite output files"));
|
|||
static cl::opt<bool>
|
||||
DumpAsm("d", cl::desc("Print assembly as parsed"), cl::Hidden);
|
||||
|
||||
static cl::opt<bool>
|
||||
NoCompress("disable-compression", cl::init(true),
|
||||
cl::desc("Don't compress the generated bytecode"));
|
||||
|
||||
static cl::opt<bool>
|
||||
DisableVerify("disable-verify", cl::Hidden,
|
||||
cl::desc("Do not run verifier on input LLVM (dangerous!)"));
|
||||
|
||||
static cl::opt<bool>
|
||||
EnableBitcode("bitcode", cl::desc("Emit bitcode"));
|
||||
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
|
||||
cl::ParseCommandLineOptions(argc, argv, " llvm .ll -> .bc assembler\n");
|
||||
|
@ -134,14 +125,8 @@ int main(int argc, char **argv) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (Force || !CheckBytecodeOutputToConsole(Out,true)) {
|
||||
if (EnableBitcode) {
|
||||
WriteBitcodeToFile(M.get(), *Out);
|
||||
} else {
|
||||
OStream L(*Out);
|
||||
WriteBytecodeToFile(M.get(), L, !NoCompress);
|
||||
}
|
||||
}
|
||||
if (Force || !CheckBytecodeOutputToConsole(Out,true))
|
||||
WriteBitcodeToFile(M.get(), *Out);
|
||||
} catch (const std::string& msg) {
|
||||
cerr << argv[0] << ": " << msg << "\n";
|
||||
exitCode = 1;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
LEVEL = ../..
|
||||
|
||||
TOOLNAME = llvm-bcanalyzer
|
||||
LINK_COMPONENTS := bcreader
|
||||
LINK_COMPONENTS := bitreader
|
||||
REQUIRES_EH := 1
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
|
|
@ -13,8 +13,6 @@
|
|||
//
|
||||
// Options:
|
||||
// --help - Output information about command line switches
|
||||
// --nodetails - Don't print out detailed informaton about individual
|
||||
// blocks and functions
|
||||
// --dump - Dump low-level bytecode structure in readable format
|
||||
//
|
||||
// This tool provides analytical information about a bytecode file. It is
|
||||
|
@ -22,8 +20,7 @@
|
|||
// produces on std::out a summary of the bytecode file that shows various
|
||||
// statistics about the contents of the file. By default this information is
|
||||
// detailed and contains information about individual bytecode blocks and the
|
||||
// functions in the module. To avoid this more detailed output, use the
|
||||
// -nodetails option to limit the output to just module level information.
|
||||
// functions in the module.
|
||||
// The tool is also able to print a bytecode file in a straight forward text
|
||||
// format that shows the containment and relationships of the information in
|
||||
// the bytecode file (-dump option).
|
||||
|
@ -33,12 +30,11 @@
|
|||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Bitcode/BitstreamReader.h"
|
||||
#include "llvm/Bitcode/LLVMBitCodes.h"
|
||||
#include "llvm/Bytecode/Analyzer.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Compressor.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
#include <map>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
@ -50,15 +46,12 @@ static cl::opt<std::string>
|
|||
static cl::opt<std::string>
|
||||
OutputFilename("-o", cl::init("-"), cl::desc("<output file>"));
|
||||
|
||||
static cl::opt<bool> NoDetails("nodetails", cl::desc("Skip detailed output"));
|
||||
static cl::opt<bool> Dump("dump", cl::desc("Dump low level bytecode trace"));
|
||||
static cl::opt<bool> Verify("verify", cl::desc("Progressively verify module"));
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Bitcode specific analysis.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
static cl::opt<bool> Bitcode("bitcode", cl::desc("Read a bitcode file"));
|
||||
static cl::opt<bool> NoHistogram("disable-histogram",
|
||||
cl::desc("Do not print per-code histogram"));
|
||||
|
||||
|
@ -501,51 +494,11 @@ static int AnalyzeBitcode() {
|
|||
}
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Bytecode specific analysis.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
|
||||
cl::ParseCommandLineOptions(argc, argv, " llvm-bcanalyzer file analyzer\n");
|
||||
|
||||
sys::PrintStackTraceOnErrorSignal();
|
||||
|
||||
if (Bitcode)
|
||||
return AnalyzeBitcode();
|
||||
|
||||
try {
|
||||
std::ostream *Out = &std::cout; // Default to printing to stdout...
|
||||
std::string ErrorMessage;
|
||||
BytecodeAnalysis bca;
|
||||
|
||||
/// Determine what to generate
|
||||
bca.detailedResults = !NoDetails;
|
||||
bca.progressiveVerify = Verify;
|
||||
|
||||
/// Analyze the bytecode file
|
||||
Module* M = AnalyzeBytecodeFile(InputFilename, bca,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMessage, (Dump?Out:0));
|
||||
|
||||
// All that bcanalyzer does is write the gathered statistics to the output
|
||||
PrintBytecodeAnalysis(bca,*Out);
|
||||
|
||||
if (M && Verify) {
|
||||
std::string verificationMsg;
|
||||
if (verifyModule(*M, ReturnStatusAction, &verificationMsg))
|
||||
std::cerr << "Final Verification Message: " << verificationMsg << "\n";
|
||||
}
|
||||
|
||||
if (Out != &std::cout) {
|
||||
((std::ofstream*)Out)->close();
|
||||
delete Out;
|
||||
}
|
||||
return 0;
|
||||
} catch (const std::string& msg) {
|
||||
std::cerr << argv[0] << ": " << msg << "\n";
|
||||
} catch (...) {
|
||||
std::cerr << argv[0] << ": Unexpected unknown exception occurred.\n";
|
||||
}
|
||||
return 1;
|
||||
return AnalyzeBitcode();
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
LEVEL = ../..
|
||||
|
||||
TOOLNAME = llvm-dis
|
||||
LINK_COMPONENTS := bcreader bitreader
|
||||
LINK_COMPONENTS := bitreader
|
||||
REQUIRES_EH := 1
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
#include "llvm/Module.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Assembly/PrintModulePass.h"
|
||||
#include "llvm/Support/Compressor.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
|
@ -45,9 +43,6 @@ Force("f", cl::desc("Overwrite output files"));
|
|||
static cl::opt<bool>
|
||||
DontPrint("disable-output", cl::desc("Don't output the .ll file"), cl::Hidden);
|
||||
|
||||
static cl::opt<bool>
|
||||
Bitcode("bitcode", cl::desc("Read a bitcode file"));
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
llvm_shutdown_obj X; // Call llvm_shutdown() on exit.
|
||||
try {
|
||||
|
@ -59,21 +54,14 @@ int main(int argc, char **argv) {
|
|||
|
||||
std::auto_ptr<Module> M;
|
||||
|
||||
if (Bitcode) {
|
||||
MemoryBuffer *Buffer
|
||||
= MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
|
||||
MemoryBuffer *Buffer
|
||||
= MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
|
||||
|
||||
if (Buffer == 0)
|
||||
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
||||
else
|
||||
M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
|
||||
|
||||
delete Buffer;
|
||||
} else {
|
||||
M.reset(ParseBytecodeFile(InputFilename,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMessage));
|
||||
}
|
||||
if (Buffer == 0)
|
||||
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
||||
else
|
||||
M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
|
||||
delete Buffer;
|
||||
|
||||
if (M.get() == 0) {
|
||||
cerr << argv[0] << ": ";
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
LEVEL = ../..
|
||||
|
||||
TOOLNAME = llvm-extract
|
||||
LINK_COMPONENTS := bcreader bcwriter ipo bitreader bitwriter
|
||||
LINK_COMPONENTS := ipo bitreader bitwriter
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
|
|
@ -15,23 +15,17 @@
|
|||
#include "llvm/Module.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bytecode/WriteBytecodePass.h"
|
||||
#include "llvm/Transforms/IPO.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Compressor.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <fstream>
|
||||
using namespace llvm;
|
||||
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
|
||||
// InputFilename - The filename to read from.
|
||||
static cl::opt<std::string>
|
||||
InputFilename(cl::Positional, cl::desc("<input bytecode file>"),
|
||||
|
@ -63,20 +57,15 @@ int main(int argc, char **argv) {
|
|||
|
||||
std::auto_ptr<Module> M;
|
||||
|
||||
if (Bitcode) {
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFilename[0],
|
||||
InputFilename.size());
|
||||
if (Buffer == 0) {
|
||||
cerr << "Error reading file '" + InputFilename + "'";
|
||||
return 1;
|
||||
} else {
|
||||
M.reset(ParseBitcodeFile(Buffer));
|
||||
}
|
||||
delete Buffer;
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFilename[0],
|
||||
InputFilename.size());
|
||||
if (Buffer == 0) {
|
||||
cerr << "Error reading file '" + InputFilename + "'";
|
||||
return 1;
|
||||
} else {
|
||||
M.reset(ParseBytecodeFile(InputFilename,
|
||||
Compressor::decompressToNewBuffer));
|
||||
M.reset(ParseBitcodeFile(Buffer));
|
||||
}
|
||||
delete Buffer;
|
||||
|
||||
if (M.get() == 0) {
|
||||
cerr << argv[0] << ": bytecode didn't read correctly.\n";
|
||||
|
@ -120,11 +109,7 @@ int main(int argc, char **argv) {
|
|||
Out = &std::cout;
|
||||
}
|
||||
|
||||
OStream L(*Out);
|
||||
if (Bitcode)
|
||||
Passes.add(CreateBitcodeWriterPass(*Out));
|
||||
else
|
||||
Passes.add(new WriteBytecodePass(&L)); // Write bytecode to file...
|
||||
Passes.add(CreateBitcodeWriterPass(*Out));
|
||||
Passes.run(*M.get());
|
||||
|
||||
if (Out != &std::cout)
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
LEVEL = ../..
|
||||
|
||||
TOOLNAME = llvm-ld
|
||||
LINK_COMPONENTS = ipo scalaropts linker archive bcwriter bitwriter
|
||||
LINK_COMPONENTS = ipo scalaropts linker archive bitwriter
|
||||
REQUIRES_EH := 1
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include "llvm/Module.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Writer.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Target/TargetMachine.h"
|
||||
#include "llvm/Target/TargetMachineRegistry.h"
|
||||
|
@ -41,8 +40,6 @@
|
|||
#include <memory>
|
||||
using namespace llvm;
|
||||
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
|
||||
// Input/Output Options
|
||||
static cl::list<std::string> InputFilenames(cl::Positional, cl::OneOrMore,
|
||||
cl::desc("<input bytecode files>"));
|
||||
|
@ -78,9 +75,6 @@ static cl::opt<bool> Native("native",
|
|||
static cl::opt<bool>NativeCBE("native-cbe",
|
||||
cl::desc("Generate a native binary with the C backend and GCC"));
|
||||
|
||||
static cl::opt<bool>DisableCompression("disable-compression", cl::init(true),
|
||||
cl::desc("Disable writing of compressed bytecode files"));
|
||||
|
||||
static cl::list<std::string> PostLinkOpts("post-link-opts",
|
||||
cl::value_desc("path"),
|
||||
cl::desc("Run one or more optimization programs after linking"));
|
||||
|
@ -227,12 +221,7 @@ void GenerateBytecode(Module* M, const std::string& FileName) {
|
|||
sys::RemoveFileOnSignal(sys::Path(FileName));
|
||||
|
||||
// Write it out
|
||||
if (Bitcode) {
|
||||
WriteBitcodeToFile(M, Out);
|
||||
} else {
|
||||
OStream L(Out);
|
||||
WriteBytecodeToFile(M, L, !DisableCompression);
|
||||
}
|
||||
WriteBitcodeToFile(M, Out);
|
||||
|
||||
// Close the bytecode file.
|
||||
Out.close();
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
LEVEL = ../..
|
||||
|
||||
TOOLNAME = llvm-link
|
||||
LINK_COMPONENTS = linker bcreader bcwriter bitreader bitwriter
|
||||
LINK_COMPONENTS = linker bitreader bitwriter
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
|
|
@ -16,12 +16,9 @@
|
|||
#include "llvm/Module.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bytecode/Writer.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
#include "llvm/System/Path.h"
|
||||
#include <fstream>
|
||||
|
@ -29,8 +26,6 @@
|
|||
#include <memory>
|
||||
using namespace llvm;
|
||||
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
|
||||
static cl::list<std::string>
|
||||
InputFilenames(cl::Positional, cl::OneOrMore,
|
||||
cl::desc("<input bytecode files>"));
|
||||
|
@ -65,20 +60,14 @@ static inline std::auto_ptr<Module> LoadFile(const std::string &FN) {
|
|||
if (Verbose) cerr << "Loading '" << Filename.c_str() << "'\n";
|
||||
Module* Result = 0;
|
||||
|
||||
if (Bitcode) {
|
||||
const std::string &FNStr = Filename.toString();
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&FNStr[0],
|
||||
FNStr.size());
|
||||
if (Buffer == 0)
|
||||
ErrorMessage = "Error reading file '" + FNStr + "'";
|
||||
else
|
||||
Result = ParseBitcodeFile(Buffer, &ErrorMessage);
|
||||
delete Buffer;
|
||||
} else {
|
||||
Result = ParseBytecodeFile(Filename.toString(),
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMessage);
|
||||
}
|
||||
const std::string &FNStr = Filename.toString();
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&FNStr[0],
|
||||
FNStr.size());
|
||||
if (Buffer == 0)
|
||||
ErrorMessage = "Error reading file '" + FNStr + "'";
|
||||
else
|
||||
Result = ParseBitcodeFile(Buffer, &ErrorMessage);
|
||||
delete Buffer;
|
||||
if (Result) return std::auto_ptr<Module>(Result); // Load successful!
|
||||
|
||||
if (Verbose) {
|
||||
|
@ -159,12 +148,7 @@ int main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (Verbose) cerr << "Writing bytecode...\n";
|
||||
if (Bitcode) {
|
||||
WriteBitcodeToFile(Composite.get(), *Out);
|
||||
} else {
|
||||
OStream L(*Out);
|
||||
WriteBytecodeToFile(Composite.get(), L, !NoCompress);
|
||||
}
|
||||
WriteBitcodeToFile(Composite.get(), *Out);
|
||||
|
||||
if (Out != &std::cout) delete Out;
|
||||
return 0;
|
||||
|
|
|
@ -9,6 +9,6 @@
|
|||
LEVEL = ../..
|
||||
|
||||
TOOLNAME = llvm-nm
|
||||
LINK_COMPONENTS = archive bcreader bitreader
|
||||
LINK_COMPONENTS = archive bitreader
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
|
|
@ -18,8 +18,7 @@
|
|||
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bytecode/Archive.h"
|
||||
#include "llvm/Bitcode/Archive.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
|
@ -31,8 +30,6 @@
|
|||
#include <iostream>
|
||||
using namespace llvm;
|
||||
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
|
||||
namespace {
|
||||
enum OutputFormatTy { bsd, sysv, posix };
|
||||
cl::opt<OutputFormatTy>
|
||||
|
@ -125,17 +122,7 @@ static void DumpSymbolNamesFromFile(std::string &Filename) {
|
|||
std::string ErrorMessage;
|
||||
sys::Path aPath(Filename);
|
||||
// Note: Currently we do not support reading an archive from stdin.
|
||||
if (Filename == "-" || aPath.isBytecodeFile()) {
|
||||
Module *Result = ParseBytecodeFile(Filename,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMessage);
|
||||
if (Result) {
|
||||
DumpSymbolNamesFromModule (Result);
|
||||
} else {
|
||||
std::cerr << ToolName << ": " << Filename << ": " << ErrorMessage << "\n";
|
||||
return;
|
||||
}
|
||||
} else if (aPath.isBitcodeFile()) {
|
||||
if (Filename == "-" || aPath.isBitcodeFile()) {
|
||||
std::auto_ptr<MemoryBuffer> Buffer(
|
||||
MemoryBuffer::getFileOrSTDIN(&Filename[0], Filename.size()));
|
||||
Module *Result = 0;
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
LEVEL = ../..
|
||||
|
||||
TOOLNAME = llvm-prof
|
||||
LINK_COMPONENTS = bcreader bitreader analysis
|
||||
LINK_COMPONENTS = bitreader analysis
|
||||
REQUIRES_EH := 1
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
#include "llvm/Module.h"
|
||||
#include "llvm/Assembly/AsmAnnotationWriter.h"
|
||||
#include "llvm/Analysis/ProfileInfoLoader.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
|
@ -32,7 +31,6 @@
|
|||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
cl::opt<std::string>
|
||||
BytecodeFile(cl::Positional, cl::desc("<program bytecode file>"),
|
||||
cl::Required);
|
||||
|
@ -120,19 +118,13 @@ int main(int argc, char **argv) {
|
|||
// Read in the bytecode file...
|
||||
std::string ErrorMessage;
|
||||
Module *M;
|
||||
if (Bitcode) {
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&BytecodeFile[0],
|
||||
BytecodeFile.size());
|
||||
if (Buffer == 0)
|
||||
ErrorMessage = "Error reading file '" + BytecodeFile + "'";
|
||||
else
|
||||
M = ParseBitcodeFile(Buffer, &ErrorMessage);
|
||||
delete Buffer;
|
||||
} else {
|
||||
M = ParseBytecodeFile(BytecodeFile,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMessage);
|
||||
}
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&BytecodeFile[0],
|
||||
BytecodeFile.size());
|
||||
if (Buffer == 0)
|
||||
ErrorMessage = "Error reading file '" + BytecodeFile + "'";
|
||||
else
|
||||
M = ParseBitcodeFile(Buffer, &ErrorMessage);
|
||||
delete Buffer;
|
||||
if (M == 0) {
|
||||
std::cerr << argv[0] << ": " << BytecodeFile << ": "
|
||||
<< ErrorMessage << "\n";
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Bytecode/Archive.h"
|
||||
#include "llvm/Bitcode/Archive.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
##===----------------------------------------------------------------------===##
|
||||
LEVEL = ../..
|
||||
TOOLNAME = llvm2cpp
|
||||
LINK_COMPONENTS = bcreader bitreader
|
||||
LINK_COMPONENTS = bitreader
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
|
@ -31,8 +30,6 @@
|
|||
#include <memory>
|
||||
using namespace llvm;
|
||||
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
|
||||
static cl::opt<std::string>
|
||||
InputFilename(cl::Positional, cl::desc("<input LLVM bytecode file>"),
|
||||
cl::init("-"));
|
||||
|
@ -54,18 +51,12 @@ int main(int argc, char **argv) {
|
|||
std::string ErrorMessage;
|
||||
|
||||
std::auto_ptr<Module> M;
|
||||
if (Bitcode) {
|
||||
std::auto_ptr<MemoryBuffer> Buffer(
|
||||
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
|
||||
if (Buffer.get())
|
||||
M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
|
||||
else
|
||||
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
||||
} else {
|
||||
M.reset(ParseBytecodeFile(InputFilename,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMessage));
|
||||
}
|
||||
std::auto_ptr<MemoryBuffer> Buffer(
|
||||
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
|
||||
if (Buffer.get())
|
||||
M.reset(ParseBitcodeFile(Buffer.get(), &ErrorMessage));
|
||||
else
|
||||
ErrorMessage = "Error reading file '" + InputFilename + "'";
|
||||
if (M.get() == 0) {
|
||||
std::cerr << argv[0] << ": ";
|
||||
if (ErrorMessage.size())
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
#include "CompilerDriver.h"
|
||||
#include "ConfigLexer.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ModuleProvider.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/Timer.h"
|
||||
#include "llvm/System/Signals.h"
|
||||
|
@ -27,8 +27,6 @@
|
|||
using namespace llvm;
|
||||
|
||||
|
||||
static bool Bitcode = false;
|
||||
|
||||
namespace {
|
||||
|
||||
void WriteAction(CompilerDriver::Action* action ) {
|
||||
|
@ -69,17 +67,12 @@ void DumpConfigData(CompilerDriver::ConfigData* cd, const std::string& type ){
|
|||
|
||||
static bool GetBytecodeDependentLibraries(const std::string &fname,
|
||||
Module::LibraryListType& deplibs,
|
||||
BCDecompressor_t *BCDC,
|
||||
std::string* ErrMsg) {
|
||||
ModuleProvider *MP = 0;
|
||||
if (Bitcode) {
|
||||
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&fname[0],
|
||||
fname.size())) {
|
||||
MP = getBitcodeModuleProvider(Buffer);
|
||||
if (MP == 0) delete Buffer;
|
||||
}
|
||||
} else {
|
||||
MP = getBytecodeModuleProvider(fname, BCDC, ErrMsg);
|
||||
if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&fname[0],
|
||||
fname.size())) {
|
||||
MP = getBitcodeModuleProvider(Buffer);
|
||||
if (MP == 0) delete Buffer;
|
||||
}
|
||||
if (!MP) {
|
||||
deplibs.clear();
|
||||
|
@ -598,9 +591,7 @@ private:
|
|||
if (fullpath.isBytecodeFile()) {
|
||||
// Process the dependent libraries recursively
|
||||
Module::LibraryListType modlibs;
|
||||
if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&err)) {
|
||||
if (GetBytecodeDependentLibraries(fullpath.toString(),modlibs, &err)) {
|
||||
// Traverse the dependent libraries list
|
||||
Module::lib_iterator LI = modlibs.begin();
|
||||
Module::lib_iterator LE = modlibs.end();
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
##===----------------------------------------------------------------------===##
|
||||
LEVEL = ../..
|
||||
TOOLNAME = llvmc
|
||||
LINK_COMPONENTS = support system core bcreader bitreader
|
||||
LINK_COMPONENTS = support system core bitreader
|
||||
CONFIG_FILES = c cpp ll st
|
||||
EXTRA_DIST = c cpp ll ConfigLexer.cpp.cvs ConfigLexer.l.cvs
|
||||
REQUIRES_EH := 1
|
||||
|
|
Loading…
Reference in New Issue