diff options
| author | Douglas <Douglas.Gliner@sony.com> | 2025-10-27 15:03:33 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-10-27 08:03:33 -0700 |
| commit | 6bf6babb30488df340337923573c562553128706 (patch) | |
| tree | 95bd634d0a4759fc887b4b4856633f482d4e4731 /llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp | |
| parent | dbd9818db320abc02a055201ba6b069069c09e58 (diff) | |
| download | llvm-6bf6babb30488df340337923573c562553128706.zip llvm-6bf6babb30488df340337923573c562553128706.tar.gz llvm-6bf6babb30488df340337923573c562553128706.tar.bz2 | |
[Clang][ARM][Sema] Check validity of ldrexd/strexd builtin calls (#164919)
This change enables validation checks against the following two ARM
atomic builtins:
```
__builtin_arm_ldrexd
__builtin_arm_strexd
```
Previously, no checks existed for these builtins, so under a release
compiler, it would be possible to emit `ldrexd`/`strexd` under ARM
targets which set the LDREX mask (returned via `getARMLDREXMask`) to
signify these as unsupported instructions.
For example, the following would compile with errors:
```c
> type atomics.c
long long func(void) {
long long num = 0;
__builtin_arm_strex(42, &num);
return __builtin_arm_ldrex(&num);
}
```
```
> clang --target=armv7m-linux-gnueabi -S atomics.c -o -
atomics.c:3:5: error: address argument to load or store exclusive builtin must be a pointer to 1,2
or 4 byte type ('volatile long long *' invalid)
3 | __builtin_arm_strex(42, &num);
| ^
atomics.c:4:12: error: address argument to load or store exclusive builtin must be a pointer to 1,2
or 4 byte type ('const volatile long long *' invalid)
4 | return __builtin_arm_ldrex(&num);
| ^
2 errors generated.
```
However, a similar program would compile without errors:
```c
> type atomics.c
long long func(void) {
long long num = 0;
__builtin_arm_strexd(42, &num);
return __builtin_arm_ldrexd(&num);
}
```
```
> clang --target=armv7m-linux-gnueabi -S atomics.c -o -
...
strexd r1, r2, r3, [r0]
ldrexd r0, r1, [r0]
...
```
With this change, we now have appropriate compile-time errors:
```
> clang --target=armv7m-linux-gnueabi -S atomics.c -o -
atomics.c:3:5: error: load and store exclusive builtins are not available on this architecture
3 | __builtin_arm_strexd(42, &num);
| ^ ~~~~
atomics.c:4:12: error: load and store exclusive builtins are not available on this architecture
4 | return __builtin_arm_ldrexd(&num);
| ^ ~~~~
2 errors generated.
```
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc/RPCUtilsTest.cpp')
0 files changed, 0 insertions, 0 deletions
