mirror of https://github.com/tinygo-org/tinygo.git
Browse Source
Because of a bug in the ARM backend of LLVM, the cmpxchg instruction is lowered using ldrexd/strexd instructions which don't exist on Cortex-M cores. This leads to an "undefined instruction" exception at runtime. Therefore, this patch works around this by lowering directly to a call to the __sync_val_compare_and_swap_8 function, which is what the backend should be doing. For details, see: https://reviews.llvm.org/D95891 To test this patch, you can run the code on a Cortex-M3 or higher microcontroller, for example: tinygo flash -target=pca10040 ./testdata/atomic.go Before this patch, this would trigger an error. With this patch, the behavior is correct. The error (without this patch) could look like this: fatal error: undefined instruction with sp=0x200007cc pc=nilpull/1616/head
Ayke van Laethem
4 years ago
committed by
Ron Evans
1 changed files with 27 additions and 0 deletions
Loading…
Reference in new issue