[PATCH] D47589: [RISCV] Add codegen support for atomic load/stores with RV32A

Alex Bradbury via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 31 12:13:14 PDT 2018


asb added a subscriber: regehr.
asb added a comment.

In https://reviews.llvm.org/D47589#1117978, @asb wrote:

> In https://reviews.llvm.org/D47589#1117778, @jfb wrote:
>
> > > When the A extension is supported, __atomic libcalls will be generated for any atomic that isn't the native word size or has less than natural alignment.
> >
> > When do you expect non-natural alignment to occur? Is this purely for C++ support? If so you're guaranteed natural alignment. Otherwise (for intrinsics or for other languages) I'd like to understand what you expect, and whether you have the guarantee that the alignment information you have is correct. Without knowing that it's absolutely correct you're going to codegen bad code (a libcall in one place, and instructions in another).
>
>
> That comment simply reflects the status quo for behaviour of AtomicExpandPass, that I replicated. Do you think it would be worth doing `report_fatal_error` if Align < Size?


Acutally I'm not sure it's reasonable to quote at compile-time when encountering UB (@regehr  - thoughts?). Emitting an `__atomic_*` libcall in this case seems like a reasonable choice, so perhaps the fix is simply to be clear that an instruction with `Align < Size` has UB and emitting the `__atomic_*` call is the behaviour we choose.


https://reviews.llvm.org/D47589





More information about the llvm-commits mailing list