summaryrefslogtreecommitdiffstats
path: root/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
diff options
context:
space:
mode:
authorChuck Rose III <cfr@adobe.com>2007-07-27 18:26:35 +0000
committerChuck Rose III <cfr@adobe.com>2007-07-27 18:26:35 +0000
commit1a39a2d13d8a2bff3c3503d3610b082649217f5b (patch)
tree6688168fc69680ad4bf89811ca6353444449da61 /llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
parent8e9869716c3d9860271c9a84d5e6a401d845c0d4 (diff)
downloadbcm5719-llvm-1a39a2d13d8a2bff3c3503d3610b082649217f5b.tar.gz
bcm5719-llvm-1a39a2d13d8a2bff3c3503d3610b082649217f5b.zip
VStudio compiler errors and placing Function*->ExFunc map under ManagedStatic control.
This commit fixes two things. One is a pair of VStudio compiler errors stemming from variables which defined within the for loop statement and also within the body of the for loop. I fixed these by renaming one of the two variables. Additionally, I've made the Function*->ExFunc map in ExternalFunctions.cpp a ManagedStatic object, so that cleanup will be done on llvm_shutdown. In repeated uses of the interpreter, where the same Function* address may get used for completely differnet functions, this was causing a crash. llvm-svn: 40558
Diffstat (limited to 'llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index 14dcdf9e036..55391df8886 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -25,6 +25,7 @@
#include "llvm/Support/Streams.h"
#include "llvm/System/DynamicLibrary.h"
#include "llvm/Target/TargetData.h"
+#include "llvm/Support/ManagedStatic.h"
#include <csignal>
#include <map>
#include <cmath>
@@ -33,7 +34,7 @@ using std::vector;
using namespace llvm;
typedef GenericValue (*ExFunc)(FunctionType *, const vector<GenericValue> &);
-static std::map<const Function *, ExFunc> Functions;
+static ManagedStatic<std::map<const Function *, ExFunc> > Functions;
static std::map<std::string, ExFunc> FuncNames;
static Interpreter *TheInterpreter;
@@ -80,7 +81,7 @@ static ExFunc lookupFunction(const Function *F) {
FnPtr = (ExFunc)(intptr_t)
sys::DynamicLibrary::SearchForAddressOfSymbol(F->getName());
if (FnPtr != 0)
- Functions.insert(std::make_pair(F, FnPtr)); // Cache for later
+ Functions->insert(std::make_pair(F, FnPtr)); // Cache for later
return FnPtr;
}
@@ -90,8 +91,8 @@ GenericValue Interpreter::callExternalFunction(Function *F,
// Do a lookup to see if the function is in our cache... this should just be a
// deferred annotation!
- std::map<const Function *, ExFunc>::iterator FI = Functions.find(F);
- ExFunc Fn = (FI == Functions.end()) ? lookupFunction(F) : FI->second;
+ std::map<const Function *, ExFunc>::iterator FI = Functions->find(F);
+ ExFunc Fn = (FI == Functions->end()) ? lookupFunction(F) : FI->second;
if (Fn == 0) {
cerr << "Tried to execute an unknown external function: "
<< F->getType()->getDescription() << " " << F->getName() << "\n";
OpenPOWER on IntegriCloud