Skip to content
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

@memset undefined not optimized out #14094

Closed
silversquirl opened this issue Dec 28, 2022 · 1 comment · Fixed by #15278
Closed

@memset undefined not optimized out #14094

silversquirl opened this issue Dec 28, 2022 · 1 comment · Fixed by #15278
Labels
bug Observed behavior contradicts documented or intended behavior optimization regression It worked in a previous version of Zig, but stopped working.
Milestone

Comments

@silversquirl
Copy link
Contributor

Zig Version

0.11.0-dev.960+af9a9a137

Steps to Reproduce and Observed Behavior

// test.zig
export fn foo(x: [*]u8, l: usize) void {
    @memset(x, undefined, l);
}
$ zig build-obj -OReleaseFast test.zig && objdump -d test.o

test.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <foo>:
   0:	48 89 f2             	mov    %rsi,%rdx
   3:	be aa 00 00 00       	mov    $0xaa,%esi
   8:	e9 00 00 00 00       	jmpq   d <foo+0xd>

Expected Behavior

$ zig build-obj -OReleaseFast test.zig && objdump -d test.o

test.o:     file format elf64-x86-64


Disassembly of section .text:

0000000000000000 <foo>:
   0:	c3                   	retq
@silversquirl silversquirl added the bug Observed behavior contradicts documented or intended behavior label Dec 28, 2022
@silversquirl
Copy link
Contributor Author

This is a regression in stage2; -fstage1 in 0.10 emits the desired (lack of) code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior optimization regression It worked in a previous version of Zig, but stopped working.
Projects
None yet
2 participants