-
Notifications
You must be signed in to change notification settings - Fork 211
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
Use wrapping pointer arithmetic in mem/impls.rs #713
Conversation
Add a comment (and fix a typo)
For reference we have some benchmarks in https://github.com/rust-lang/compiler-builtins/blob/cb060052ab7e4bad408c85d44be7e60096e93e38/testcrate/benches/mem.rs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with having this workaround.
With this PR:
With read_volatile/write_volatile:
There are no significant differences, but I'd still rather not use volatile in here because it just seems like overkill, and I wouldn't be shocked if my nice x86_64 CPU is compensating for the codegen regression in microbenchmarks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the results, I don’t think there is any reason not to do this change if it helps the copy-to-end situation.
rust-lang/rust can bump to 0.1.134 after #714 merges |
#714 is now merged :) |
Posted rust-lang/rust#131907 |
…=aDotInTheVoid Update `compiler-builtins` to 0.1.134 I'm modeling this PR after rust-lang#131314. This pulls in rust-lang/compiler-builtins#713 which should mitigate the problem reported and discussed in https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Hello.20World.20on.20sparc-unknown-none-elf.20crashes
…=tgross35 Update `compiler-builtins` to 0.1.134 I'm modeling this PR after rust-lang#131314. This pulls in rust-lang/compiler-builtins#713 which should mitigate the problem reported and discussed in https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Hello.20World.20on.20sparc-unknown-none-elf.20crashes
Update `compiler-builtins` to 0.1.134 I'm modeling this PR after rust-lang/rust#131314. This pulls in rust-lang/compiler-builtins#713 which should mitigate the problem reported and discussed in https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Hello.20World.20on.20sparc-unknown-none-elf.20crashes
@Amanieu you suggested wrapping arithmetic and volatile loads/stores. Some quick experimentation indicates that volatile loads/stores do indeed have an optimization impact, but wrapping pointer arithmetic maybe doesn't: https://godbolt.org/z/Y8MP46dEE
Also, since these intrinsics (i.e.
memcpy
) are well-known to the compiler, I suspect that if a compiler is going to optimize out a read/write to the last byte in address space, it'll do that by analyzing the call site of thememcpy
and not consider whether or not the implementation is full of volatiles. So I suspect using volatiles in here would be dubious benefit for making the Rust toolchain do what our users want to use it for, and probably inflict a slowdown on everyone using compiler-builtins with optimizations enabled.