This patch copies implementation from cpuid.h, which preserve base register %rbx around cpuid. It fixes PR50133.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Seems reasonable, thanks.
We really ought to solve the general problem one day. It is kind of pig-headed that the backend just picks two arbitrary CSRs, the base and frame pointers, and doesn't bother checking if any instructions clobber those registers.
clang-format: please reformat the code
-#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \ - __asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \ - : "0"(__leaf), "2"(__count)) +#define __cpuid_count(__leaf, __count, __eax, __ebx, __ecx, __edx) \ + __asm("cpuid" \ + : "=a"(__eax), "=b"(__ebx), "=c"(__ecx), "=d"(__edx) \ + : "0"(__leaf), "2"(__count))