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);
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);