authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-28 12:32:39-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-28 12:32:39-05:00
loge0000c47bd22c7b351247b72a85ca26c1c2ada96
treeb90f6afb040e5dbe4d65f7f17ea76d469a36f6c7
parent5c55a9b4e8d6d1f5ee3548cf8033e7e69951b308
signature Commit is signed but in an unrecognized format.

fix regression of storing optional with 0-bit payload


2 files changed, 8 insertions(+), 2 deletions(-)

src/codegen.cpp+4
...@@ -4731,6 +4731,10 @@ static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutableGen *e...@@ -4731,6 +4731,10 @@ static LLVMValueRef ir_render_optional_unwrap_ptr(CodeGen *g, IrExecutableGen *e
4731 LLVMPositionBuilderAtEnd(g->builder, ok_block);4731 LLVMPositionBuilderAtEnd(g->builder, ok_block);
4732 }4732 }
4733 if (!type_has_bits(child_type)) {4733 if (!type_has_bits(child_type)) {
4734 if (instruction->initializing) {
4735 LLVMValueRef non_null_bit = LLVMConstInt(LLVMInt1Type(), 1, false);
4736 gen_store_untyped(g, non_null_bit, base_ptr, 0, false);
4737 }
4734 return nullptr;4738 return nullptr;
4735 } else {4739 } else {
4736 bool is_scalar = !handle_is_ptr(maybe_type);4740 bool is_scalar = !handle_is_ptr(maybe_type);
src/ir.cpp+4-2
...@@ -10402,6 +10402,7 @@ static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *ex...@@ -10402,6 +10402,7 @@ static Error ir_exec_scan_for_side_effects(CodeGen *codegen, IrExecutableGen *ex
10402 if (instr_is_comptime(instruction)) {10402 if (instr_is_comptime(instruction)) {
10403 switch (instruction->id) {10403 switch (instruction->id) {
10404 case IrInstGenIdUnwrapErrPayload:10404 case IrInstGenIdUnwrapErrPayload:
10405 case IrInstGenIdOptionalUnwrapPtr:
10405 case IrInstGenIdUnionFieldPtr:10406 case IrInstGenIdUnionFieldPtr:
10406 continue;10407 continue;
10407 default:10408 default:
...@@ -18671,7 +18672,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr...@@ -18671,7 +18672,7 @@ static IrInstGen *ir_resolve_result(IrAnalyze *ira, IrInst *suspend_source_instr
18671 {18672 {
18672 bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);18673 bool same_comptime_repr = types_have_same_zig_comptime_repr(ira->codegen, actual_elem_type, value_type);
18673 if (!same_comptime_repr) {18674 if (!same_comptime_repr) {
18674 result_loc_pass1->written = false;18675 result_loc_pass1->written = was_written;
18675 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);18676 return ir_analyze_unwrap_optional_payload(ira, suspend_source_instr, result_loc, false, true);
18676 }18677 }
18677 } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) {18678 } else if (actual_elem_type->id == ZigTypeIdErrorUnion && value_type->id != ZigTypeIdErrorUnion) {
...@@ -29971,7 +29972,6 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {...@@ -29971,7 +29972,6 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {
29971 case IrInstGenIdReturnPtr:29972 case IrInstGenIdReturnPtr:
29972 case IrInstGenIdStructFieldPtr:29973 case IrInstGenIdStructFieldPtr:
29973 case IrInstGenIdTestNonNull:29974 case IrInstGenIdTestNonNull:
29974 case IrInstGenIdOptionalUnwrapPtr:
29975 case IrInstGenIdClz:29975 case IrInstGenIdClz:
29976 case IrInstGenIdCtz:29976 case IrInstGenIdCtz:
29977 case IrInstGenIdPopCount:29977 case IrInstGenIdPopCount:
...@@ -30028,6 +30028,8 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {...@@ -30028,6 +30028,8 @@ bool ir_inst_gen_has_side_effects(IrInstGen *instruction) {
30028 return reinterpret_cast<IrInstGenUnwrapErrCode *>(instruction)->initializing;30028 return reinterpret_cast<IrInstGenUnwrapErrCode *>(instruction)->initializing;
30029 case IrInstGenIdUnionFieldPtr:30029 case IrInstGenIdUnionFieldPtr:
30030 return reinterpret_cast<IrInstGenUnionFieldPtr *>(instruction)->initializing;30030 return reinterpret_cast<IrInstGenUnionFieldPtr *>(instruction)->initializing;
30031 case IrInstGenIdOptionalUnwrapPtr:
30032 return reinterpret_cast<IrInstGenOptionalUnwrapPtr *>(instruction)->initializing;
30031 case IrInstGenIdErrWrapPayload:30033 case IrInstGenIdErrWrapPayload:
30032 return reinterpret_cast<IrInstGenErrWrapPayload *>(instruction)->result_loc != nullptr;30034 return reinterpret_cast<IrInstGenErrWrapPayload *>(instruction)->result_loc != nullptr;
30033 case IrInstGenIdErrWrapCode:30035 case IrInstGenIdErrWrapCode: