mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-11-01 15:11:24 +00:00
switch tools to bitcode from bytecode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36872 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
73a978a753
commit
744879ea01
@ -20,9 +20,7 @@
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Assembly/Parser.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Compressor.h"
|
||||
#include "llvm/Support/FileUtilities.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#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.
|
||||
///
|
||||
Module *llvm::ParseInputFile(const std::string &InputFilename) {
|
||||
ParseError Err;
|
||||
Module *Result = ParseBytecodeFile(InputFilename,
|
||||
Compressor::decompressToNewBuffer);
|
||||
if (!Result) {
|
||||
std::auto_ptr<MemoryBuffer> Buffer(
|
||||
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
|
||||
if (Buffer.get())
|
||||
Result = ParseBitcodeFile(Buffer.get());
|
||||
}
|
||||
std::auto_ptr<MemoryBuffer> Buffer(
|
||||
MemoryBuffer::getFileOrSTDIN(&InputFilename[0], InputFilename.size()));
|
||||
Module *Result = 0;
|
||||
if (Buffer.get())
|
||||
Result = ParseBitcodeFile(Buffer.get());
|
||||
|
||||
ParseError Err;
|
||||
if (!Result && !(Result = ParseAssemblyFile(InputFilename,&Err))) {
|
||||
std::cerr << "bugpoint: " << Err.getMessage() << "\n";
|
||||
Result = 0;
|
||||
|
@ -10,7 +10,7 @@ LEVEL = ../..
|
||||
|
||||
TOOLNAME = bugpoint
|
||||
|
||||
LINK_COMPONENTS := bcreader bcwriter asmparser instrumentation scalaropts ipo \
|
||||
LINK_COMPONENTS := asmparser instrumentation scalaropts ipo \
|
||||
linker bitreader bitwriter
|
||||
REQUIRES_EH := 1
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Bytecode/WriteBytecodePass.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Target/TargetData.h"
|
||||
#include "llvm/Support/FileUtilities.h"
|
||||
@ -39,8 +38,6 @@
|
||||
#include <fstream>
|
||||
using namespace llvm;
|
||||
|
||||
static bool Bitcode = false;
|
||||
|
||||
|
||||
namespace {
|
||||
// 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::ofstream Out(Filename.c_str(), io_mode);
|
||||
if (!Out.good()) return true;
|
||||
try {
|
||||
OStream L(Out);
|
||||
WriteBytecodeToFile(M ? M : Program, L, /*compression=*/false);
|
||||
} catch (...) {
|
||||
return true;
|
||||
}
|
||||
|
||||
WriteBitcodeToFile(M, Out);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -113,11 +106,7 @@ int BugDriver::runPassesAsChild(const std::vector<const PassInfo*> &Passes) {
|
||||
PM.add(createVerifierPass());
|
||||
|
||||
// Write bytecode out to disk as the last step...
|
||||
OStream L(OutFile);
|
||||
if (Bitcode)
|
||||
PM.add(CreateBitcodeWriterPass(OutFile));
|
||||
else
|
||||
PM.add(new WriteBytecodePass(&L));
|
||||
PM.add(CreateBitcodeWriterPass(OutFile));
|
||||
|
||||
// Run all queued passes.
|
||||
PM.run(*Program);
|
||||
@ -161,8 +150,7 @@ bool BugDriver::runPasses(const std::vector<const PassInfo*> &Passes,
|
||||
cerr << "Error opening bytecode file: " << inputFilename << "\n";
|
||||
return(1);
|
||||
}
|
||||
OStream L(InFile);
|
||||
WriteBytecodeToFile(Program,L,false);
|
||||
WriteBitcodeToFile(Program, InFile);
|
||||
InFile.close();
|
||||
|
||||
// setup the child process' arguments
|
||||
|
@ -15,7 +15,7 @@ TOOLNAME = llc
|
||||
# early so we can set up LINK_COMPONENTS before including Makefile.rules
|
||||
include $(LEVEL)/Makefile.config
|
||||
|
||||
LINK_COMPONENTS := $(TARGETS_TO_BUILD) bcreader bitreader
|
||||
LINK_COMPONENTS := $(TARGETS_TO_BUILD) bitreader
|
||||
|
||||
include $(LLVM_SRC_ROOT)/Makefile.rules
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/CodeGen/FileWriters.h"
|
||||
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
||||
#include "llvm/Target/SubtargetFeature.h"
|
||||
@ -23,10 +22,10 @@
|
||||
#include "llvm/Target/TargetMachineRegistry.h"
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ModuleProvider.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Compressor.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/PluginLoader.h"
|
||||
@ -40,9 +39,6 @@
|
||||
#include <memory>
|
||||
using namespace llvm;
|
||||
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
|
||||
|
||||
// General options for llc. Other pass-specific options are specified
|
||||
// within the corresponding llc passes, and target-specific options
|
||||
// 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::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] << ": bytecode didn't read correctly.\n";
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
LEVEL := ../..
|
||||
TOOLNAME := lli
|
||||
LINK_COMPONENTS := jit interpreter native bcreader bitreader selectiondag
|
||||
LINK_COMPONENTS := jit interpreter native bitreader selectiondag
|
||||
|
||||
# Enable JIT support
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
@ -17,13 +17,11 @@
|
||||
#include "llvm/ModuleProvider.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/CodeGen/LinkAllCodegenComponents.h"
|
||||
#include "llvm/ExecutionEngine/JIT.h"
|
||||
#include "llvm/ExecutionEngine/Interpreter.h"
|
||||
#include "llvm/ExecutionEngine/GenericValue.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/Compressor.h"
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MemoryBuffer.h"
|
||||
#include "llvm/Support/PluginLoader.h"
|
||||
@ -34,8 +32,6 @@
|
||||
using namespace llvm;
|
||||
|
||||
namespace {
|
||||
cl::opt<bool> Bitcode("bitcode");
|
||||
|
||||
cl::opt<std::string>
|
||||
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...
|
||||
std::string ErrorMsg;
|
||||
ModuleProvider *MP = 0;
|
||||
if (Bitcode) {
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFile[0],
|
||||
InputFile.size());
|
||||
if (Buffer == 0)
|
||||
ErrorMsg = "Error reading file '" + InputFile + "'";
|
||||
else {
|
||||
MP = getBitcodeModuleProvider(Buffer, &ErrorMsg);
|
||||
if (!MP) delete Buffer;
|
||||
}
|
||||
} else {
|
||||
MP = getBytecodeModuleProvider(InputFile,
|
||||
Compressor::decompressToNewBuffer,
|
||||
&ErrorMsg);
|
||||
MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(&InputFile[0],
|
||||
InputFile.size());
|
||||
if (Buffer == 0)
|
||||
ErrorMsg = "Error reading file '" + InputFile + "'";
|
||||
else {
|
||||
MP = getBitcodeModuleProvider(Buffer, &ErrorMsg);
|
||||
if (!MP) delete Buffer;
|
||||
}
|
||||
|
||||
if (!MP) {
|
||||
|
@ -24,7 +24,7 @@ else
|
||||
BUILD_ARCHIVE = 1
|
||||
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
|
||||
|
||||
|
@ -17,9 +17,8 @@
|
||||
#include "llvm/Linker.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/ModuleProvider.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bytecode/Writer.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/Support/FileUtilities.h"
|
||||
#include "llvm/Support/SystemUtils.h"
|
||||
@ -40,7 +39,6 @@
|
||||
#include "llvm/Transforms/Scalar.h"
|
||||
#include "llvm/Analysis/LoadValueNumbering.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
#include "llvm/LinkTimeOptimizer.h"
|
||||
#include <fstream>
|
||||
#include <ostream>
|
||||
@ -53,8 +51,6 @@ llvm::LinkTimeOptimizer *createLLVMOptimizer()
|
||||
return l;
|
||||
}
|
||||
|
||||
static bool Bitcode = false;
|
||||
|
||||
/// If symbol is not used then make it internal and let optimizer takes
|
||||
/// care of it.
|
||||
void LLVMSymbol::mayBeNotUsed() {
|
||||
@ -121,16 +117,13 @@ LTO::getModule(const std::string &InputFilename)
|
||||
NameToModuleMap::iterator pos = allModules.find(InputFilename.c_str());
|
||||
if (pos != allModules.end())
|
||||
m = allModules[InputFilename.c_str()];
|
||||
else if (Bitcode) {
|
||||
else {
|
||||
if (MemoryBuffer *Buffer
|
||||
= MemoryBuffer::getFile(&InputFilename[0], InputFilename.size())) {
|
||||
m = ParseBitcodeFile(Buffer);
|
||||
delete Buffer;
|
||||
}
|
||||
allModules[InputFilename.c_str()] = m;
|
||||
} else {
|
||||
m = ParseBytecodeFile(InputFilename);
|
||||
allModules[InputFilename.c_str()] = m;
|
||||
}
|
||||
return m;
|
||||
}
|
||||
@ -385,12 +378,7 @@ LTO::optimizeModules(const std::string &OutputFilename,
|
||||
std::string tempFileName(FinalOutputPath.c_str());
|
||||
tempFileName += "0.bc";
|
||||
std::ofstream Out(tempFileName.c_str(), io_mode);
|
||||
if (Bitcode) {
|
||||
WriteBitcodeToFile(bigOne, Out);
|
||||
} else {
|
||||
OStream L(Out);
|
||||
WriteBytecodeToFile(bigOne, L);
|
||||
}
|
||||
WriteBitcodeToFile(bigOne, Out);
|
||||
}
|
||||
|
||||
// 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());
|
||||
tempFileName += "1.bc";
|
||||
std::ofstream Out(tempFileName.c_str(), io_mode);
|
||||
if (Bitcode) {
|
||||
WriteBitcodeToFile(bigOne, Out);
|
||||
} else {
|
||||
OStream L(Out);
|
||||
WriteBytecodeToFile(bigOne, L);
|
||||
}
|
||||
WriteBitcodeToFile(bigOne, Out);
|
||||
}
|
||||
|
||||
targetTriple = bigOne->getTargetTriple();
|
||||
|
@ -10,6 +10,6 @@ LEVEL = ../..
|
||||
TOOLNAME = opt
|
||||
REQUIRES_EH := 1
|
||||
|
||||
LINK_COMPONENTS := bcreader bcwriter bitreader bitwriter instrumentation scalaropts ipo
|
||||
LINK_COMPONENTS := bitreader bitwriter instrumentation scalaropts ipo
|
||||
|
||||
include $(LEVEL)/Makefile.common
|
||||
|
@ -14,8 +14,6 @@
|
||||
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bytecode/WriteBytecodePass.h"
|
||||
#include "llvm/Bitcode/ReaderWriter.h"
|
||||
#include "llvm/Assembly/PrintModulePass.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
@ -37,17 +35,12 @@
|
||||
#include <algorithm>
|
||||
using namespace llvm;
|
||||
|
||||
static cl::opt<bool> Bitcode("bitcode");
|
||||
|
||||
// The OptimizationList is automatically populated with registered Passes by the
|
||||
// PassNameParser.
|
||||
//
|
||||
static cl::list<const PassInfo*, bool, PassNameParser>
|
||||
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...
|
||||
//
|
||||
static cl::opt<std::string>
|
||||
@ -267,21 +260,15 @@ int main(int argc, char **argv) {
|
||||
|
||||
// Load the input module...
|
||||
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] << ": ";
|
||||
if (ErrorMessage.size())
|
||||
@ -372,13 +359,8 @@ int main(int argc, char **argv) {
|
||||
Passes.add(createVerifierPass());
|
||||
|
||||
// Write bytecode out to disk or cout as the last step...
|
||||
OStream L(*Out);
|
||||
if (!NoOutput && !AnalyzeOnly) {
|
||||
if (Bitcode)
|
||||
Passes.add(CreateBitcodeWriterPass(*Out));
|
||||
else
|
||||
Passes.add(new WriteBytecodePass(&L, false, !NoCompress));
|
||||
}
|
||||
if (!NoOutput && !AnalyzeOnly)
|
||||
Passes.add(CreateBitcodeWriterPass(*Out));
|
||||
|
||||
// Now that we have all of the passes ready, run them.
|
||||
Passes.run(*M.get());
|
||||
|
Loading…
Reference in New Issue
Block a user