Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upMissoptimization of functions with C calling convention #33868
Comments
This comment has been minimized.
This comment has been minimized.
|
Which target is this for? There are multiple calling conventions across operating systems and architectures after all. |
This comment has been minimized.
This comment has been minimized.
|
This is on x86_64-unknown-linux-gnu. |
This comment has been minimized.
This comment has been minimized.
|
I can confirm this for |
nagisa
added
the
regression-from-stable-to-beta
label
May 25, 2016
This comment has been minimized.
This comment has been minimized.
|
Works on stable. |
This comment has been minimized.
This comment has been minimized.
|
cc @eddyb could it be your call trans refactor? |
This comment has been minimized.
This comment has been minimized.
|
Seems like we invoke some UB: ; Function Attrs: noinline norecurse nounwind readnone uwtable
define i32 @test({ i64, i64 }) unnamed_addr #0 {
entry-block:
ret i32 undef
}is what the function ends up being optimised to. |
nagisa
added
I-wrong
A-ffi
labels
May 25, 2016
This comment has been minimized.
This comment has been minimized.
|
This is what I managed to reduce the issue to. |
This comment has been minimized.
This comment has been minimized.
|
This suffices: #[no_mangle]
pub extern "C" fn test(s: S) -> u32 {
s.c
}Bad IR:
|
This comment has been minimized.
This comment has been minimized.
|
The old, working functionality uses a shim:
|
This comment has been minimized.
This comment has been minimized.
|
We are storing 16 bytes of data in a 12-byte bag and that is killing us. |
This comment has been minimized.
This comment has been minimized.
|
For the reference, |
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis
added
the
P-high
label
May 25, 2016
This comment has been minimized.
This comment has been minimized.
|
Ah, this is the problem @dotdash was aware of, isn't it? EDIT: That was actually more about calls, rather than definitions, and I can't get calls to misbehave (we do the same thing there that the old code does AFAICT). One thing that we might need to look into is MIR trans not doing a cast returned value |
This comment has been minimized.
This comment has been minimized.
|
The core team discussed this issue today and our conclusions were as follows:
|
Florob commentedMay 25, 2016
When trying to look at how aggregates are passed to functions I came across the following:
The code presented below erroneously outputs
488447261instead of20.This is using the 1.9.0 preview release (or anything newer) and seems to be a regression from 1.8.0.
The behaviour only occurs when using the C calling conventions and optimizations, eliminating either factor gives the correct result.