Closed leongross closed 1 week ago
@aykevl @deadprogram
ci failure looks like windows race condition again ...
As discussed on Slack, this change looks correct.
ci failure looks like windows race condition again ...
I've restarted the build. Hopefully it'll pass now (also, this PR doesn't affect Windows so it'd be safe to merge even with the failure IMHO).
Except (obviously) for the addresses
That doesn't seem obvious to me? If the addresses are different, it means there is a difference in some other part of the binary. This could very well be because with this change, the compiler is allowed to keep a few more registers alive across the syscall, which probably means more efficient code. So entirely expected.
Also, to be pedantic, the fact that the code in one example is the same doesn't necessarily mean the change is correct: I've seen weird edge cases where code would work correctly in most cases but have a few cases where wrong code was generated due to a subtle bug in the inline assembly.
Also, to be pedantic, the fact that the code in one example is the same doesn't necessarily mean the change is correct: I've seen weird edge cases where code would work correctly in most cases but have a few cases where wrong code was generated due to a subtle bug in the inline assembly.
You are totally right with this. However, I am not quite sure how to systematically test the code generation behavior in an efficient way. If you have any suggestions I'd be glad to help you out with that, but atm I don't see any.
I tried to compile your example program with and without this change on linux/amd64 and the produced binary is exactly identical. Are you sure about the diff you were seeing?
$ md5sum test*.elf
d1017e8996b9e4d08611cf06bc42933c test1.elf
d1017e8996b9e4d08611cf06bc42933c test2.elf
(I used llvm-objdump to look at the binary, but since the files are identical there won't be a difference).
My build command looks like this (because I'm on linux/arm64):
GOARCH=amd64 tinygo build -o test1.elf ./tmp/pr4301.go
In any case, I think this is a safe change.
Thank you for the PR @leongross and to @aykevl for review.
A short analysis of my findings:
Except (obviously) for the addresses, the generated assembly code is the same.
Two key points might be important: