aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
diff options
context:
space:
mode:
authorKeno Fischer <kfischer@college.harvard.edu>2015-06-20 00:55:58 +0000
committerKeno Fischer <kfischer@college.harvard.edu>2015-06-20 00:55:58 +0000
commit73378eb1c739ef39c6c01184a09a9019d94dc031 (patch)
treeac20e9b7fb8585fd65a6f76d609c361e82d79c89 /llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
parente46d3796fc7a7c766c5a6a943cfe8b162c320ca8 (diff)
downloadllvm-73378eb1c739ef39c6c01184a09a9019d94dc031.zip
llvm-73378eb1c739ef39c6c01184a09a9019d94dc031.tar.gz
llvm-73378eb1c739ef39c6c01184a09a9019d94dc031.tar.bz2
[MCJIT] Add a FindGlobalVariableNamed utility
Summary: This adds FindGlobalVariableNamed to ExecutionEngine (plus implementation in MCJIT), which is an analog of FindFunctionNamed for GlobalVariables. Reviewers: lhames Reviewed By: lhames Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D10421 llvm-svn: 240202
Diffstat (limited to 'llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp')
-rw-r--r--llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
index 358d364..87243e4 100644
--- a/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
+++ b/llvm/lib/ExecutionEngine/MCJIT/MCJIT.cpp
@@ -429,6 +429,19 @@ Function *MCJIT::FindFunctionNamedInModulePtrSet(const char *FnName,
return nullptr;
}
+GlobalVariable *MCJIT::FindGlobalVariableNamedInModulePtrSet(const char *Name,
+ bool AllowInternal,
+ ModulePtrSet::iterator I,
+ ModulePtrSet::iterator E) {
+ for (; I != E; ++I) {
+ GlobalVariable *GV = (*I)->getGlobalVariable(Name, AllowInternal);
+ if (GV && !GV->isDeclaration())
+ return GV;
+ }
+ return nullptr;
+}
+
+
Function *MCJIT::FindFunctionNamed(const char *FnName) {
Function *F = FindFunctionNamedInModulePtrSet(
FnName, OwnedModules.begin_added(), OwnedModules.end_added());
@@ -441,6 +454,18 @@ Function *MCJIT::FindFunctionNamed(const char *FnName) {
return F;
}
+GlobalVariable *MCJIT::FindGlobalVariableNamed(const char *Name, bool AllowInternal) {
+ GlobalVariable *GV = FindGlobalVariableNamedInModulePtrSet(
+ Name, AllowInternal, OwnedModules.begin_added(), OwnedModules.end_added());
+ if (!GV)
+ GV = FindGlobalVariableNamedInModulePtrSet(Name, AllowInternal, OwnedModules.begin_loaded(),
+ OwnedModules.end_loaded());
+ if (!GV)
+ GV = FindGlobalVariableNamedInModulePtrSet(Name, AllowInternal, OwnedModules.begin_finalized(),
+ OwnedModules.end_finalized());
+ return GV;
+}
+
GenericValue MCJIT::runFunction(Function *F, ArrayRef<GenericValue> ArgValues) {
assert(F && "Function *F was null at entry to run()");