Module: Mesa
Branch: master
Commit: 012fabca722494162c244a367913562b8cfa4677
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=012fabca722494162c244a367913562b8cfa4677

Author: Zack Rusin <za...@vmware.com>
Date:   Mon Mar 29 16:17:17 2010 -0400

gallivm: make sure that the alloca's are the very first thing in the function

otherwise mem2reg can't put them in registers

---

 src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c |   20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c 
b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
index f160be8..95cd6a0 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c
@@ -651,6 +651,19 @@ emit_declaration(
    unsigned first = decl->Range.First;
    unsigned last = decl->Range.Last;
    unsigned idx, i;
+   LLVMBasicBlockRef current_block =
+      LLVMGetInsertBlock(bld->base.builder);
+   LLVMBasicBlockRef first_block =
+      LLVMGetEntryBasicBlock(
+         LLVMGetBasicBlockParent(current_block));
+   LLVMValueRef first_inst =
+      LLVMGetFirstInstruction(first_block);
+
+   /* we want alloca's to be the first instruction
+    * in the function so we need to rewind the builder
+    * to the very beginning */
+   LLVMPositionBuilderBefore(bld->base.builder,
+                             first_inst);
 
    for (idx = first; idx <= last; ++idx) {
       boolean ok;
@@ -673,10 +686,15 @@ emit_declaration(
          ok = TRUE;
       }
 
-      if (!ok)
+      if (!ok) {
+         LLVMPositionBuilderAtEnd(bld->base.builder,
+                                  current_block);
          return FALSE;
+      }
    }
 
+   LLVMPositionBuilderAtEnd(bld->base.builder,
+                            current_block);
    return TRUE;
 }
 

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to