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