Browse Source

Fix untyped ternary string IR conversion

gingerBill 6 years ago
parent
commit
dbd0638853
2 changed files with 10 additions and 1 deletions
  1. 2 0
      core/mem/allocators.odin
  2. 8 1
      src/ir.cpp

+ 2 - 0
core/mem/allocators.odin

@@ -381,6 +381,8 @@ small_stack_allocator_proc :: proc(allocator_data: rawptr, mode: Allocator_Mode,
 		return nil;
 	}
 
+	alignment = clamp(alignment, 1, 8*size_of(Stack_Allocation_Header{}.padding)/2);
+
 	raw_alloc :: proc(s: ^Small_Stack, size, alignment: int) -> rawptr {
 		curr_addr := uintptr(&s.data[0]) + uintptr(s.offset);
 		padding := calc_padding_with_header(curr_addr, uintptr(alignment), size_of(Small_Stack_Allocation_Header));

+ 8 - 1
src/ir.cpp

@@ -4644,6 +4644,7 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
 	}
 
 
+
 	// bool <-> llvm bool
 	if (is_type_boolean(src) && dst == t_llvm_bool) {
 		return ir_emit(proc, ir_instr_conv(proc, irConv_trunc, value, src_type, t));
@@ -4906,7 +4907,13 @@ irValue *ir_emit_conv(irProcedure *proc, irValue *value, Type *t) {
 		return ir_emit_load(proc, result);
 	}
 
-
+	if (is_type_untyped(src)) {
+		if (is_type_string(src) && is_type_string(dst)) {
+			irValue *result = ir_add_local_generated(proc, t, false);
+			ir_emit_store(proc, result, value);
+			return ir_emit_load(proc, result);
+		}
+	}
 
 	gb_printf_err("ir_emit_conv: src -> dst\n");
 	gb_printf_err("Not Identical %s != %s\n", type_to_string(src_type), type_to_string(t));