/* llmoduleprovider -> ExecutionEngine.t -> llmodule */ CAMLprim LLVMModuleRef llvm_ee_remove_mp(LLVMModuleProviderRef MP, LLVMExecutionEngineRef EE) { LLVMModuleRef RemovedModule; char *Error; if (LLVMRemoveModuleProvider(EE, MP, &RemovedModule, &Error)) llvm_raise(llvm_ee_error_exn, Error); return RemovedModule; }
/** * Free gallivm object's LLVM allocations, but not the gallivm object itself. */ static void free_gallivm_state(struct gallivm_state *gallivm) { #if HAVE_LLVM >= 0x207 /* XXX or 0x208? */ /* This leads to crashes w/ some versions of LLVM */ LLVMModuleRef mod; char *error; if (gallivm->engine && gallivm->provider) LLVMRemoveModuleProvider(gallivm->engine, gallivm->provider, &mod, &error); #endif if (gallivm->passmgr) { LLVMDisposePassManager(gallivm->passmgr); } #if 0 /* XXX this seems to crash with all versions of LLVM */ if (gallivm->provider) LLVMDisposeModuleProvider(gallivm->provider); #endif if (HAVE_LLVM >= 0x207 && gallivm->engine) { /* This will already destroy any associated module */ LLVMDisposeExecutionEngine(gallivm->engine); } else { LLVMDisposeModule(gallivm->module); } #if !USE_MCJIT /* Don't free the TargetData, it's owned by the exec engine */ #else if (gallivm->target) { LLVMDisposeTargetData(gallivm->target); } #endif /* Never free the LLVM context. */ #if 0 if (gallivm->context) LLVMContextDispose(gallivm->context); #endif if (gallivm->builder) LLVMDisposeBuilder(gallivm->builder); gallivm->engine = NULL; gallivm->target = NULL; gallivm->module = NULL; gallivm->provider = NULL; gallivm->passmgr = NULL; gallivm->context = NULL; gallivm->builder = NULL; }
/** * Free gallivm object's LLVM allocations, but not the gallivm object itself. */ static void free_gallivm_state(struct gallivm_state *gallivm) { #if HAVE_LLVM >= 0x207 /* XXX or 0x208? */ /* This leads to crashes w/ some versions of LLVM */ LLVMModuleRef mod; char *error; if (gallivm->engine && gallivm->provider) LLVMRemoveModuleProvider(gallivm->engine, gallivm->provider, &mod, &error); #endif #if 0 /* XXX this seems to crash with all versions of LLVM */ if (gallivm->provider) LLVMDisposeModuleProvider(gallivm->provider); #endif if (gallivm->passmgr) LLVMDisposePassManager(gallivm->passmgr); #if HAVE_LLVM >= 0x207 if (gallivm->module) LLVMDisposeModule(gallivm->module); #endif #if 0 /* Don't free the exec engine, it's a global/singleton */ if (gallivm->engine) LLVMDisposeExecutionEngine(gallivm->engine); #endif #if 0 /* Don't free the TargetData, it's owned by the exec engine */ LLVMDisposeTargetData(gallivm->target); #endif if (gallivm->context) LLVMContextDispose(gallivm->context); if (gallivm->builder) LLVMDisposeBuilder(gallivm->builder); gallivm->engine = NULL; gallivm->target = NULL; gallivm->module = NULL; gallivm->provider = NULL; gallivm->passmgr = NULL; gallivm->context = NULL; gallivm->builder = NULL; }
SWIGEXPORT jint JNICALL Java_org_jllvm_bindings_ExecutionEngineJNI_LLVMRemoveModuleProvider(JNIEnv *jenv, jclass jcls, jlong jarg1, jlong jarg2, jlong jarg3, jlong jarg4) { jint jresult = 0 ; LLVMExecutionEngineRef arg1 = (LLVMExecutionEngineRef) 0 ; LLVMModuleProviderRef arg2 = (LLVMModuleProviderRef) 0 ; LLVMModuleRef *arg3 = (LLVMModuleRef *) 0 ; char **arg4 = (char **) 0 ; LLVMBool result; (void)jenv; (void)jcls; arg1 = *(LLVMExecutionEngineRef *)&jarg1; arg2 = *(LLVMModuleProviderRef *)&jarg2; arg3 = *(LLVMModuleRef **)&jarg3; arg4 = *(char ***)&jarg4; result = (LLVMBool)LLVMRemoveModuleProvider(arg1,arg2,arg3,arg4); jresult = (jint)result; return jresult; }