aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm/lp_bld_flow.c
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2010-05-08 13:02:46 +0100
committerJosé Fonseca <[email protected]>2010-05-08 13:02:46 +0100
commit36e28d42b3e6212bf0cbcbb363ddf822c8d8f5cc (patch)
tree859c6b89f49be9c07e32e05712b83fb727ae7b44 /src/gallium/auxiliary/gallivm/lp_bld_flow.c
parent2c2debaea71eb99322c2371f1c581e9748cda91f (diff)
gallivm: Fix segfaul when inserting allocas in an empty function.
Diffstat (limited to 'src/gallium/auxiliary/gallivm/lp_bld_flow.c')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_flow.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_flow.c b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
index 8f15b1d287d..560ce1de73f 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_flow.c
+++ b/src/gallium/auxiliary/gallivm/lp_bld_flow.c
@@ -821,8 +821,11 @@ lp_build_alloca(LLVMBuilderRef builder,
LLVMBuilderRef first_builder = LLVMCreateBuilder();
LLVMValueRef res;
- LLVMPositionBuilderAtEnd(first_builder, first_block);
- LLVMPositionBuilderBefore(first_builder, first_instr);
+ if (first_instr) {
+ LLVMPositionBuilderBefore(first_builder, first_instr);
+ } else {
+ LLVMPositionBuilderAtEnd(first_builder, first_block);
+ }
res = LLVMBuildAlloca(first_builder, type, name);
@@ -859,7 +862,11 @@ lp_build_array_alloca(LLVMBuilderRef builder,
LLVMBuilderRef first_builder = LLVMCreateBuilder();
LLVMValueRef res;
- LLVMPositionBuilderBefore(first_builder, first_instr);
+ if (first_instr) {
+ LLVMPositionBuilderBefore(first_builder, first_instr);
+ } else {
+ LLVMPositionBuilderAtEnd(first_builder, first_block);
+ }
res = LLVMBuildArrayAlloca(first_builder, type, count, name);