Issue 58184
Summary [clang++] Clang-15 vs Clang-14 local static init guards
Labels new issue
Assignees
Reporter eskimo-software
    I'm using Clang++ to compile for a Cortex-M0+ target, and in moving from version 14 to version 15 I've found a difference in the code generated for guard variables for local statics.

So, for example:
```
int main()
{
    static knl::QueueN<uint32_t, 8> valQueue;
    ...
}
```
Clang-14 generates the following:
```
ldr r0, .LCPI0_4
ldrb    r0, [r0]
dmb sy
lsls    r0, r0, #31
beq .LBB0_8
```
Clang-15 now generates:
```
ldr r0, .LCPI0_4
movs    r1, #2
bl  __atomic_load_1
lsls    r0, r0, #31
beq .LBB0_8
```

An important consequence of this is that the second case actually requires an implementation of __atomic_load_1 to be provided from somewhere external to the compiler (e.g. -latomic?), whereas the first doesn't.  

Note that the source code doesn't explicitly use atomics, only the implied usage by the statics (which can of course be disabled with `-fno-threadsafe-statics`).

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to