xref: /aosp_15_r20/external/llvm/docs/TestSuiteMakefileGuide.rst (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker=====================
2*9880d681SAndroid Build Coastguard WorkerLLVM test-suite Guide
3*9880d681SAndroid Build Coastguard Worker=====================
4*9880d681SAndroid Build Coastguard Worker
5*9880d681SAndroid Build Coastguard Worker.. contents::
6*9880d681SAndroid Build Coastguard Worker   :local:
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard WorkerOverview
9*9880d681SAndroid Build Coastguard Worker========
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard WorkerThis document describes the features of the Makefile-based LLVM
12*9880d681SAndroid Build Coastguard Workertest-suite as well as the cmake based replacement. This way of interacting
13*9880d681SAndroid Build Coastguard Workerwith the test-suite is deprecated in favor of running the test-suite using LNT,
14*9880d681SAndroid Build Coastguard Workerbut may continue to prove useful for some users. See the Testing
15*9880d681SAndroid Build Coastguard WorkerGuide's :ref:`test-suite Quickstart <test-suite-quickstart>` section for more
16*9880d681SAndroid Build Coastguard Workerinformation.
17*9880d681SAndroid Build Coastguard Worker
18*9880d681SAndroid Build Coastguard WorkerTest suite Structure
19*9880d681SAndroid Build Coastguard Worker====================
20*9880d681SAndroid Build Coastguard Worker
21*9880d681SAndroid Build Coastguard WorkerThe ``test-suite`` module contains a number of programs that can be
22*9880d681SAndroid Build Coastguard Workercompiled with LLVM and executed. These programs are compiled using the
23*9880d681SAndroid Build Coastguard Workernative compiler and various LLVM backends. The output from the program
24*9880d681SAndroid Build Coastguard Workercompiled with the native compiler is assumed correct; the results from
25*9880d681SAndroid Build Coastguard Workerthe other programs are compared to the native program output and pass if
26*9880d681SAndroid Build Coastguard Workerthey match.
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard WorkerWhen executing tests, it is usually a good idea to start out with a
29*9880d681SAndroid Build Coastguard Workersubset of the available tests or programs. This makes test run times
30*9880d681SAndroid Build Coastguard Workersmaller at first and later on this is useful to investigate individual
31*9880d681SAndroid Build Coastguard Workertest failures. To run some test only on a subset of programs, simply
32*9880d681SAndroid Build Coastguard Workerchange directory to the programs you want tested and run ``gmake``
33*9880d681SAndroid Build Coastguard Workerthere. Alternatively, you can run a different test using the ``TEST``
34*9880d681SAndroid Build Coastguard Workervariable to change what tests or run on the selected programs (see below
35*9880d681SAndroid Build Coastguard Workerfor more info).
36*9880d681SAndroid Build Coastguard Worker
37*9880d681SAndroid Build Coastguard WorkerIn addition for testing correctness, the ``test-suite`` directory also
38*9880d681SAndroid Build Coastguard Workerperforms timing tests of various LLVM optimizations. It also records
39*9880d681SAndroid Build Coastguard Workercompilation times for the compilers and the JIT. This information can be
40*9880d681SAndroid Build Coastguard Workerused to compare the effectiveness of LLVM's optimizations and code
41*9880d681SAndroid Build Coastguard Workergeneration.
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Worker``test-suite`` tests are divided into three types of tests: MultiSource,
44*9880d681SAndroid Build Coastguard WorkerSingleSource, and External.
45*9880d681SAndroid Build Coastguard Worker
46*9880d681SAndroid Build Coastguard Worker-  ``test-suite/SingleSource``
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Worker   The SingleSource directory contains test programs that are only a
49*9880d681SAndroid Build Coastguard Worker   single source file in size. These are usually small benchmark
50*9880d681SAndroid Build Coastguard Worker   programs or small programs that calculate a particular value. Several
51*9880d681SAndroid Build Coastguard Worker   such programs are grouped together in each directory.
52*9880d681SAndroid Build Coastguard Worker
53*9880d681SAndroid Build Coastguard Worker-  ``test-suite/MultiSource``
54*9880d681SAndroid Build Coastguard Worker
55*9880d681SAndroid Build Coastguard Worker   The MultiSource directory contains subdirectories which contain
56*9880d681SAndroid Build Coastguard Worker   entire programs with multiple source files. Large benchmarks and
57*9880d681SAndroid Build Coastguard Worker   whole applications go here.
58*9880d681SAndroid Build Coastguard Worker
59*9880d681SAndroid Build Coastguard Worker-  ``test-suite/External``
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Worker   The External directory contains Makefiles for building code that is
62*9880d681SAndroid Build Coastguard Worker   external to (i.e., not distributed with) LLVM. The most prominent
63*9880d681SAndroid Build Coastguard Worker   members of this directory are the SPEC 95 and SPEC 2000 benchmark
64*9880d681SAndroid Build Coastguard Worker   suites. The ``External`` directory does not contain these actual
65*9880d681SAndroid Build Coastguard Worker   tests, but only the Makefiles that know how to properly compile these
66*9880d681SAndroid Build Coastguard Worker   programs from somewhere else. The presence and location of these
67*9880d681SAndroid Build Coastguard Worker   external programs is configured by the test-suite ``configure``
68*9880d681SAndroid Build Coastguard Worker   script.
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard WorkerEach tree is then subdivided into several categories, including
71*9880d681SAndroid Build Coastguard Workerapplications, benchmarks, regression tests, code that is strange
72*9880d681SAndroid Build Coastguard Workergrammatically, etc. These organizations should be relatively self
73*9880d681SAndroid Build Coastguard Workerexplanatory.
74*9880d681SAndroid Build Coastguard Worker
75*9880d681SAndroid Build Coastguard WorkerSome tests are known to fail. Some are bugs that we have not fixed yet;
76*9880d681SAndroid Build Coastguard Workerothers are features that we haven't added yet (or may never add). In the
77*9880d681SAndroid Build Coastguard Workerregression tests, the result for such tests will be XFAIL (eXpected
78*9880d681SAndroid Build Coastguard WorkerFAILure). In this way, you can tell the difference between an expected
79*9880d681SAndroid Build Coastguard Workerand unexpected failure.
80*9880d681SAndroid Build Coastguard Worker
81*9880d681SAndroid Build Coastguard WorkerThe tests in the test suite have no such feature at this time. If the
82*9880d681SAndroid Build Coastguard Workertest passes, only warnings and other miscellaneous output will be
83*9880d681SAndroid Build Coastguard Workergenerated. If a test fails, a large <program> FAILED message will be
84*9880d681SAndroid Build Coastguard Workerdisplayed. This will help you separate benign warnings from actual test
85*9880d681SAndroid Build Coastguard Workerfailures.
86*9880d681SAndroid Build Coastguard Worker
87*9880d681SAndroid Build Coastguard WorkerRunning the test suite via CMake
88*9880d681SAndroid Build Coastguard Worker================================
89*9880d681SAndroid Build Coastguard Worker
90*9880d681SAndroid Build Coastguard WorkerTo run the test suite, you need to use the following steps:
91*9880d681SAndroid Build Coastguard Worker
92*9880d681SAndroid Build Coastguard Worker#. The test suite uses the lit test runner to run the test-suite,
93*9880d681SAndroid Build Coastguard Worker   you need to have lit installed first.  Check out LLVM and install lit:
94*9880d681SAndroid Build Coastguard Worker
95*9880d681SAndroid Build Coastguard Worker   .. code-block:: bash
96*9880d681SAndroid Build Coastguard Worker
97*9880d681SAndroid Build Coastguard Worker       % svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm
98*9880d681SAndroid Build Coastguard Worker       % cd llvm/utils/lit
99*9880d681SAndroid Build Coastguard Worker       % sudo python setup.py install # Or without sudo, install in virtual-env.
100*9880d681SAndroid Build Coastguard Worker       running install
101*9880d681SAndroid Build Coastguard Worker       running bdist_egg
102*9880d681SAndroid Build Coastguard Worker       running egg_info
103*9880d681SAndroid Build Coastguard Worker       writing lit.egg-info/PKG-INFO
104*9880d681SAndroid Build Coastguard Worker       ...
105*9880d681SAndroid Build Coastguard Worker       % lit --version
106*9880d681SAndroid Build Coastguard Worker       lit 0.5.0dev
107*9880d681SAndroid Build Coastguard Worker
108*9880d681SAndroid Build Coastguard Worker#. Check out the ``test-suite`` module with:
109*9880d681SAndroid Build Coastguard Worker
110*9880d681SAndroid Build Coastguard Worker   .. code-block:: bash
111*9880d681SAndroid Build Coastguard Worker
112*9880d681SAndroid Build Coastguard Worker       % svn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suite
113*9880d681SAndroid Build Coastguard Worker
114*9880d681SAndroid Build Coastguard Worker#. Use CMake to configure the test suite in a new directory. You cannot build
115*9880d681SAndroid Build Coastguard Worker   the test suite in the source tree.
116*9880d681SAndroid Build Coastguard Worker
117*9880d681SAndroid Build Coastguard Worker   .. code-block:: bash
118*9880d681SAndroid Build Coastguard Worker
119*9880d681SAndroid Build Coastguard Worker       % mkdir test-suite-build
120*9880d681SAndroid Build Coastguard Worker       % cd test-suite-build
121*9880d681SAndroid Build Coastguard Worker       % cmake ../test-suite
122*9880d681SAndroid Build Coastguard Worker
123*9880d681SAndroid Build Coastguard Worker#. Build the benchmarks, using the makefiles CMake generated.
124*9880d681SAndroid Build Coastguard Worker
125*9880d681SAndroid Build Coastguard Worker.. code-block:: bash
126*9880d681SAndroid Build Coastguard Worker
127*9880d681SAndroid Build Coastguard Worker    % make
128*9880d681SAndroid Build Coastguard Worker    Scanning dependencies of target timeit-target
129*9880d681SAndroid Build Coastguard Worker    [  0%] Building C object tools/CMakeFiles/timeit-target.dir/timeit.c.o
130*9880d681SAndroid Build Coastguard Worker    [  0%] Linking C executable timeit-target
131*9880d681SAndroid Build Coastguard Worker    [  0%] Built target timeit-target
132*9880d681SAndroid Build Coastguard Worker    Scanning dependencies of target fpcmp-host
133*9880d681SAndroid Build Coastguard Worker    [  0%] [TEST_SUITE_HOST_CC] Building host executable fpcmp
134*9880d681SAndroid Build Coastguard Worker    [  0%] Built target fpcmp-host
135*9880d681SAndroid Build Coastguard Worker    Scanning dependencies of target timeit-host
136*9880d681SAndroid Build Coastguard Worker    [  0%] [TEST_SUITE_HOST_CC] Building host executable timeit
137*9880d681SAndroid Build Coastguard Worker    [  0%] Built target timeit-host
138*9880d681SAndroid Build Coastguard Worker
139*9880d681SAndroid Build Coastguard Worker
140*9880d681SAndroid Build Coastguard Worker#. Run the tests with lit:
141*9880d681SAndroid Build Coastguard Worker
142*9880d681SAndroid Build Coastguard Worker.. code-block:: bash
143*9880d681SAndroid Build Coastguard Worker
144*9880d681SAndroid Build Coastguard Worker    % lit -v -j 1 . -o results.json
145*9880d681SAndroid Build Coastguard Worker    -- Testing: 474 tests, 1 threads --
146*9880d681SAndroid Build Coastguard Worker    PASS: test-suite :: MultiSource/Applications/ALAC/decode/alacconvert-decode.test (1 of 474)
147*9880d681SAndroid Build Coastguard Worker    ********** TEST 'test-suite :: MultiSource/Applications/ALAC/decode/alacconvert-decode.test' RESULTS **********
148*9880d681SAndroid Build Coastguard Worker    compile_time: 0.2192
149*9880d681SAndroid Build Coastguard Worker    exec_time: 0.0462
150*9880d681SAndroid Build Coastguard Worker    hash: "59620e187c6ac38b36382685ccd2b63b"
151*9880d681SAndroid Build Coastguard Worker    size: 83348
152*9880d681SAndroid Build Coastguard Worker    **********
153*9880d681SAndroid Build Coastguard Worker    PASS: test-suite :: MultiSource/Applications/ALAC/encode/alacconvert-encode.test (2 of 474)
154*9880d681SAndroid Build Coastguard Worker
155*9880d681SAndroid Build Coastguard Worker
156*9880d681SAndroid Build Coastguard WorkerRunning the test suite via Makefiles (deprecated)
157*9880d681SAndroid Build Coastguard Worker=================================================
158*9880d681SAndroid Build Coastguard Worker
159*9880d681SAndroid Build Coastguard WorkerFirst, all tests are executed within the LLVM object directory tree.
160*9880d681SAndroid Build Coastguard WorkerThey *are not* executed inside of the LLVM source tree. This is because
161*9880d681SAndroid Build Coastguard Workerthe test suite creates temporary files during execution.
162*9880d681SAndroid Build Coastguard Worker
163*9880d681SAndroid Build Coastguard WorkerTo run the test suite, you need to use the following steps:
164*9880d681SAndroid Build Coastguard Worker
165*9880d681SAndroid Build Coastguard Worker#. ``cd`` into the ``llvm/projects`` directory in your source tree.
166*9880d681SAndroid Build Coastguard Worker#. Check out the ``test-suite`` module with:
167*9880d681SAndroid Build Coastguard Worker
168*9880d681SAndroid Build Coastguard Worker   .. code-block:: bash
169*9880d681SAndroid Build Coastguard Worker
170*9880d681SAndroid Build Coastguard Worker       % svn co http://llvm.org/svn/llvm-project/test-suite/trunk test-suite
171*9880d681SAndroid Build Coastguard Worker
172*9880d681SAndroid Build Coastguard Worker   This will get the test suite into ``llvm/projects/test-suite``.
173*9880d681SAndroid Build Coastguard Worker
174*9880d681SAndroid Build Coastguard Worker#. Configure and build ``llvm``.
175*9880d681SAndroid Build Coastguard Worker
176*9880d681SAndroid Build Coastguard Worker#. Configure and build ``llvm-gcc``.
177*9880d681SAndroid Build Coastguard Worker
178*9880d681SAndroid Build Coastguard Worker#. Install ``llvm-gcc`` somewhere.
179*9880d681SAndroid Build Coastguard Worker
180*9880d681SAndroid Build Coastguard Worker#. *Re-configure* ``llvm`` from the top level of each build tree (LLVM
181*9880d681SAndroid Build Coastguard Worker   object directory tree) in which you want to run the test suite, just
182*9880d681SAndroid Build Coastguard Worker   as you do before building LLVM.
183*9880d681SAndroid Build Coastguard Worker
184*9880d681SAndroid Build Coastguard Worker   During the *re-configuration*, you must either: (1) have ``llvm-gcc``
185*9880d681SAndroid Build Coastguard Worker   you just built in your path, or (2) specify the directory where your
186*9880d681SAndroid Build Coastguard Worker   just-built ``llvm-gcc`` is installed using
187*9880d681SAndroid Build Coastguard Worker   ``--with-llvmgccdir=$LLVM_GCC_DIR``.
188*9880d681SAndroid Build Coastguard Worker
189*9880d681SAndroid Build Coastguard Worker   You must also tell the configure machinery that the test suite is
190*9880d681SAndroid Build Coastguard Worker   available so it can be configured for your build tree:
191*9880d681SAndroid Build Coastguard Worker
192*9880d681SAndroid Build Coastguard Worker   .. code-block:: bash
193*9880d681SAndroid Build Coastguard Worker
194*9880d681SAndroid Build Coastguard Worker       % cd $LLVM_OBJ_ROOT ; $LLVM_SRC_ROOT/configure [--with-llvmgccdir=$LLVM_GCC_DIR]
195*9880d681SAndroid Build Coastguard Worker
196*9880d681SAndroid Build Coastguard Worker   [Remember that ``$LLVM_GCC_DIR`` is the directory where you
197*9880d681SAndroid Build Coastguard Worker   *installed* llvm-gcc, not its src or obj directory.]
198*9880d681SAndroid Build Coastguard Worker
199*9880d681SAndroid Build Coastguard Worker#. You can now run the test suite from your build tree as follows:
200*9880d681SAndroid Build Coastguard Worker
201*9880d681SAndroid Build Coastguard Worker   .. code-block:: bash
202*9880d681SAndroid Build Coastguard Worker
203*9880d681SAndroid Build Coastguard Worker       % cd $LLVM_OBJ_ROOT/projects/test-suite
204*9880d681SAndroid Build Coastguard Worker       % make
205*9880d681SAndroid Build Coastguard Worker
206*9880d681SAndroid Build Coastguard WorkerNote that the second and third steps only need to be done once. After
207*9880d681SAndroid Build Coastguard Workeryou have the suite checked out and configured, you don't need to do it
208*9880d681SAndroid Build Coastguard Workeragain (unless the test code or configure script changes).
209*9880d681SAndroid Build Coastguard Worker
210*9880d681SAndroid Build Coastguard WorkerConfiguring External Tests
211*9880d681SAndroid Build Coastguard Worker--------------------------
212*9880d681SAndroid Build Coastguard Worker
213*9880d681SAndroid Build Coastguard WorkerIn order to run the External tests in the ``test-suite`` module, you
214*9880d681SAndroid Build Coastguard Workermust specify *--with-externals*. This must be done during the
215*9880d681SAndroid Build Coastguard Worker*re-configuration* step (see above), and the ``llvm`` re-configuration
216*9880d681SAndroid Build Coastguard Workermust recognize the previously-built ``llvm-gcc``. If any of these is
217*9880d681SAndroid Build Coastguard Workermissing or neglected, the External tests won't work.
218*9880d681SAndroid Build Coastguard Worker
219*9880d681SAndroid Build Coastguard Worker* *--with-externals*
220*9880d681SAndroid Build Coastguard Worker
221*9880d681SAndroid Build Coastguard Worker* *--with-externals=<directory>*
222*9880d681SAndroid Build Coastguard Worker
223*9880d681SAndroid Build Coastguard WorkerThis tells LLVM where to find any external tests. They are expected to
224*9880d681SAndroid Build Coastguard Workerbe in specifically named subdirectories of <``directory``>. If
225*9880d681SAndroid Build Coastguard Worker``directory`` is left unspecified, ``configure`` uses the default value
226*9880d681SAndroid Build Coastguard Worker``/home/vadve/shared/benchmarks/speccpu2000/benchspec``. Subdirectory
227*9880d681SAndroid Build Coastguard Workernames known to LLVM include:
228*9880d681SAndroid Build Coastguard Worker
229*9880d681SAndroid Build Coastguard Worker* spec95
230*9880d681SAndroid Build Coastguard Worker
231*9880d681SAndroid Build Coastguard Worker* speccpu2000
232*9880d681SAndroid Build Coastguard Worker
233*9880d681SAndroid Build Coastguard Worker* speccpu2006
234*9880d681SAndroid Build Coastguard Worker
235*9880d681SAndroid Build Coastguard Worker* povray31
236*9880d681SAndroid Build Coastguard Worker
237*9880d681SAndroid Build Coastguard WorkerOthers are added from time to time, and can be determined from
238*9880d681SAndroid Build Coastguard Worker``configure``.
239*9880d681SAndroid Build Coastguard Worker
240*9880d681SAndroid Build Coastguard WorkerRunning different tests
241*9880d681SAndroid Build Coastguard Worker-----------------------
242*9880d681SAndroid Build Coastguard Worker
243*9880d681SAndroid Build Coastguard WorkerIn addition to the regular "whole program" tests, the ``test-suite``
244*9880d681SAndroid Build Coastguard Workermodule also provides a mechanism for compiling the programs in different
245*9880d681SAndroid Build Coastguard Workerways. If the variable TEST is defined on the ``gmake`` command line, the
246*9880d681SAndroid Build Coastguard Workertest system will include a Makefile named
247*9880d681SAndroid Build Coastguard Worker``TEST.<value of TEST variable>.Makefile``. This Makefile can modify
248*9880d681SAndroid Build Coastguard Workerbuild rules to yield different results.
249*9880d681SAndroid Build Coastguard Worker
250*9880d681SAndroid Build Coastguard WorkerFor example, the LLVM nightly tester uses ``TEST.nightly.Makefile`` to
251*9880d681SAndroid Build Coastguard Workercreate the nightly test reports. To run the nightly tests, run
252*9880d681SAndroid Build Coastguard Worker``gmake TEST=nightly``.
253*9880d681SAndroid Build Coastguard Worker
254*9880d681SAndroid Build Coastguard WorkerThere are several TEST Makefiles available in the tree. Some of them are
255*9880d681SAndroid Build Coastguard Workerdesigned for internal LLVM research and will not work outside of the
256*9880d681SAndroid Build Coastguard WorkerLLVM research group. They may still be valuable, however, as a guide to
257*9880d681SAndroid Build Coastguard Workerwriting your own TEST Makefile for any optimization or analysis passes
258*9880d681SAndroid Build Coastguard Workerthat you develop with LLVM.
259*9880d681SAndroid Build Coastguard Worker
260*9880d681SAndroid Build Coastguard WorkerGenerating test output
261*9880d681SAndroid Build Coastguard Worker----------------------
262*9880d681SAndroid Build Coastguard Worker
263*9880d681SAndroid Build Coastguard WorkerThere are a number of ways to run the tests and generate output. The
264*9880d681SAndroid Build Coastguard Workermost simple one is simply running ``gmake`` with no arguments. This will
265*9880d681SAndroid Build Coastguard Workercompile and run all programs in the tree using a number of different
266*9880d681SAndroid Build Coastguard Workermethods and compare results. Any failures are reported in the output,
267*9880d681SAndroid Build Coastguard Workerbut are likely drowned in the other output. Passes are not reported
268*9880d681SAndroid Build Coastguard Workerexplicitly.
269*9880d681SAndroid Build Coastguard Worker
270*9880d681SAndroid Build Coastguard WorkerSomewhat better is running ``gmake TEST=sometest test``, which runs the
271*9880d681SAndroid Build Coastguard Workerspecified test and usually adds per-program summaries to the output
272*9880d681SAndroid Build Coastguard Worker(depending on which sometest you use). For example, the ``nightly`` test
273*9880d681SAndroid Build Coastguard Workerexplicitly outputs TEST-PASS or TEST-FAIL for every test after each
274*9880d681SAndroid Build Coastguard Workerprogram. Though these lines are still drowned in the output, it's easy
275*9880d681SAndroid Build Coastguard Workerto grep the output logs in the Output directories.
276*9880d681SAndroid Build Coastguard Worker
277*9880d681SAndroid Build Coastguard WorkerEven better are the ``report`` and ``report.format`` targets (where
278*9880d681SAndroid Build Coastguard Worker``format`` is one of ``html``, ``csv``, ``text`` or ``graphs``). The
279*9880d681SAndroid Build Coastguard Workerexact contents of the report are dependent on which ``TEST`` you are
280*9880d681SAndroid Build Coastguard Workerrunning, but the text results are always shown at the end of the run and
281*9880d681SAndroid Build Coastguard Workerthe results are always stored in the ``report.<type>.format`` file (when
282*9880d681SAndroid Build Coastguard Workerrunning with ``TEST=<type>``). The ``report`` also generate a file
283*9880d681SAndroid Build Coastguard Workercalled ``report.<type>.raw.out`` containing the output of the entire
284*9880d681SAndroid Build Coastguard Workertest run.
285*9880d681SAndroid Build Coastguard Worker
286*9880d681SAndroid Build Coastguard WorkerWriting custom tests for the test suite
287*9880d681SAndroid Build Coastguard Worker---------------------------------------
288*9880d681SAndroid Build Coastguard Worker
289*9880d681SAndroid Build Coastguard WorkerAssuming you can run the test suite, (e.g.
290*9880d681SAndroid Build Coastguard Worker"``gmake TEST=nightly report``" should work), it is really easy to run
291*9880d681SAndroid Build Coastguard Workeroptimizations or code generator components against every program in the
292*9880d681SAndroid Build Coastguard Workertree, collecting statistics or running custom checks for correctness. At
293*9880d681SAndroid Build Coastguard Workerbase, this is how the nightly tester works, it's just one example of a
294*9880d681SAndroid Build Coastguard Workergeneral framework.
295*9880d681SAndroid Build Coastguard Worker
296*9880d681SAndroid Build Coastguard WorkerLets say that you have an LLVM optimization pass, and you want to see
297*9880d681SAndroid Build Coastguard Workerhow many times it triggers. First thing you should do is add an LLVM
298*9880d681SAndroid Build Coastguard Worker`statistic <ProgrammersManual.html#Statistic>`_ to your pass, which will
299*9880d681SAndroid Build Coastguard Workertally counts of things you care about.
300*9880d681SAndroid Build Coastguard Worker
301*9880d681SAndroid Build Coastguard WorkerFollowing this, you can set up a test and a report that collects these
302*9880d681SAndroid Build Coastguard Workerand formats them for easy viewing. This consists of two files, a
303*9880d681SAndroid Build Coastguard Worker"``test-suite/TEST.XXX.Makefile``" fragment (where XXX is the name of
304*9880d681SAndroid Build Coastguard Workeryour test) and a "``test-suite/TEST.XXX.report``" file that indicates
305*9880d681SAndroid Build Coastguard Workerhow to format the output into a table. There are many example reports of
306*9880d681SAndroid Build Coastguard Workervarious levels of sophistication included with the test suite, and the
307*9880d681SAndroid Build Coastguard Workerframework is very general.
308*9880d681SAndroid Build Coastguard Worker
309*9880d681SAndroid Build Coastguard WorkerIf you are interested in testing an optimization pass, check out the
310*9880d681SAndroid Build Coastguard Worker"libcalls" test as an example. It can be run like this:
311*9880d681SAndroid Build Coastguard Worker
312*9880d681SAndroid Build Coastguard Worker.. code-block:: bash
313*9880d681SAndroid Build Coastguard Worker
314*9880d681SAndroid Build Coastguard Worker    % cd llvm/projects/test-suite/MultiSource/Benchmarks  # or some other level
315*9880d681SAndroid Build Coastguard Worker    % make TEST=libcalls report
316*9880d681SAndroid Build Coastguard Worker
317*9880d681SAndroid Build Coastguard WorkerThis will do a bunch of stuff, then eventually print a table like this:
318*9880d681SAndroid Build Coastguard Worker
319*9880d681SAndroid Build Coastguard Worker::
320*9880d681SAndroid Build Coastguard Worker
321*9880d681SAndroid Build Coastguard Worker    Name                                  | total | #exit |
322*9880d681SAndroid Build Coastguard Worker    ...
323*9880d681SAndroid Build Coastguard Worker    FreeBench/analyzer/analyzer           | 51    | 6     |
324*9880d681SAndroid Build Coastguard Worker    FreeBench/fourinarow/fourinarow       | 1     | 1     |
325*9880d681SAndroid Build Coastguard Worker    FreeBench/neural/neural               | 19    | 9     |
326*9880d681SAndroid Build Coastguard Worker    FreeBench/pifft/pifft                 | 5     | 3     |
327*9880d681SAndroid Build Coastguard Worker    MallocBench/cfrac/cfrac               | 1     | *     |
328*9880d681SAndroid Build Coastguard Worker    MallocBench/espresso/espresso         | 52    | 12    |
329*9880d681SAndroid Build Coastguard Worker    MallocBench/gs/gs                     | 4     | *     |
330*9880d681SAndroid Build Coastguard Worker    Prolangs-C/TimberWolfMC/timberwolfmc  | 302   | *     |
331*9880d681SAndroid Build Coastguard Worker    Prolangs-C/agrep/agrep                | 33    | 12    |
332*9880d681SAndroid Build Coastguard Worker    Prolangs-C/allroots/allroots          | *     | *     |
333*9880d681SAndroid Build Coastguard Worker    Prolangs-C/assembler/assembler        | 47    | *     |
334*9880d681SAndroid Build Coastguard Worker    Prolangs-C/bison/mybison              | 74    | *     |
335*9880d681SAndroid Build Coastguard Worker    ...
336*9880d681SAndroid Build Coastguard Worker
337*9880d681SAndroid Build Coastguard WorkerThis basically is grepping the -stats output and displaying it in a
338*9880d681SAndroid Build Coastguard Workertable. You can also use the "TEST=libcalls report.html" target to get
339*9880d681SAndroid Build Coastguard Workerthe table in HTML form, similarly for report.csv and report.tex.
340*9880d681SAndroid Build Coastguard Worker
341*9880d681SAndroid Build Coastguard WorkerThe source for this is in ``test-suite/TEST.libcalls.*``. The format is
342*9880d681SAndroid Build Coastguard Workerpretty simple: the Makefile indicates how to run the test (in this case,
343*9880d681SAndroid Build Coastguard Worker"``opt -simplify-libcalls -stats``"), and the report contains one line
344*9880d681SAndroid Build Coastguard Workerfor each column of the output. The first value is the header for the
345*9880d681SAndroid Build Coastguard Workercolumn and the second is the regex to grep the output of the command
346*9880d681SAndroid Build Coastguard Workerfor. There are lots of example reports that can do fancy stuff.
347