aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/ExecutionEngine/ExecutionEngine.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-25 22:10:06 +0000
committerChris Lattner <sabre@nondot.org>2009-04-25 22:10:06 +0000
commit552672d28516f71344d7ce5ae3edd8a251cefc42 (patch)
tree8b9a0da6a81ec4344f20cce666551fdd31d577ff /include/llvm/ExecutionEngine/ExecutionEngine.h
parent069429062d15a020047a3e52680822709aeb6d51 (diff)
downloadexternal_llvm-552672d28516f71344d7ce5ae3edd8a251cefc42.zip
external_llvm-552672d28516f71344d7ce5ae3edd8a251cefc42.tar.gz
external_llvm-552672d28516f71344d7ce5ae3edd8a251cefc42.tar.bz2
improve documentation around memory lifetimes,
patch by Jeffrey Yasskin! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@70083 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/ExecutionEngine/ExecutionEngine.h')
-rw-r--r--include/llvm/ExecutionEngine/ExecutionEngine.h22
1 files changed, 17 insertions, 5 deletions
diff --git a/include/llvm/ExecutionEngine/ExecutionEngine.h b/include/llvm/ExecutionEngine/ExecutionEngine.h
index 0c53a53..39ed071 100644
--- a/include/llvm/ExecutionEngine/ExecutionEngine.h
+++ b/include/llvm/ExecutionEngine/ExecutionEngine.h
@@ -186,7 +186,8 @@ public:
/// at the specified location. This is used internally as functions are JIT'd
/// and as global variables are laid out in memory. It can and should also be
/// used by clients of the EE that want to have an LLVM global overlay
- /// existing data in memory.
+ /// existing data in memory. After adding a mapping for GV, you must not
+ /// destroy it until you've removed the mapping.
void addGlobalMapping(const GlobalValue *GV, void *Addr);
/// clearAllGlobalMappings - Clear all global mappings and start over again
@@ -210,19 +211,29 @@ public:
void *getPointerToGlobalIfAvailable(const GlobalValue *GV);
/// getPointerToGlobal - This returns the address of the specified global
- /// value. This may involve code generation if it's a function.
+ /// value. This may involve code generation if it's a function. After
+ /// getting a pointer to GV, it and all globals it transitively refers to have
+ /// been passed to addGlobalMapping. You must clear the mapping for each
+ /// referred-to global before destroying it. If a referred-to global RTG is a
+ /// function and this ExecutionEngine is a JIT compiler, calling
+ /// updateGlobalMapping(RTG, 0) will leak the function's machine code, so you
+ /// should call freeMachineCodeForFunction(RTG) instead. Note that
+ /// optimizations can move and delete non-external GlobalValues without
+ /// notifying the ExecutionEngine.
///
void *getPointerToGlobal(const GlobalValue *GV);
/// getPointerToFunction - The different EE's represent function bodies in
/// different ways. They should each implement this to say what a function
- /// pointer should look like.
+ /// pointer should look like. See getPointerToGlobal for the requirements on
+ /// destroying F and any GlobalValues it refers to.
///
virtual void *getPointerToFunction(Function *F) = 0;
/// getPointerToFunctionOrStub - If the specified function has been
/// code-gen'd, return a pointer to the function. If not, compile it, or use
- /// a stub to implement lazy compilation if available.
+ /// a stub to implement lazy compilation if available. See getPointerToGlobal
+ /// for the requirements on destroying F and any GlobalValues it refers to.
///
virtual void *getPointerToFunctionOrStub(Function *F) {
// Default implementation, just codegen the function.
@@ -255,7 +266,8 @@ public:
/// getOrEmitGlobalVariable - Return the address of the specified global
/// variable, possibly emitting it to memory if needed. This is used by the
- /// Emitter.
+ /// Emitter. See getPointerToGlobal for the requirements on destroying GV and
+ /// any GlobalValues it refers to.
virtual void *getOrEmitGlobalVariable(const GlobalVariable *GV) {
return getPointerToGlobal((GlobalValue*)GV);
}