Issue 183635
Summary clang's built-in assembler does not support frstors,fsaves and vpcmpestriq
Labels clang
Assignees
Reporter edwintorok
    See [the post on xen-devel](https://lore.kernel.org/xen-devel/[email protected]/)
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:
```
#include <stdint.h>
#include <stdlib.h>

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");
      | ^
<inline asm>:1:2: note: instantiated into assembly here
    1 | frstors (%rax)
      |         ^~~~~~~
x.c:10:28: error: invalid instruction mnemonic 'fsaves'
   10 |                "fidivs %1\n\t"
 |                            ^
<inline asm>:4:2: note: instantiated into assembly here
    4 |         fsaves (%rax)
      | ^~~~~~
x.c:17:17: error: invalid instruction mnemonic 'vpcmpestriq'
   17 | "vpcmpestriq $0b01111010, (%1), %%xmm2"
      | ^
<inline asm>:2:1: note: instantiated into assembly here
    2 | vpcmpestriq $0b01111010, (%rsi), %xmm2
      | ^~~~~~~~~~~
3 errors generated.
$ clang -no-integrated-as x.c
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to