aboutsummaryrefslogtreecommitdiff
path: root/src/stage1/ir.cpp
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2021-04-25 19:12:06 -0400
committerGitHub <noreply@github.com>2021-04-25 19:12:06 -0400
commit2fc6b347ec66650cd1702c63104fc45148658b15 (patch)
treefe102bc1693efb2d3254192ca4f0f10313ed6fd5 /src/stage1/ir.cpp
parent6f61594692af846226880e5903ad26a922014d55 (diff)
parent82f1d592fae021fcfc737e3cb6c107b325fcf1ee (diff)
downloadzig-2fc6b347ec66650cd1702c63104fc45148658b15.tar.gz
zig-2fc6b347ec66650cd1702c63104fc45148658b15.zip
Merge pull request #8616 from LemonBoy/fn-align
Function pointer alignment
Diffstat (limited to 'src/stage1/ir.cpp')
-rw-r--r--src/stage1/ir.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/stage1/ir.cpp b/src/stage1/ir.cpp
index c59f63399c..7edfe37c92 100644
--- a/src/stage1/ir.cpp
+++ b/src/stage1/ir.cpp
@@ -20659,8 +20659,12 @@ static IrInstGen *analyze_casted_new_stack(IrAnalyze *ira, IrInst* source_instr,
get_fn_frame_type(ira->codegen, fn_entry), false);
return ir_implicit_cast(ira, new_stack, needed_frame_type);
} else {
+ // XXX The stack alignment is hardcoded to 16 here and in
+ // std.Target.stack_align.
+ const uint32_t required_align = is_async_call_builtin ?
+ get_async_frame_align_bytes(ira->codegen) : 16;
ZigType *u8_ptr = get_pointer_to_type_extra(ira->codegen, ira->codegen->builtin_types.entry_u8,
- false, false, PtrLenUnknown, target_fn_align(ira->codegen->zig_target), 0, 0, false);
+ false, false, PtrLenUnknown, required_align, 0, 0, false);
ZigType *u8_slice = get_slice_type(ira->codegen, u8_ptr);
ira->codegen->need_frame_size_prefix_data = true;
return ir_implicit_cast2(ira, new_stack_src, new_stack, u8_slice);
@@ -26079,11 +26083,11 @@ static Error ir_make_type_info_value(IrAnalyze *ira, IrInst* source_instr, ZigTy
fields[0]->special = ConstValSpecialStatic;
fields[0]->type = get_builtin_type(ira->codegen, "CallingConvention");
bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.fn.fn_type_id.cc);
- // alignment: u29
+ // alignment: comptime_int
ensure_field_index(result->type, "alignment", 1);
fields[1]->special = ConstValSpecialStatic;
fields[1]->type = ira->codegen->builtin_types.entry_num_lit_int;
- bigint_init_unsigned(&fields[1]->data.x_bigint, type_entry->data.fn.fn_type_id.alignment);
+ bigint_init_unsigned(&fields[1]->data.x_bigint, get_ptr_align(ira->codegen, type_entry));
// is_generic: bool
ensure_field_index(result->type, "is_generic", 2);
bool is_generic = type_entry->data.fn.is_generic;
@@ -30095,7 +30099,7 @@ static IrInstGen *ir_align_cast(IrAnalyze *ira, IrInstGen *target, uint32_t alig
fn_type_id.alignment = align_bytes;
result_type = get_fn_type(ira->codegen, &fn_type_id);
} else if (target_type->id == ZigTypeIdAnyFrame) {
- if (align_bytes >= target_fn_align(ira->codegen->zig_target)) {
+ if (align_bytes >= get_async_frame_align_bytes(ira->codegen)) {
result_type = target_type;
} else {
ir_add_error(ira, &target->base, buf_sprintf("sub-aligned anyframe not allowed"));