-
Notifications
You must be signed in to change notification settings - Fork 151
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
Missing case of compile-time constant folding #547
Comments
(Note that I haven't checked what generally we're doing with respect to compile-time constant folding.) |
I think the bug isn't necessarily to do with constant folding in the front-end. I think it is because of the missing: #241 Currently when we define a method with &self the reference part of the type is currently ignored since we need to support #434 as part of that in the type system. Its something I was going to be working on this month. I was able to verify this by testing a similar c++ piece of code that GCC will optimize this but from that example in rust our gimple dump shows:
|
Unlike LLVM, GCC doesn't assume |
Also it looks like there might be another bug since its referencing usize here not u64 |
Found the bug with the gimple reference to 'usize' it was a bad call to named_type to give the integer type a relevant name in gimple land. The underlying integer type was correct but the name was bad. |
548: Fix bad naming of primitive types such as u64 which ended up as usize r=philberty a=philberty In #547 it was found that u64's ended up as usize in gimple which confuses debugging sessions. This take the original implementation of named type from gccgo showing it was the TYPE_NAME tree getting confused. Addresses #547 Co-authored-by: Philip Herron <philip.herron@embecosm.com>
Found the issue is here: https://github.com/Rust-GCC/gccrs/blob/master/gcc/rust/rust-gcc.cc#L3373-L3374 We need to explicitly set function_is_inlinable flags other wise the rust-gcc.cc wrapper ensures that this function is un-inlinable. I think it makes sense being able to turn this on and off, so lets make the flags default allow for inlining |
We are reusing a forked version of the GCC wrapper from the go front-end, if we do not specify that a function is inlineable, this marks the function as DECL_UNINLINABLE which means we miss alot of optimization opertunities. Fixes #547
The example code https://godbolt.org/z/8o74c57Yj (via https://lkml.org/lkml/2021/7/4/171, via https://gcc-rust.zulipchat.com/#narrow/stream/266897-general/topic/Rust.20for.20Linux.20RFC.3A.20Another.20mention.20of.20GCC-RS) shows a missing case of compile-time constant folding.
At this time, we produce (see gccrs-snapshot tab):
..., whereas
rustc 1.53.0
produces:The text was updated successfully, but these errors were encountered: