diff options
| author | gingerBill <bill@gingerbill.org> | 2021-06-06 16:34:51 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-06-06 16:34:51 +0100 |
| commit | 89890d7900cbb2580d47938a27103eb99e9d3549 (patch) | |
| tree | 4f82ff68cc4a7b3e03a8b9fd4cf39776238c62e5 /src/types.cpp | |
| parent | 661fcad895c5bfec307a3405e5dade46f4ced701 (diff) | |
Correct union tag size for large alignments
Diffstat (limited to 'src/types.cpp')
| -rw-r--r-- | src/types.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/types.cpp b/src/types.cpp index d6d4c943c..04ac31a01 100644 --- a/src/types.cpp +++ b/src/types.cpp @@ -2208,7 +2208,6 @@ i64 union_tag_size(Type *u) { return 0; } -#if 1 // TODO(bill): Is this an okay approach? i64 max_align = 1; for_array(i, u->Union.variants) { @@ -2219,15 +2218,8 @@ i64 union_tag_size(Type *u) { } } - u->Union.tag_size = gb_min(max_align, build_context.max_align); - return max_align; -#else - i64 bytes = next_pow2(cast(i64)(floor_log2(n)/8 + 1)); - i64 tag_size = gb_max(bytes, 1); - - u->Union.tag_size = tag_size; - return tag_size; -#endif + u->Union.tag_size = gb_min3(max_align, build_context.max_align, 8); + return u->Union.tag_size; } Type *union_tag_type(Type *u) { |