diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-09-14 13:54:33 -0400 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2018-09-14 13:55:45 -0400 |
| commit | 639c3811288b65173b3d9706b8e2001ee2419233 (patch) | |
| tree | 7c800c2e3853280c2eafd44d0456feb4096e0b4f /src/analyze.cpp | |
| parent | 82af31ce368d16cc5cadac80faa3d8a4d4b1f752 (diff) | |
| download | zig-639c3811288b65173b3d9706b8e2001ee2419233.tar.gz zig-639c3811288b65173b3d9706b8e2001ee2419233.zip | |
fix coroutine alignment
zig returned the wrong alignment for coroutine promises
in some cases
Diffstat (limited to 'src/analyze.cpp')
| -rw-r--r-- | src/analyze.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/analyze.cpp b/src/analyze.cpp index 9af4f7347c..d403433c5c 100644 --- a/src/analyze.cpp +++ b/src/analyze.cpp @@ -3953,14 +3953,14 @@ bool type_is_codegen_pointer(ZigType *type) { return get_codegen_ptr_type(type) == type; } -uint32_t get_ptr_align(ZigType *type) { +uint32_t get_ptr_align(CodeGen *g, ZigType *type) { ZigType *ptr_type = get_codegen_ptr_type(type); if (ptr_type->id == ZigTypeIdPointer) { return ptr_type->data.pointer.alignment; } else if (ptr_type->id == ZigTypeIdFn) { return (ptr_type->data.fn.fn_type_id.alignment == 0) ? 1 : ptr_type->data.fn.fn_type_id.alignment; } else if (ptr_type->id == ZigTypeIdPromise) { - return 1; + return get_coro_frame_align_bytes(g); } else { zig_unreachable(); } @@ -6277,10 +6277,6 @@ uint32_t get_abi_alignment(CodeGen *g, ZigType *type_entry) { return 1; } else { uint32_t llvm_alignment = LLVMABIAlignmentOfType(g->target_data_ref, type_entry->type_ref); - // promises have at least alignment 8 so that we can have 3 extra bits when doing atomicrmw - if (type_entry->id == ZigTypeIdPromise && llvm_alignment < 8) { - return 8; - } return llvm_alignment; } } @@ -6318,7 +6314,10 @@ bool type_is_global_error_set(ZigType *err_set_type) { } uint32_t get_coro_frame_align_bytes(CodeGen *g) { - return g->pointer_size_bytes * 2; + uint32_t a = g->pointer_size_bytes * 2; + // promises have at least alignment 8 so that we can have 3 extra bits when doing atomicrmw + if (a < 8) a = 8; + return a; } bool type_can_fail(ZigType *type_entry) { |
