forked from OSchip/llvm-project
Fit to 80 columns.
Add support for running static ctor/dtors that aren't handled by __main. This fixes programs with the JIT and the new CFE, such as HBD. llvm-svn: 26620
This commit is contained in:
parent
faae50b66b
commit
d0eb1d12d2
|
@ -60,7 +60,8 @@ int main(int argc, char **argv, char * const *envp) {
|
||||||
try {
|
try {
|
||||||
MP = getBytecodeModuleProvider(InputFile);
|
MP = getBytecodeModuleProvider(InputFile);
|
||||||
} catch (std::string &err) {
|
} catch (std::string &err) {
|
||||||
std::cerr << "Error loading program '" << InputFile << "': " << err << "\n";
|
std::cerr << "Error loading program '" << InputFile << "': "
|
||||||
|
<< err << "\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,10 +70,10 @@ int main(int argc, char **argv, char * const *envp) {
|
||||||
MP->getModule()->setTargetTriple(TargetTriple);
|
MP->getModule()->setTargetTriple(TargetTriple);
|
||||||
|
|
||||||
ExecutionEngine *EE = ExecutionEngine::create(MP, ForceInterpreter);
|
ExecutionEngine *EE = ExecutionEngine::create(MP, ForceInterpreter);
|
||||||
assert(EE && "Couldn't create an ExecutionEngine, not even an interpreter?");
|
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
|
// If the user specifically requested an argv[0] to pass into the program,
|
||||||
// it now.
|
// do it now.
|
||||||
if (!FakeArgv0.empty()) {
|
if (!FakeArgv0.empty()) {
|
||||||
InputFile = FakeArgv0;
|
InputFile = FakeArgv0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -96,11 +97,17 @@ int main(int argc, char **argv, char * const *envp) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Run main...
|
// Run static constructors.
|
||||||
|
EE->runStaticConstructorsDestructors(false);
|
||||||
|
|
||||||
|
// Run main.
|
||||||
int Result = EE->runFunctionAsMain(Fn, InputArgv, envp);
|
int Result = EE->runFunctionAsMain(Fn, InputArgv, envp);
|
||||||
|
|
||||||
// If the program didn't explicitly call exit, call exit now, for the program.
|
// Run static destructors.
|
||||||
// This ensures that any atexit handlers get called correctly.
|
EE->runStaticConstructorsDestructors(true);
|
||||||
|
|
||||||
|
// If the program didn't explicitly call exit, call exit now, for the
|
||||||
|
// program. This ensures that any atexit handlers get called correctly.
|
||||||
Function *Exit = MP->getModule()->getOrInsertFunction("exit", Type::VoidTy,
|
Function *Exit = MP->getModule()->getOrInsertFunction("exit", Type::VoidTy,
|
||||||
Type::IntTy,
|
Type::IntTy,
|
||||||
(Type *)0);
|
(Type *)0);
|
||||||
|
|
Loading…
Reference in New Issue