diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-03-01 18:24:00 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-03-01 18:24:00 -0700 |
| commit | 6f303c01f3e06fe8203563065ea32537f6eff456 (patch) | |
| tree | c1e85221ff40bfd5be043a6f7429e2b3e4d94024 /test/behavior/struct.zig | |
| parent | 8878f085dccaf9efe89a04b458205fddc215e095 (diff) | |
| download | zig-6f303c01f3e06fe8203563065ea32537f6eff456.tar.gz zig-6f303c01f3e06fe8203563065ea32537f6eff456.zip | |
LLVM: add extra padding to structs and tuples sometimes
* Sema: resolve type fully when emitting an alloc AIR instruction to
avoid tripping assertion for checking struct field alignment.
* LLVM backend: keep a reference to the LLVM target data alive during
lowering so that we can ask LLVM what it thinks the ABI alignment
and size of LLVM types are. We need this in order to lower tuples and
structs so that we can put in extra padding bytes when Zig disagrees
with LLVM about the size or alignment of something.
* LLVM backend: make the LLVM struct type packed that contains the most
aligned union field and the padding. This prevents the struct from
being too big according to LLVM. In the future, we may want to
consider instead emitting unions in a "flat" manner; putting the tag,
most aligned union field, and padding all in the same struct field
space.
* LLVM backend: make structs with 2 or fewer fields return isByRef=false.
This results in more efficient codegen. This required lowering of
bitcast to sometimes store the struct into an alloca, ptrcast, and
then load because LLVM does not allow bitcasting structs.
* enable more passing behavior tests.
Diffstat (limited to 'test/behavior/struct.zig')
| -rw-r--r-- | test/behavior/struct.zig | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/test/behavior/struct.zig b/test/behavior/struct.zig index 13fe0820ce..20123e8014 100644 --- a/test/behavior/struct.zig +++ b/test/behavior/struct.zig @@ -857,7 +857,9 @@ test "fn with C calling convention returns struct by value" { } test "non-packed struct with u128 entry in union" { - if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_x86_64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO const U = union(enum) { Num: u128, @@ -952,7 +954,9 @@ test "fully anonymous struct" { } test "fully anonymous list literal" { - if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_c) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_arm) return error.SkipZigTest; // TODO + if (builtin.zig_backend == .stage2_aarch64) return error.SkipZigTest; // TODO const S = struct { fn doTheTest() !void { |
