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 uppowi only: don't override arm calling convention #26
Conversation
TimNN
added some commits
Nov 8, 2016
This comment has been minimized.
This comment has been minimized.
|
Thanks! With this strategy, though, I feel like we still may have not settled this ABI issue. Clearly the compiler and compiler-rt are disagreeing about the ABI of these intrinsics, but we should figure out how to get them to agree on all of them because in theory clang does something here that's correct which we should be mirroring. So previously the compiler and compiler-rt disagreed about the ABI of powi, so we assumed they disagreed about all of them. It looks like some assembly at least is the aapcs ABI which the compiler now would not be expecting. In summary this PR is assuming that powi is the only intrinsic that we disagreed on ABI with, right? Do we have any information leading us to that conclusion? Or are we basically just in "fix regressions as we see them" mode? (just trying to get a handle on the current state of affairs) |
This comment has been minimized.
This comment has been minimized.
|
This is the >>"fix regressions as we see them" mode<< right now. As I see the situation, this affects beta and is about to hit stable. A complete fix would probably be more difficult and involve patching llvm, which would take a much longer time. Although it would of course be interesting to know, what the exceptional situation is: "Everything is HF except [...]" or "everything is SF except [...]". An alternative fix would probably be to revert the previous patch and just don't link agains |
This comment has been minimized.
This comment has been minimized.
|
Hm so the timeliness here may not be too much of a factor. Stable builds are already branched and underway, so we're not going to fix that with the 1.13.0 release (I believe). In that sense I wouldn't mind taking some more time to investigate what's going on here and dig into the disagreement. |
This comment has been minimized.
This comment has been minimized.
|
Sure, that's fine with me, although the new regression (failure to parse floats properly) seems much worse to me than the old regression (failure of |
This comment has been minimized.
This comment has been minimized.
|
cc @brson, thoughts about the regression status? summary:
We could either backport this PR and make a new stable build, or punt and fix this problem in beta. I'm tempted to fix this problem in beta (a non-tier-1 platform is not worth the amount of trouble to delay everything, just a very good thing to fix) |
This comment has been minimized.
This comment has been minimized.
brson
commented
Nov 8, 2016
|
I think we have to accept rust-lang/rust#37630 as a known regression for 1.13. There's a lot of risk making any changes now, and as you say, it's a tier 2 platform. |
This comment has been minimized.
This comment has been minimized.
|
I suspect all of the rust-declared float intrinsics will have this problem, not just Even though it's Tier 2, I'll be blocked from shipping this to Fedora until there's a fix. I've been trying to enable all archs for the eventual Firefox oxidation, so Tier 1 x86-only is too restrictive. But, if we do get a proper fix for this in the next beta, I can definitely backport that for our 1.13 build. |
This comment has been minimized.
This comment has been minimized.
|
On a nightly before my original fix ( I tested (for
This was using cross-compiling + qemu on Ubuntu. |
This comment has been minimized.
This comment has been minimized.
|
Interesting! Maybe the ABI gets lost/corrupted when inlining that wrapper? And how about the same test on a nightly that does have your fix -- then are the direct and wrapper versions both ok? I'd still feel more comfortable if we knew why the other calls are ok -- are they perhaps inlining direct instructions instead of making a real function call? |
This comment has been minimized.
This comment has been minimized.
|
There is not yet a nightly with my fix, however I did test on the latest beta: On the latest beta things worked fine for the above mentioned functions -- both with and without a wrapper function. I also added tests for That failed for |
This comment has been minimized.
This comment has been minimized.
|
@TimNN the functions you mentioned here all come from libc, right? not compiler-rt? (except for powi). In that sense I wouldn't expect a calling convention mismatch as we're calling those functions ourselves and LLVM isn't lowering intrinsics. |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton: I used the intrinsics from |
This comment has been minimized.
This comment has been minimized.
|
Wow good point. I don't really know what LLVM is doing with intrinsics. Surely there's someone from LLVM who either knows what's up here or could help us... |
This comment has been minimized.
This comment has been minimized.
|
One thing that I've been thinking about is that the now failing function ( This generates ir like this: The This was tested on beta, test code, ir and asm. |
This comment has been minimized.
This comment has been minimized.
|
@TimNN I'm looking disassembly of your test's With optimized code, they all disappear, whether wrapped or direct, so I guess LLVM is const-folding those intrinsics entirely away. |
This comment has been minimized.
This comment has been minimized.
|
@cuviper: Yeah, I just noticed the powi behaviour as well (for the smaller test from my previous comment). This could probably be fixed by using some blackboxes in the old test case as well. |
This comment has been minimized.
This comment has been minimized.
|
I added blackbox calls to the old test as well and now |
This comment has been minimized.
This comment has been minimized.
|
Note that the |
This comment has been minimized.
This comment has been minimized.
|
@TimNN so I think the next step here is to answer the question of what LLVM expects each ABI to be and why. LLVM seems to be clearly expecting not aapcs for powi, but it does aapcs for casts. It seems to not be clear why, and could perhaps indicate some deeper problems? Would you be up for investigating that? (I also can do so) |
This comment has been minimized.
This comment has been minimized.
|
@alexcrichton: I already looked a bit at llvm, but I find the llvm source to be... not easily approachable. I'll try to look some more, but don't know how much time to do so I will have in the near future. An interesting place to look at seems to be Edit: more specifically, these lines. |
This comment has been minimized.
This comment has been minimized.
|
Ok, I've done a bit of investigation, and here's what I've come up with. Following @TimNN's lead the relevant set of declarations seems fairly small and targeted. Furthermore, it basically seems to follow the pattern that anything with the Next up, it turns out that a lot of intrinsics in compiler-rt have aliases defined for them through the Finally, if we take a look at all intrinsics that are interested in floats, ignore all those with aliases, and ignore all those related to 128-bit floats, we're only left with two we're interested in: So to sum that up:
tl;dr; @TimNN this patch I now believe to be correct. Odd though it may be! |
alexcrichton
merged commit 3bc0272
into
rust-lang:rust-llvm-2016-07-18
Nov 10, 2016
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this pull request
Nov 10, 2016
TimNN
deleted the
TimNN:arm-cc
branch
Nov 10, 2016
This was referenced Nov 10, 2016
bors
added a commit
to rust-lang/rust
that referenced
this pull request
Nov 11, 2016
mattico
referenced this pull request
Nov 11, 2016
Closed
Floating point add gives different results than compiler-rt on arm-unknown-linux-gnueabi #90
This comment has been minimized.
This comment has been minimized.
parched
commented
Nov 11, 2016
|
@alexcrichton Yes this looks correct for now, but note that upstream LLVM now uses AAPCS for all arm intrinsics llvm-mirror/llvm@c4c2318 Although that seems to conflict with what GCC does https://gcc.gnu.org/ml/gcc/2016-09/msg00162.html where they use AAPCS for all |
This comment has been minimized.
This comment has been minimized.
|
Note the linked bug report: https://llvm.org/bugs/show_bug.cgi?id=30543. |
This comment has been minimized.
This comment has been minimized.
|
Ok, sounds like we should perhaps go back to AAPCS everywhere when updating to LLVM 4.0? Seems like something good to watch out for! |
This comment has been minimized.
This comment has been minimized.
|
That will have to be conditional, so long as we support pre-4.0 external LLVM. |
This comment has been minimized.
This comment has been minimized.
|
Or maybe powi should be a priority for the project to rewrite builtins in Rust. It's a small pure-C implementation -- should be easy to translate. |
This comment has been minimized.
This comment has been minimized.
|
@cuviper: The |
This comment has been minimized.
This comment has been minimized.
|
Ah, great! Hopefully that integration can beat LLVM 4.0's release, and we won't have to worry about it. |
TimNN commentedNov 8, 2016
•
edited
This should be a short term fix for rust-lang/rust#37630, while not regressing rust-lang/rust#37559.
cc @alexcrichton, @japaric, #25