//===----------------------------------------------------------------------===//
#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>
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--;
}
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
LEVEL = ../..
TOOLNAME = llvm-as
-LINK_COMPONENTS := asmparser bcwriter bitwriter
+LINK_COMPONENTS := asmparser bitwriter
REQUIRES_EH := 1
include $(LEVEL)/Makefile.common
//
// 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"
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");
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;
LEVEL = ../..
TOOLNAME = llvm-bcanalyzer
-LINK_COMPONENTS := bcreader
+LINK_COMPONENTS := bitreader
REQUIRES_EH := 1
include $(LEVEL)/Makefile.common
//
// 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
// 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).
#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>
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"));
}
-//===----------------------------------------------------------------------===//
-// 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();
}
LEVEL = ../..
TOOLNAME = llvm-dis
-LINK_COMPONENTS := bcreader bitreader
+LINK_COMPONENTS := bitreader
REQUIRES_EH := 1
include $(LEVEL)/Makefile.common
#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"
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 {
std::auto_ptr<Module> M;
- if (Bitcode) {
- 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));
- }
+ MemoryBuffer *Buffer
+ = MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size());
+
+ if (Buffer == 0)
+ ErrorMessage = "Error reading file '" + InputFilename + "'";
+ else
+ M.reset(ParseBitcodeFile(Buffer, &ErrorMessage));
+ delete Buffer;
if (M.get() == 0) {
cerr << argv[0] << ": ";
LEVEL = ../..
TOOLNAME = llvm-extract
-LINK_COMPONENTS := bcreader bcwriter ipo bitreader bitwriter
+LINK_COMPONENTS := ipo bitreader bitwriter
include $(LEVEL)/Makefile.common
#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>"),
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";
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)
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
#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"
#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>"));
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"));
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();
LEVEL = ../..
TOOLNAME = llvm-link
-LINK_COMPONENTS = linker bcreader bcwriter bitreader bitwriter
+LINK_COMPONENTS = linker bitreader bitwriter
include $(LEVEL)/Makefile.common
#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>
#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>"));
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) {
}
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;
LEVEL = ../..
TOOLNAME = llvm-nm
-LINK_COMPONENTS = archive bcreader bitreader
+LINK_COMPONENTS = archive bitreader
include $(LEVEL)/Makefile.common
#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"
#include <iostream>
using namespace llvm;
-cl::opt<bool> Bitcode("bitcode");
-
namespace {
enum OutputFormatTy { bsd, sysv, posix };
cl::opt<OutputFormatTy>
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;
LEVEL = ../..
TOOLNAME = llvm-prof
-LINK_COMPONENTS = bcreader bitreader analysis
+LINK_COMPONENTS = bitreader analysis
REQUIRES_EH := 1
include $(LEVEL)/Makefile.common
#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"
using namespace llvm;
namespace {
- cl::opt<bool> Bitcode("bitcode");
cl::opt<std::string>
BytecodeFile(cl::Positional, cl::desc("<program bytecode file>"),
cl::Required);
// 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";
//===----------------------------------------------------------------------===//
#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"
##===----------------------------------------------------------------------===##
LEVEL = ../..
TOOLNAME = llvm2cpp
-LINK_COMPONENTS = bcreader bitreader
+LINK_COMPONENTS = bitreader
include $(LEVEL)/Makefile.common
#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"
#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("-"));
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())
#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"
using namespace llvm;
-static bool Bitcode = false;
-
namespace {
void WriteAction(CompilerDriver::Action* action ) {
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();
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();
##===----------------------------------------------------------------------===##
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