diff --git a/src/gallium/auxiliary/gallivm/lp_bld_init.c b/src/gallium/auxiliary/gallivm/lp_bld_init.c index 768d935..0aaa95d 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_init.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_init.c @@ -196,6 +196,7 @@ free_gallivm_state(struct gallivm_state *gallivm) #if 0 /* Don't free the TargetData, it's owned by the exec engine */ +#else LLVMDisposeTargetData(gallivm->target); #endif @@ -271,6 +272,21 @@ init_gallivm_state(struct gallivm_state *gallivm) LLVMAddModuleProvider(gallivm->engine, gallivm->provider);//new gallivm->target = LLVMGetExecutionEngineTargetData(gallivm->engine); +#if 1 + { + /* + * Try to workaround a misterious bug whereby LLVMOffsetOfElement() starts + * giving bogus results (see fdo bug 41791 and 44466); + */ + + char *data_layout; + data_layout = LLVMCopyStringRepOfTargetData(gallivm->target); + if (data_layout) { + gallivm->target = LLVMCreateTargetData(data_layout); + free(data_layout); + } + } +#endif if (!gallivm->target) goto fail;