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

JF Bastien via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 31 08:53:03 PDT 2018


jfb added a comment.

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).


In fact, let me go further and quote the langref <https://llvm.org/docs/LangRef.html#id193>:

> 'load' instruction
> 
> `align` must be explicitly specified on atomic loads, and the load has undefined behavior if the alignment is not set to a value which is at least the size in bytes of the pointee.

It sounds like you'll want to remove there UB from the IR before your work proceeds. I'm still not sure that you want what you said you did :-)


https://reviews.llvm.org/D47589





More information about the llvm-commits mailing list