Browse Source

cast isize to unsigned int for llvm api, add defaulted name parameter to helper.

Henry Dooley 3 years ago
parent
commit
069c05669f
2 changed files with 5 additions and 5 deletions
  1. 1 1
      src/llvm_backend.hpp
  2. 4 4
      src/llvm_backend_general.cpp

+ 1 - 1
src/llvm_backend.hpp

@@ -459,7 +459,7 @@ void lb_set_entity_from_other_modules_linkage_correctly(lbModule *other_module,
 lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type *t);
 lbValue lb_expr_untyped_const_to_typed(lbModule *m, Ast *expr, Type *t);
 bool lb_is_expr_untyped_const(Ast *expr);
 bool lb_is_expr_untyped_const(Ast *expr);
 
 
-LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment);
+LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment, char const* name = "");
 
 
 void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, unsigned alignment);
 void lb_mem_zero_ptr(lbProcedure *p, LLVMValueRef ptr, Type *type, unsigned alignment);
 
 

+ 4 - 4
src/llvm_backend_general.cpp

@@ -216,9 +216,9 @@ LLVMValueRef llvm_one(lbModule *m) {
 	return LLVMConstInt(lb_type(m, t_i32), 1, false);
 	return LLVMConstInt(lb_type(m, t_i32), 1, false);
 }
 }
 
 
-LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment) {
-	LLVMValueRef val = LLVMBuildAlloca(p->builder, llvm_type, "");
-	LLVMSetAlignment(val, alignment);
+LLVMValueRef llvm_alloca(lbProcedure *p, LLVMTypeRef llvm_type, isize alignment, char const* name) {
+	LLVMValueRef val = LLVMBuildAlloca(p->builder, llvm_type, name);
+	LLVMSetAlignment(val, cast(unsigned int)alignment);
 	LLVMPositionBuilderAtEnd(p->builder, p->curr_block->block);
 	LLVMPositionBuilderAtEnd(p->builder, p->curr_block->block);
 
 
 	return val;
 	return val;
@@ -2655,7 +2655,7 @@ lbAddr lb_add_local(lbProcedure *p, Type *type, Entity *e, bool zero_init, i32 p
 		alignment *= 2; // NOTE(bill): Just in case
 		alignment *= 2; // NOTE(bill): Just in case
 	}
 	}
 
 
-	LLVMValueRef ptr = llvm_alloca(p, llvm_type, alignment);
+	LLVMValueRef ptr = llvm_alloca(p, llvm_type, alignment, name);
 
 
 	if (!zero_init && !force_no_init) {
 	if (!zero_init && !force_no_init) {
 		// If there is any padding of any kind, just zero init regardless of zero_init parameter
 		// If there is any padding of any kind, just zero init regardless of zero_init parameter