[PATCH] D120026: [ARM] Fix ARM backend to correctly use atomic expansion routines.

Ayke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 22 07:46:20 PDT 2022


aykevl added a comment.

> This also affects Cortex-M0, but I don't think `__sync_*` routines actually exist in any Cortex-M0 libraries. So in practice this just leads to a slightly different linker error for those cases, I think.

TinyGo implements these `__sync_*` routines so that atomic operations work. See https://github.com/tinygo-org/tinygo/blob/v0.22.0/src/runtime/atomics_critical.go#L188. I believe the `__sync_*` variants only exist for Cortex-M / ARM, other targets use `__atomic_*`. That said, I'm generally in favor of this change because it looks more correct and aligns with atomics on other LLVM backends.

I suspect Rust Embedded also implements these routines (I think I've seen them somewhere) but I can't find it easily.

Related: https://reviews.llvm.org/D61052



================
Comment at: llvm/test/CodeGen/ARM/atomic-op.ll:414
 ; CHECK-T1-M0: dmb
-; CHECK-T1-M0: str [[R0]], [r1]
+; CHECK-T1-M0: __atomic_store_4
 
----------------
This looks like a regression. I'm pretty sure that these loads and stores are always atomic. Is there a reason why this has to go through a library function?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D120026/new/

https://reviews.llvm.org/D120026



More information about the llvm-commits mailing list