-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple stores generated for writes to volatile packed struct(u32) #17119
Comments
I'm running into a similar issue, however here with 0.11.0 neither Starting with commit 8b91611 onwards the issue is only triggered when var value: u32 = 42;
const register: *volatile packed union {
fields: packed struct(u32) {
foo: bool = false,
_1: u3 = 0,
_2: u4 = 0,
bar: bool = false,
_3: u3 = 0,
baz: bool = false,
_6: u19 = 0,
},
value: u32,
} = @ptrCast(&value);
export fn _start() void {
register.fields = .{ .foo = true, .bar = true };
}
Adding Using a temporary variable does not trigger the issue: export fn _start() void {
const fields = .{ .foo = true, .bar = true };
register.fields = fields;
} |
… with `-fstrip` The first instruction in the block was never checked resulting in `struct_is_comptime` being incorrectly cleared if there are no instructions before the first field of the comptime struct. Fixes ziglang#17119
…th `-fstrip` The first instruction in the block was never checked resulting in `struct_is_comptime` being incorrectly cleared if there are no instructions before the first field of the comptime struct. Fixes ziglang#17119
…th `-fstrip` The first instruction in the block was never checked resulting in `struct_is_comptime` being incorrectly cleared if there are no instructions before the first field of the comptime struct. Fixes #17119
Zig Version
0.11.0
Steps to Reproduce and Observed Behavior
When compiling with
-O ReleaseSmall -target thumb-freestanding-none
, strange stores are generated when writing to a volatile packed struct. This behavior seems to be related to-fstrip
somehow, because the expected output is correctly generated with-fno-strip
or-O ReleaseFast
The output can be seen in godbolt here.
Given the following source:
The resulting assembly is:
This seems to be generating a bit clear and a store for each field in the struct.
Expected Behavior
When compiling with
-fno-strip
the following assembly is generated:This is the expected output.
The text was updated successfully, but these errors were encountered: