From e9bf09a98a624e594bdea2503326bb693b8cf9b8 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Fri, 30 Apr 2010 19:00:58 +0100 Subject: draw: Fix memory leaks in llvm code. --- src/gallium/auxiliary/draw/draw_llvm.c | 2 ++ .../draw/draw_pt_fetch_shade_pipeline_llvm.c | 24 ++++++++++++++++++++++ 2 files changed, 26 insertions(+) (limited to 'src/gallium/auxiliary/draw') diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 3b2df054c3c..2c234285b5e 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -207,6 +207,8 @@ draw_llvm_create(struct draw_context *draw) void draw_llvm_destroy(struct draw_llvm *llvm) { + LLVMDisposePassManager(llvm->pass); + FREE(llvm); } diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index d2a492f2b4c..35913a59951 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -349,7 +349,31 @@ static void llvm_middle_end_finish( struct draw_pt_middle_end *middle ) static void llvm_middle_end_destroy( struct draw_pt_middle_end *middle ) { struct llvm_middle_end *fpme = (struct llvm_middle_end *)middle; + struct draw_context *draw = fpme->draw; + struct draw_llvm_variant *variant = NULL; + + variant = fpme->variants; + while(variant) { + struct draw_llvm_variant *next = variant->next; + if (variant->function_elts) { + if (variant->function_elts) + LLVMFreeMachineCodeForFunction(draw->engine, + variant->function_elts); + LLVMDeleteFunction(variant->function_elts); + } + + if (variant->function) { + if (variant->function) + LLVMFreeMachineCodeForFunction(draw->engine, + variant->function); + LLVMDeleteFunction(variant->function); + } + + FREE(variant); + + variant = next; + } if (fpme->fetch) draw_pt_fetch_destroy( fpme->fetch ); -- cgit v1.2.3 From d44c8ee568878899e4ce5d8e1d0fcf523aa62199 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 09:53:12 +0100 Subject: draw: Disable rtasm compilation when using LLVM. Saves time and trouble. --- src/gallium/auxiliary/draw/draw_vs.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/gallium/auxiliary/draw') diff --git a/src/gallium/auxiliary/draw/draw_vs.c b/src/gallium/auxiliary/draw/draw_vs.c index c2832eefa2a..b9db886a24d 100644 --- a/src/gallium/auxiliary/draw/draw_vs.c +++ b/src/gallium/auxiliary/draw/draw_vs.c @@ -85,18 +85,22 @@ struct draw_vertex_shader * draw_create_vertex_shader(struct draw_context *draw, const struct pipe_shader_state *shader) { - struct draw_vertex_shader *vs; + struct draw_vertex_shader *vs = NULL; if (draw->dump_vs) { tgsi_dump(shader->tokens, 0); } - vs = draw_create_vs_sse( draw, shader ); - if (!vs) { + if (!draw->pt.middle.llvm) { +#if defined(PIPE_ARCH_X86) + vs = draw_create_vs_sse( draw, shader ); +#elif defined(PIPE_ARCH_PPC) vs = draw_create_vs_ppc( draw, shader ); - if (!vs) { - vs = draw_create_vs_exec( draw, shader ); - } +#endif + } + + if (!vs) { + vs = draw_create_vs_exec( draw, shader ); } if (vs) -- cgit v1.2.3 From caede7528d2afad478c49afb98eb96088e1c41cc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 3 May 2010 12:15:32 +0100 Subject: draw: Remove draw_pt_fetch_prepare call from llvm middle end. Unneeded since we code generate the vertex fecthes. --- .../auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'src/gallium/auxiliary/draw') diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 35913a59951..6d00b0fbd44 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -66,7 +66,6 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle, struct llvm_middle_end *fpme = (struct llvm_middle_end *)middle; struct draw_context *draw = fpme->draw; struct draw_vertex_shader *vs = draw->vs.vertex_shader; - struct draw_geometry_shader *gs = draw->gs.geometry_shader; struct draw_llvm_variant_key key; struct draw_llvm_variant *variant = NULL; unsigned i; @@ -97,17 +96,6 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle, fpme->vertex_size = sizeof(struct vertex_header) + nr * 4 * sizeof(float); - - draw_pt_fetch_prepare( fpme->fetch, - vs->info.num_inputs, - fpme->vertex_size, - instance_id_index ); - if (opt & PT_SHADE) { - vs->prepare(vs, draw); - draw_geometry_shader_prepare(gs, draw); - } - - /* XXX: it's not really gl rasterization rules we care about here, * but gl vs dx9 clip spaces. */ -- cgit v1.2.3 From 15af543f106db9e6ff840828905df4978e68f715 Mon Sep 17 00:00:00 2001 From: Török Edwin Date: Mon, 3 May 2010 07:43:03 -0700 Subject: Reorder LLVM passes, running mem2reg earlier. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This gives a ~30% shader optimization time improvement on blender. Tested by comparing the dumped LLVM modules. Current ordering: time ~/llvm-git/obj/Release-Asserts/bin/opt l.bc -constprop -instcombine -mem2reg -gvn -simplifycfg real 0m1.126s user 0m1.108s sys 0m0.012s With this patch: time ~/llvm-git/obj/Release-Asserts/bin/opt l.bc -mem2reg -constprop -instcombine -gvn -simplifycfg real 0m0.885s user 0m0.880s sys 0m0.000s The overall improvement in blender is ~15%. Blender without the patch takes 1m13s: edwin 5934 87.6 11.5 729440 458296 pts/5 SLl+ 17:35 1:13 blender Blender with the patch takes 1m3s: edwin 5726 94.2 11.2 716424 446168 pts/5 SLl+ 17:32 1:03 blender It is still slow with the patch, but better (most of the optimization time is taken up by GVN, see LLVM PR7023). Signed-off-by: Török Edwin Signed-off-by: José Fonseca --- src/gallium/auxiliary/draw/draw_llvm.c | 4 ++-- src/gallium/drivers/llvmpipe/lp_jit.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium/auxiliary/draw') diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 2c234285b5e..ea9b7c90a51 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -182,6 +182,8 @@ draw_llvm_create(struct draw_context *draw) /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, * but there are more on SVN. */ /* TODO: Add more passes */ + LLVMAddCFGSimplificationPass(llvm->pass); + LLVMAddPromoteMemoryToRegisterPass(llvm->pass); LLVMAddConstantPropagationPass(llvm->pass); if(util_cpu_caps.has_sse4_1) { /* FIXME: There is a bug in this pass, whereby the combination of fptosi @@ -190,9 +192,7 @@ draw_llvm_create(struct draw_context *draw) */ LLVMAddInstructionCombiningPass(llvm->pass); } - LLVMAddPromoteMemoryToRegisterPass(llvm->pass); LLVMAddGVNPass(llvm->pass); - LLVMAddCFGSimplificationPass(llvm->pass); init_globals(llvm); diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index 466a2f54fbe..30e206a2b42 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -185,6 +185,8 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) /* These are the passes currently listed in llvm-c/Transforms/Scalar.h, * but there are more on SVN. */ /* TODO: Add more passes */ + LLVMAddCFGSimplificationPass(screen->pass); + LLVMAddPromoteMemoryToRegisterPass(screen->pass); LLVMAddConstantPropagationPass(screen->pass); if(util_cpu_caps.has_sse4_1) { /* FIXME: There is a bug in this pass, whereby the combination of fptosi @@ -193,9 +195,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) */ LLVMAddInstructionCombiningPass(screen->pass); } - LLVMAddPromoteMemoryToRegisterPass(screen->pass); LLVMAddGVNPass(screen->pass); - LLVMAddCFGSimplificationPass(screen->pass); } lp_jit_init_globals(screen); -- cgit v1.2.3