You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm posting here first because I have an unexpected result on some code I wrote. It looks like a compiler issue but as I'm learning Rust, maybe it's just me doing dumb things :D. Could you please tell me is this is a misusage on my end before I raise the issue upstream ?
Basically, it consists of a RefCell that is written in an interrupt, and read on the main loop. The initial value is 0, and set to > 0 on the interrup. The main loop turns on the LED if the value is >0. So it starts off and then turns on.
(sorry for the rather strange code; I started removing logic to make a minimum MVP)
However, when there is no code on the else branch, the LED never turns on. If we put some code (like a nop, or something else) then it works as expected.
For the sake of simplicity, I created two examples:
GOOD, with a nop in the else branch -> LED turns on.
BAD with nothing on the else branch -> LED stays off.
I tried to debug the compilation, and I see that:
MIR
The runtime optimized after MIR (006.000) looks okay on both cases:
Hi,
I'm posting here first because I have an unexpected result on some code I wrote. It looks like a compiler issue but as I'm learning Rust, maybe it's just me doing dumb things :D. Could you please tell me is this is a misusage on my end before I raise the issue upstream ?
The code is here.
Basically, it consists of a
RefCell
that is written in an interrupt, and read on the main loop. The initial value is0
, and set to> 0
on the interrup. The main loop turns on the LED if the value is>0
. So it starts off and then turns on.(sorry for the rather strange code; I started removing logic to make a minimum MVP)
However, when there is no code on the
else
branch, the LED never turns on. If we put some code (like anop
, or something else) then it works as expected.For the sake of simplicity, I created two examples:
nop
in the else branch -> LED turns on.I tried to debug the compilation, and I see that:
MIR
The runtime optimized after MIR (006.000) looks okay on both cases:
GOOD:
BAD:
Basically, the diff is in
bb18
/bb19
LLVM-IR:
GOOD:
BAD:
I don't really know LLVM, but the
phi i8
that uses[0, %bb14]
looks strange to me, making the condition after always true ?Assembly
BAD:
To be honest I don't really understand instruction
24
; why would it try to load from0x0000
?What do you think ?
Many thanks for your help !
The text was updated successfully, but these errors were encountered: