- try {
- cl::ParseCommandLineOptions(argc, argv,
- " llvm interpreter & dynamic compiler\n");
- sys::PrintStackTraceOnErrorSignal();
-
- // Load the bytecode...
- std::string ErrorMsg;
- ModuleProvider *MP = 0;
- try {
- MP = getBytecodeModuleProvider(InputFile);
- } catch (std::string &err) {
- std::cerr << "Error loading program '" << InputFile << "': " << err << "\n";
- exit(1);
- }
-
- ExecutionEngine *EE = ExecutionEngine::create(MP, ForceInterpreter);
- assert(EE && "Couldn't create an ExecutionEngine, not even an interpreter?");
-
- // If the user specifically requested an argv[0] to pass into the program, do
- // it now.
- if (!FakeArgv0.empty()) {
- InputFile = FakeArgv0;
- } else {
- // Otherwise, if there is a .bc suffix on the executable strip it off, it
- // might confuse the program.
- if (InputFile.rfind(".bc") == InputFile.length() - 3)
- InputFile.erase(InputFile.length() - 3);
+ atexit(do_shutdown); // Call llvm_shutdown() on exit.
+ cl::ParseCommandLineOptions(argc, argv,
+ " llvm interpreter & dynamic compiler\n");
+ sys::PrintStackTraceOnErrorSignal();
+
+ // If the user doesn't want core files, disable them.
+ if (DisableCoreFiles)
+ sys::Process::PreventCoreFiles();
+
+ // 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;