forked from OSchip/llvm-project
[llvm-mca] add example workflow for source code
This is copied from Andrea's text in PR36875: https://bugs.llvm.org/show_bug.cgi?id=36875 As noted there, this is a hack...but it's a good one! It's important to show potential workflows up-front with examples, so customers can copy and experiment with them. llvm-svn: 329726
This commit is contained in:
parent
90a937e3e1
commit
c86033a55a
|
@ -36,6 +36,26 @@ substring ``LLVM-MCA-END`` marks the end of a code region. For example:
|
||||||
...
|
...
|
||||||
# LLVM-MCA-END
|
# LLVM-MCA-END
|
||||||
|
|
||||||
|
Inline assembly directives may also be used from source code to annotate the
|
||||||
|
assembly text:
|
||||||
|
|
||||||
|
.. code-block:: c++
|
||||||
|
|
||||||
|
int foo(int a, int b) {
|
||||||
|
__asm volatile("# LLVM-MCA-BEGIN foo");
|
||||||
|
a += 42;
|
||||||
|
__asm volatile("# LLVM-MCA-END");
|
||||||
|
a *= b;
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
So for example, you can compile code with clang, output assembly, and pipe it
|
||||||
|
directly into llvm-mca for analysis:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
$ clang foo.cpp -O2 -target x86_64-unknown-unknown -S -o - | llvm-mca -mcpu=btver2
|
||||||
|
|
||||||
Multiple regions can be specified provided that they do not overlap. A code
|
Multiple regions can be specified provided that they do not overlap. A code
|
||||||
region can have an optional description. If no user defined region is specified,
|
region can have an optional description. If no user defined region is specified,
|
||||||
then :program:`llvm-mca` assumes a default region which contains every
|
then :program:`llvm-mca` assumes a default region which contains every
|
||||||
|
|
Loading…
Reference in New Issue