You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As far as my observation, we didn't consider if the frame pointer RBX will be clobbered by inline asm.
I have no idea if we can fix this problem in frame lowering completely.
Given usage of inline asm is rare on Windows, especially MSVC doesn't support for 64 bits. I think a workaround should be good for a quick fix.
Candidate patch: https://reviews.llvm.org/D101338
This is basically an instance of the more general problem, llvm.org/pr16830, which has been known for a while. In this case, I think a workaround makes sense.
Summary:
We need to preserve `rbx` across the call to `cpuid` on Windows. This becomes obvious when compiling under ASan where presumably due to high register pressure, we end up in a situation where `rbx` is clobbered by `cpuid` but the compiler did not expect it to be clobbered.
This is fixed in clang upstream here:
llvm/llvm-project#49477https://reviews.llvm.org/D101338
However we use an older compiler (LLVM12.0.1) which does not have the patch yet.
Reviewed By: yfeldblum
Differential Revision: D35229538
fbshipit-source-id: 265835fb0e79e3a209dbce4fe82e8baa43e3d6ba
Extended Description
Small reproducer:
#include
#include
#include <intrin.h>
struct A {
std::string S;
std::vector<std::array<int, 4>> V;
A() {
std::array<int, 4> B;
__cpuid(B.data(), 0);
V.push_back(B);
V.push_back(B);
char C[64];
memset(C, 0, sizeof(C));
S = C;
}
} T;
Commands:
clang-cl -mavx2 /EHs repro.cpp -S
cat repro.asm | grep cpuid -A7
cpuid
#NO_APP
mov r11d, eax
mov rax, qword ptr [rbx + 72] # 8-byte Reload
mov r10d, ebx
mov r9d, ecx
mov rcx, qword ptr [rbx + 80] # 8-byte Reload
mov r8d, edx
The text was updated successfully, but these errors were encountered: