-
Notifications
You must be signed in to change notification settings - Fork 212
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
For msp430, __ashldi3
takes a 16-bit integer as the second argument in LLVM's compiler-rt
. Probably affects other builtins.
#520
Comments
If this is just a matter of |
Doing this would technically be a breaking change according to semver, as calling I personally haven't used Does this warrant a bump to |
|
Alright, I'll take a look this coming week and prepare a patch then :). |
I've created a test case that panics on msp430 in debug/release mode:
If I call
compiler_builtins::int::shift::__ashldi3(*val, *amt as u32)
directly,shift_test
does not panic. Relevant assembly code:However, if I let LLVM lower the shift to a builtin,
shift_test
tends to panic:Notice that the call to
__ashldi3
only sets up one 64-bit worth and a 16-bitint
's worth of argument. This is correct for__ashldi3
as specified incompiler-rt
. However, we call thecompiler-builtins
version in both cases (compiled with-Zbuild-std=core
), which excepts a 32-bitint
's worth of argument. The second code snippet does not do this, and therefore whencompiler_builtins::int::shift::__ashldi3
is called it reads garbage for the top 16-bits of theshl
argument. This causes subtle breakage and pain, possibly many instructions away from the call :).AVR doesn't appear to have this problem because apparently there's an dedicated pass to ensuring that calls to
__ashldi3
and friends aren't emitted into assembly files. MSP430 doesn't have such a pass. Which makes me confused as to why #513 was needed in the first place, but that's for another time.This leaves msp430 as the only platform which would use at the very least the shift builtins where
sizeof(int)
isn't 4. I'm not sure how to fix this:int
where this crate uses au32
and adding conditional compilation seems invasive.build-std-features
route to disablecompiler_builtins
because I'm trying to remove nightly features from the msp430 backend, not add them.__ashldi3
does exist inlibgcc
:int
args) are inlibgcc
for MSP430. I'd rather seecompiler-builtins
correctly support 16-bit int input arguments rather than hardcode a 32-bit one. Maybe adding anmsp430_expand
wrapper is possible- i.e. expand 16-bit ints to 32-bit before sending to__ashldi3
? That seems like it could be done in a semver-compat manner somehow?The text was updated successfully, but these errors were encountered: