diff options
author | Alexander V. Nikolaev <avn@daemon.hole.ru> | 2012-09-23 05:28:39 +0300 |
---|---|---|
committer | José Fonseca <jose.r.fonseca@gmail.com> | 2012-10-28 10:34:26 +0000 |
commit | eaa8e56108e28ff5fabc8c471f4e904b53c5f8fb (patch) | |
tree | 780268841d125bf38eb555856a8fdd53de846cd9 /src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | |
parent | 459b28aba7c4ef0afe8d23dd2953e236d1bf7aed (diff) | |
download | external_mesa3d-eaa8e56108e28ff5fabc8c471f4e904b53c5f8fb.zip external_mesa3d-eaa8e56108e28ff5fabc8c471f4e904b53c5f8fb.tar.gz external_mesa3d-eaa8e56108e28ff5fabc8c471f4e904b53c5f8fb.tar.bz2 |
gallium/gallivm: code generation options for LLVM 3.1+
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@daemon.hole.ru>
Signed-off-by: José Fonseca <jose.r.fonseca@gmail.com>
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_misc.cpp')
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 41 |
1 files changed, 33 insertions, 8 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp index dd2c612..6a560df 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; @@ -232,8 +232,9 @@ lp_set_store_alignment(LLVMValueRef Inst, #if HAVE_LLVM >= 0x301 /** - * Same as LLVMCreateJITCompilerForModule, but using MCJIT and enabling AVX - * feature where available. + * Same as LLVMCreateJITCompilerForModule, but: + * - allows using MCJIT and enabling AVX feature where available. + * - set target options * * See also: * - llvm/lib/ExecutionEngine/ExecutionEngineBindings.cpp @@ -242,20 +243,44 @@ lp_set_store_alignment(LLVMValueRef Inst, */ extern "C" LLVMBool -lp_build_create_mcjit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, - LLVMModuleRef M, - unsigned OptLevel, - char **OutError) +lp_build_create_jit_compiler_for_module(LLVMExecutionEngineRef *OutJIT, + LLVMModuleRef M, + unsigned OptLevel, + int useMCJIT, + char **OutError) { using namespace llvm; std::string Error; EngineBuilder builder(unwrap(M)); + + /** + * LLVM 3.1+ haven't more "extern unsigned llvm::StackAlignmentOverride" and + * friends for configuring code generation options, like stack alignment. + */ + TargetOptions options; +#if defined(PIPE_ARCH_X86) + options.StackAlignmentOverride = 4; + options.RealignStack = true; +#endif + +#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); + if (useMCJIT) { + builder.setUseMCJIT(true); + } llvm::SmallVector<std::string, 1> MAttrs; if (util_cpu_caps.has_avx) { |