Skip to content

Commit

Permalink
Reland "[llvm-exegesis] Fix preservation of RDI in subprocess mode (#…
Browse files Browse the repository at this point in the history
…72458)"

This reverts commit 186db1b.

This relands commit 0718c1a.

The REQUIRES flag in the test that was added only specified that the
machine needed to have the capability to execute the snippet rather than
actually run it with performance counters. This would work with
--dummy-perf-counters, but that is not currently supported in the
subprocess execution mode. So for now, we require the ability to
actually perform measurements to prevent test failures in configurations
that don't have libpfm or access to performance counters.
  • Loading branch information
boomanaiden154 committed Nov 16, 2023
1 parent 5f64b94 commit add2053
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# REQUIRES: exegesis-can-measure-latency, x86_64-linux

# RUN: llvm-exegesis -mtriple=x86_64-unknown-unknown -mode=latency -snippets-file=%s -execution-mode=subprocess | FileCheck %s

# See comment in ./subprocess-abnormal-exit-code.s on the transient
# PTRACE_ATTACH failure.
# ALLOW_RETRIES: 2

# Check that the value of the registers preserved in subprocess mode while
# making the ioctl system call are actually preserved correctly.

# LLVM-EXEGESIS-DEFREG RAX 11
# LLVM-EXEGESIS-DEFREG RDI 13
# LLVM-EXEGESIS-DEFREG RSI 17
# LLVM-EXEGESIS-DEFREG R13 0
# LLVM-EXEGESIS-DEFREG R12 127

cmpq $0x11, %rax
cmovneq %r12, %r13
cmpq $0x13, %rdi
cmovneq %r12, %r13
cmpq $0x17, %rsi
cmovneq %r12, %r13

movq $60, %rax
movq %r13, %rdi
syscall

# CHECK-NOT: error: 'Child benchmarking process exited with non-zero exit code: Child process returned with unknown exit code'

2 changes: 1 addition & 1 deletion llvm/tools/llvm-exegesis/lib/X86/Target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,7 +1205,7 @@ ExegesisX86Target::configurePerfCounter(long Request, bool SaveRegisters) const
if(SaveRegisters) {
// Restore RAX, RDI, and RSI, in reverse order.
generateRegisterStackPop(X86::RSI, ConfigurePerfCounterCode);
generateRegisterStackPop(X86::RIP, ConfigurePerfCounterCode);
generateRegisterStackPop(X86::RDI, ConfigurePerfCounterCode);
generateRegisterStackPop(X86::RAX, ConfigurePerfCounterCode);
}
return ConfigurePerfCounterCode;
Expand Down

0 comments on commit add2053

Please sign in to comment.