This is an archive of the discontinued LLVM Phabricator instance.

[llvm-exegesis] Use MCJIT only for execution

Authored by kpdev42 on Apr 21 2023, 5:56 AM.



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

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


Huawei RRI, OS Lab

Diff Detail

Event Timeline

kpdev42 created this revision.Apr 21 2023, 5:56 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 21 2023, 5:56 AM
kpdev42 requested review of this revision.Apr 21 2023, 5:56 AM
kpdev42 edited the summary of this revision. (Show Details)Apr 21 2023, 6:08 AM
courbet added inline comments.Apr 21 2023, 6:51 AM
4–6 ↗(On Diff #515705)

Maybe do this in a separate patch in case it has to be reverted ? :)


[nit] Propagate the error ?


I'm not very familiar with the section API, is this the relative address of the symbol within the section or an absolute address ? If the latter should this be compared to SectionRef::getAddress() rather than 0 ?

kpdev42 updated this revision to Diff 517472.Apr 27 2023, 12:57 AM

Address review comments

kpdev42 marked an inline comment as done.Apr 27 2023, 1:03 AM
kpdev42 added inline comments.

You are most probably right, because these addresses are subtracted in

courbet accepted this revision.May 10 2023, 1:01 AM
courbet added inline comments.


This revision is now accepted and ready to land.May 10 2023, 1:01 AM
This revision was automatically updated to reflect the committed changes.
kpdev42 marked an inline comment as done.