mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
perf/signal: rewrite code in assembly to avoid compiler optimizations
Without this change, the assembly code of this test compiled without optimizations: mov -0x150(%rbp),%rax movl $0x77777777,(%rax) lea -0x128(%rbp),%rax with optimizations: movl $0x77777777,0x0 This code doesn't work properly, because the test changes rax in the segv handler. PiperOrigin-RevId: 299896117
This commit is contained in:
@@ -43,11 +43,13 @@ void BM_FaultSignalFixup(benchmark::State& state) {
|
||||
|
||||
// Fault, fault, fault.
|
||||
for (auto _ : state) {
|
||||
register volatile unsigned int* ptr asm("rax");
|
||||
|
||||
// Trigger the segfault.
|
||||
ptr = nullptr;
|
||||
*ptr = 0;
|
||||
asm volatile(
|
||||
"movq $0, %%rax\n"
|
||||
"movq $0x77777777, (%%rax)\n"
|
||||
:
|
||||
:
|
||||
: "rax");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user