clang's built-in assembler does not support frstors,fsaves and vpcmpestriq
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
See [the post on xen-devel](https://lore.kernel.org/xen-devel/c9b20e41-cab5-4fb2-be32-cea6668a56ae@suse.com/)
The Xen x86 emulator tests use inline assembly instructions `frstors`, `fsaves`, and `vpcmpestriq`.
However clang 21.1.8's built-in assembler does not support these.
A workaround is to add `-no-integrated-as` to use an external assembler, which does accept these mnemonics.
Here is a small test program extracted from the original failure:
```c
#include
#include
int main() {
unsigned int res[0x200];
const uint16_t five = 5;
asm volatile("frstors %0" ::"m"(res[25]) : "memory");
asm volatile("fninit\n\t"
"fld1\n\t"
"fidivs %1\n\t"
"fsaves %0"
: "=m"(res[25])
: "m"(five)
: "memory");
asm volatile("movq %0, %%xmm2\n"
#ifdef __x86_64__
"vpcmpestriq $0b01111010, (%1), %%xmm2"
#else
"vpcmpestri $0b01111010, (%1), %%xmm2"
#endif
::"m"(res[0]),
"S"(NULL));
}
```
```
$ clang --version
clang version 21.1.8 (Fedora 21.1.8-4.fc43)
Target: x86_64-redhat-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
Configuration file: /etc/clang/x86_64-redhat-linux-gnu-clang.cfg
$ clang x.c
x.c:7:16: error: invalid instruction mnemonic 'frstors'
7 | asm volatile("frstors %0" ::"m"(res[25]) : "memory");
| ^
:1:2: note: instantiated into assembly here
1 | frstors (%rax)
| ^~~~~~~
x.c:10:28: error: invalid instruction mnemonic 'fsaves'
10 | "fidivs %1\n\t"
| ^
:4:2: note: instantiated into assembly here
4 | fsaves (%rax)
| ^~~~~~
x.c:17:17: error: invalid instruction mnemonic 'vpcmpestriq'
17 | "vpcmpestriq $0b01111010, (%1), %%xmm2"
| ^
:2:1: note: instantiated into assembly here
2 | vpcmpestriq $0b01111010, (%rsi), %xmm2
| ^~~~~~~~~~~
3 errors generated.
$ clang -no-integrated-as x.c
```
Contributor guide
Assessment
This issue has not been assessed yet.