assert(!gallivm->passmgr);
assert(gallivm->target);
- gallivm->passmgr = LLVMCreateFunctionPassManager(gallivm->provider);
+ gallivm->passmgr = LLVMCreateFunctionPassManagerForModule(gallivm->module);
if (!gallivm->passmgr)
return FALSE;
static void
free_gallivm_state(struct gallivm_state *gallivm)
{
- /* 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);
-
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
-
- /* This will already destroy any associated module */
- LLVMDisposeExecutionEngine(gallivm->engine);
+ if (gallivm->engine) {
+ /* This will already destroy any associated module */
+ LLVMDisposeExecutionEngine(gallivm->engine);
+ } else if (gallivm->module) {
+ LLVMDisposeModule(gallivm->module);
+ }
#if !USE_MCJIT
/* Don't free the TargetData, it's owned by the exec engine */
gallivm->engine = NULL;
gallivm->target = NULL;
gallivm->module = NULL;
- gallivm->provider = NULL;
gallivm->passmgr = NULL;
gallivm->context = NULL;
gallivm->builder = NULL;
}
}
- LLVMAddModuleProvider(gallivm->engine, gallivm->provider);//new
-
#if !USE_MCJIT
gallivm->target = LLVMGetExecutionEngineTargetData(gallivm->engine);
if (!gallivm->target)
{
assert(!gallivm->context);
assert(!gallivm->module);
- assert(!gallivm->provider);
lp_build_init();
if (!gallivm->module)
goto fail;
- gallivm->provider =
- LLVMCreateModuleProviderForExistingModule(gallivm->module);
- if (!gallivm->provider)
- goto fail;
-
gallivm->builder = LLVMCreateBuilderInContext(gallivm->context);
if (!gallivm->builder)
goto fail;