[llvm-exegesis] Use MCJIT only for execution
authorPavel Kosov <kpdev42@gmail.com>
Thu, 8 Jun 2023 16:14:00 +0000 (19:14 +0300)
committerPavel Kosov <kpdev42@gmail.com>
Fri, 16 Jun 2023 07:38:52 +0000 (10:38 +0300)
commit27f37db76a79e746561ad2545ff6ccf0d50cc38c
treec06bfa38524e5208d834a950f92552aec36468b1
parent4d0cfa6d09e2a84cceb669949d72df58c031a8c5
[llvm-exegesis] Use MCJIT only for execution

Initially, llvm-exegesis was generating the benchmark code for the
host CPU to execute it inside its own process. Thus, MCJIT was reused
for fetching function's bytes to fill the assembled_snippet field in
the benchmark report.

Later, the --mtriple and --benchmark-phase command line options were
introduced that are handy for testing snippet generation even if
snippet execution is not possible. In that setup, MCJIT is asked to
parse an object file for a foreign CPU or operating system that is
probably not guaranteed to succeed and was actually observed to fail
in https://reviews.llvm.org/D145763.

This commit implements a much simplified function's code fetching,
assuming the benchmark function is the only function in the object file
and it spans across the entire text section (note that MCJIT-based code
has more or less the same assumption - see TrackingSectionMemoryManager
class).

~~~

Huawei RRI, OS Lab

Reviewed By: courbet

Differential Revision: https://reviews.llvm.org/D148921
llvm/test/tools/llvm-exegesis/AArch64/print-assembled-snippet.s [new file with mode: 0644]
llvm/test/tools/llvm-exegesis/Mips/print-assembled-snippet.s [new file with mode: 0644]
llvm/test/tools/llvm-exegesis/PowerPC/print-assembled-snippet.s [new file with mode: 0644]
llvm/test/tools/llvm-exegesis/X86/print-assembled-snippet.s [new file with mode: 0644]
llvm/tools/llvm-exegesis/lib/Assembler.cpp
llvm/tools/llvm-exegesis/lib/Assembler.h
llvm/tools/llvm-exegesis/lib/BenchmarkRunner.cpp