summaryrefslogtreecommitdiffstats
path: root/llvm/tools
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-03-06 03:12:55 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-03-06 03:12:55 +0000
commitfe5550b2cf5502fd2d32b05596de33de1534b636 (patch)
tree7edd576df1dccf1b816f9d7d38b22c1241d86d93 /llvm/tools
parentc764c55745fc59167b062a2452c4bdfa866c146e (diff)
downloadbcm5719-llvm-fe5550b2cf5502fd2d32b05596de33de1534b636.tar.gz
bcm5719-llvm-fe5550b2cf5502fd2d32b05596de33de1534b636.zip
Obtain the exit function before execution just in case the module
disappears before we get to calling the exit function. llvm-svn: 34953
Diffstat (limited to 'llvm/tools')
-rw-r--r--llvm/tools/lli/lli.cpp12
1 files changed, 7 insertions, 5 deletions
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index c02d2a44192..225180b8cae 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -124,6 +124,10 @@ int main(int argc, char **argv, char * const *envp) {
return -1;
}
+ // If the program doesn't explicitly call exit, we will need the Exit
+ // function later on to make an explicit call, so get the function now.
+ Constant *Exit = Mod->getOrInsertFunction("exit", Type::VoidTy,
+ Type::Int32Ty, NULL);
// Run static constructors.
EE->runStaticConstructorsDestructors(false);
@@ -133,14 +137,12 @@ int main(int argc, char **argv, char * const *envp) {
// Run static destructors.
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.
- Constant *Exit = Mod->getOrInsertFunction("exit", Type::VoidTy,
- Type::Int32Ty, NULL);
+ // If the program didn't call exit explicitly, we should call it now.
+ // This ensures that any atexit handlers get called correctly.
if (Function *ExitF = dyn_cast<Function>(Exit)) {
std::vector<GenericValue> Args;
GenericValue ResultGV;
- ResultGV.Int32Val = Result;
+ ResultGV.IntVal = APInt(32, Result);
Args.push_back(ResultGV);
EE->runFunction(ExitF, Args);
std::cerr << "ERROR: exit(" << Result << ") returned!\n";
OpenPOWER on IntegriCloud