[Mesa-dev] [PATCH 1/1] gallium/gallivm: code generation options for LLVM 3.1+

Jose Fonseca jfonseca at vmware.com
Mon Sep 24 07:20:31 PDT 2012


Alexander,

Thanks for nailing this. There are still several outstanding bug reports for WINE and LLVM and I never managed to make much progress.

This only covers the MCJIT case, but for LLVM 3.2 we no longer use MCJIT, and just call LLVMCreateJITCompiler (instead of lp_build_create_mcjit_compiler_for_module). So I think we need to create another version of lp_build_create_mcjit_compiler_for_module/LLVMCreateJITCompiler that sets up the target as we need it.

Jose


----- Original Message -----
> From: "Alexander V. Nikolaev" <avn at daemon.hole.ru>
> 
> LLVM 3.1+ haven't more "extern unsigned llvm::StackAlignmentOverride"
> and friends for configuring code generation options, like stack
> alignment.
> 
> So I restrict assiging of lvm::StackAlignmentOverride and other
> variables to LLVM 3.0 only, and wrote similiar code using
> TargetOptions.
> 
> This patch fix segfaulting of WINE using llvmpipe built with LLVM 3.1
> 
> Signed-off-by: Alexander V. Nikolaev <avn at daemon.hole.ru>
> ---
>  src/gallium/auxiliary/gallivm/lp_bld_misc.cpp |   21
>  ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
> b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
> index dd2c612..8410f84 100644
> --- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
> +++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
> @@ -109,7 +109,7 @@ lp_set_target_options(void)
>      * to only assume a 4 bytes alignment for backwards
>      compatibility.
>      */
>  #if defined(PIPE_ARCH_X86)
> -#if HAVE_LLVM >= 0x0300
> +#if HAVE_LLVM == 0x0300
>     llvm::StackAlignmentOverride = 4;
>  #else
>     llvm::StackAlignment = 4;
> @@ -251,8 +251,27 @@
> lp_build_create_mcjit_compiler_for_module(LLVMExecutionEngineRef
> *OutJIT,
>  
>     std::string Error;
>     EngineBuilder builder(unwrap(M));
> +
> +   /**
> +    *  Set proper stack alignment for backward compatibility with
> old binaries
> +    *  and WINE.
> +    */
> +   TargetOptions options;
> +   options.StackAlignmentOverride = 4;
> +   options.RealignStack = true;
> +
> +#if defined(DEBUG)
> +   options.JITEmitDebugInfo = true;
> +#endif
> +
> +#if defined(DEBUG) || defined(PROFILE)
> +   options.NoFramePointerElimNonLeaf = true;
> +   options.NoFramePointerElim = true;
> +#endif
> +
>     builder.setEngineKind(EngineKind::JIT)
>            .setErrorStr(&Error)
> +          .setTargetOptions(options)
>            .setOptLevel((CodeGenOpt::Level)OptLevel);
>  
>     builder.setUseMCJIT(true);
> --
> 1.7.10
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> 


More information about the mesa-dev mailing list