diff options
author | Andrei Vagin <avagin@google.com> | 2020-03-09 11:52:32 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-03-09 11:53:28 -0700 |
commit | 2446161b3faa352bf28dc83e338f10967f0224c2 (patch) | |
tree | 7ff032459dee78b96af088bd396efd129738dcaf /test/perf/linux/signal_benchmark.cc | |
parent | ddfc7239be94fa9711df877a66a9718aabff8b96 (diff) |
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
Diffstat (limited to 'test/perf/linux/signal_benchmark.cc')
-rw-r--r-- | test/perf/linux/signal_benchmark.cc | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/test/perf/linux/signal_benchmark.cc b/test/perf/linux/signal_benchmark.cc index a6928df58..cec679191 100644 --- a/test/perf/linux/signal_benchmark.cc +++ b/test/perf/linux/signal_benchmark.cc @@ -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"); } } |