OSDN Git Service

[llvm-mca] Add the ability to mark regions of code for analysis (PR36875)
authorAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Mon, 9 Apr 2018 16:39:52 +0000 (16:39 +0000)
committerAndrea Di Biagio <Andrea_DiBiagio@sn.scee.net>
Mon, 9 Apr 2018 16:39:52 +0000 (16:39 +0000)
commitaae4cd3ca110c7bec66210ec52feaa80427e25cb
tree8f853c3a096111ebba58c947340ddfcd2f04fc90
parent70b727065871b19eea556e69eab024dd3ccd498f
[llvm-mca] Add the ability to mark regions of code for analysis (PR36875)

This patch teaches llvm-mca how to parse code comments in search for special
"markers" used to select regions of code.

Example:

# LLVM-MCA-BEGIN My Code Region
  ....
# LLVM-MCA-END

The MCAsmLexer now delegates to an object of class MCACommentParser (i.e. an
AsmCommentConsumer) the parsing of code comments to search for begin/end code
region markers.

A comment starting with substring "LLVM-MCA-BEGIN" marks the beginning of a new
region of code.  A comment starting with substring "LLVM-MCA-END" marks the end
of the last region.

This implementation doesn't allow regions to overlap. Each region can have a
optional description; internally, each region is identified by a range of source
code locations (SMLoc).

MCInst objects are added to a region R only if the source location for the
MCInst is in the range of locations specified by R.

By default, the tool allocates an implicit "Default" code region which contains
every source location.  See new tests llvm-mca-marker-*.s for a few examples.

A new Backend object is created for every region. So, the analysis is conducted
on every parsed code region.  The final report is the union of the reports
generated for every code region.  Note that empty regions are skipped.

Special "[#] Code Region - ..." strings are used in the report to mark the
portion which is specific to a code region only. For example, see
llvm-mca-markers-5.s.

Differential Revision: https://reviews.llvm.org/D45433

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@329590 91177308-0d34-0410-b5e6-96231b3b80d8
13 files changed:
docs/CommandGuide/llvm-mca.rst
test/tools/llvm-mca/X86/llvm-mca-markers-1.s [new file with mode: 0644]
test/tools/llvm-mca/X86/llvm-mca-markers-2.s [new file with mode: 0644]
test/tools/llvm-mca/X86/llvm-mca-markers-3.s [new file with mode: 0644]
test/tools/llvm-mca/X86/llvm-mca-markers-4.s [new file with mode: 0644]
test/tools/llvm-mca/X86/llvm-mca-markers-5.s [new file with mode: 0644]
test/tools/llvm-mca/X86/llvm-mca-markers-6.s [new file with mode: 0644]
test/tools/llvm-mca/X86/llvm-mca-markers-7.s [new file with mode: 0644]
tools/llvm-mca/CMakeLists.txt
tools/llvm-mca/CodeRegion.cpp [new file with mode: 0644]
tools/llvm-mca/CodeRegion.h [new file with mode: 0644]
tools/llvm-mca/SourceMgr.h
tools/llvm-mca/llvm-mca.cpp