authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-12 13:49:57-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-06-12 13:49:57-04:00
log35352e0f489882b9d5919ffd569e7dcda990f39b
treea4eba9b0275509a44d7b3fb5f919cbbbdb836920
parent278c7a2bc398ac71afc9b9b392e863a758abb5fd
signature Commit is signed but in an unrecognized format.

fix alignment problem with `@bitCast` result location


1 files changed, 13 insertions(+), 1 deletions(-)

src/ir.cpp+13-1
...@@ -14812,6 +14812,7 @@ static bool type_can_bit_cast(ZigType *t) {...@@ -14812,6 +14812,7 @@ static bool type_can_bit_cast(ZigType *t) {
14812static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr,14812static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_source_instr,
14813 ResultLoc *result_loc, ZigType *value_type, IrInstruction *value)14813 ResultLoc *result_loc, ZigType *value_type, IrInstruction *value)
14814{14814{
14815 Error err;
14815 if (result_loc->resolved_loc != nullptr) {14816 if (result_loc->resolved_loc != nullptr) {
14816 // allow to redo the result location if the value is known and comptime and the previous one isn't14817 // allow to redo the result location if the value is known and comptime and the previous one isn't
14817 if (value == nullptr || !instr_is_comptime(value) || instr_is_comptime(result_loc->resolved_loc)) {14818 if (value == nullptr || !instr_is_comptime(value) || instr_is_comptime(result_loc->resolved_loc)) {
...@@ -14962,7 +14963,18 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s...@@ -14962,7 +14963,18 @@ static IrInstruction *ir_resolve_result(IrAnalyze *ira, IrInstruction *suspend_s
14962 {14963 {
14963 return parent_result_loc;14964 return parent_result_loc;
14964 }14965 }
14965 ZigType *ptr_type = get_pointer_to_type(ira->codegen, value_type, false);14966 ZigType *parent_ptr_type = parent_result_loc->value.type;
14967 assert(parent_ptr_type->id == ZigTypeIdPointer);
14968 if ((err = type_resolve(ira->codegen, parent_ptr_type->data.pointer.child_type,
14969 ResolveStatusAlignmentKnown)))
14970 {
14971 return ira->codegen->invalid_instruction;
14972 }
14973 uint64_t parent_ptr_align = get_ptr_align(ira->codegen, parent_ptr_type);
14974 ZigType *ptr_type = get_pointer_to_type_extra(ira->codegen, value_type,
14975 parent_ptr_type->data.pointer.is_const, parent_ptr_type->data.pointer.is_volatile, PtrLenSingle,
14976 parent_ptr_align, 0, 0, parent_ptr_type->data.pointer.allow_zero);
14977
14966 result_loc->written = true;14978 result_loc->written = true;
14967 result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc,14979 result_loc->resolved_loc = ir_analyze_ptr_cast(ira, suspend_source_instr, parent_result_loc,
14968 ptr_type, result_bit_cast->base.source_instruction, false);14980 ptr_type, result_bit_cast->base.source_instruction, false);