diff options
Diffstat (limited to 'tools/lli/lli.cpp')
-rw-r--r-- | tools/lli/lli.cpp | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/tools/lli/lli.cpp b/tools/lli/lli.cpp index 218bb93..81c17cd 100644 --- a/tools/lli/lli.cpp +++ b/tools/lli/lli.cpp @@ -15,7 +15,6 @@ #include "llvm/LLVMContext.h" #include "llvm/Module.h" -#include "llvm/ModuleProvider.h" #include "llvm/Type.h" #include "llvm/Bitcode/ReaderWriter.h" #include "llvm/CodeGen/LinkAllCodegenComponents.h" @@ -59,6 +58,22 @@ namespace { TargetTriple("mtriple", cl::desc("Override target triple for module")); cl::opt<std::string> + MArch("march", + cl::desc("Architecture to generate assembly for (see --version)")); + + cl::opt<std::string> + MCPU("mcpu", + cl::desc("Target a specific cpu type (-mcpu=help for details)"), + cl::value_desc("cpu-name"), + cl::init("")); + + cl::list<std::string> + MAttrs("mattr", + cl::CommaSeparated, + cl::desc("Target specific attributes (-mattr=help for details)"), + cl::value_desc("a1,+a2,-a3,...")); + + cl::opt<std::string> EntryFunc("entry-function", cl::desc("Specify the entry function (default = 'main') " "of the executable"), @@ -110,28 +125,31 @@ int main(int argc, char **argv, char * const *envp) { // Load the bitcode... std::string ErrorMsg; - ModuleProvider *MP = NULL; + Module *Mod = NULL; if (MemoryBuffer *Buffer = MemoryBuffer::getFileOrSTDIN(InputFile,&ErrorMsg)){ - MP = getBitcodeModuleProvider(Buffer, Context, &ErrorMsg); - if (!MP) delete Buffer; + Mod = getLazyBitcodeModule(Buffer, Context, &ErrorMsg); + if (!Mod) delete Buffer; } - if (!MP) { + if (!Mod) { errs() << argv[0] << ": error loading program '" << InputFile << "': " << ErrorMsg << "\n"; exit(1); } - // Get the module as the MP could go away once EE takes over. - Module *Mod = NoLazyCompilation - ? MP->materializeModule(&ErrorMsg) : MP->getModule(); - if (!Mod) { - errs() << argv[0] << ": bitcode didn't read correctly.\n"; - errs() << "Reason: " << ErrorMsg << "\n"; - exit(1); + // If not jitting lazily, load the whole bitcode file eagerly too. + if (NoLazyCompilation) { + if (Mod->MaterializeAllPermanently(&ErrorMsg)) { + errs() << argv[0] << ": bitcode didn't read correctly.\n"; + errs() << "Reason: " << ErrorMsg << "\n"; + exit(1); + } } - EngineBuilder builder(MP); + EngineBuilder builder(Mod); + builder.setMArch(MArch); + builder.setMCPU(MCPU); + builder.setMAttrs(MAttrs); builder.setErrorStr(&ErrorMsg); builder.setEngineKind(ForceInterpreter ? EngineKind::Interpreter |