2017-01-06 21:33:48 +00:00
|
|
|
llvm_canonicalize_cmake_booleans(
|
|
|
|
LLVM_TOOL_LTO_BUILD
|
|
|
|
HAVE_OCAMLOPT
|
|
|
|
HAVE_OCAML_OUNIT
|
|
|
|
LLVM_INCLUDE_GO_TESTS
|
|
|
|
LLVM_USE_INTEL_JITEVENTS
|
|
|
|
HAVE_LIBZ
|
|
|
|
HAVE_LIBXAR
|
|
|
|
LLVM_ENABLE_DIA_SDK
|
2017-01-06 21:33:54 +00:00
|
|
|
LLVM_ENABLE_FFI
|
|
|
|
BUILD_SHARED_LIBS)
|
2017-01-06 21:33:48 +00:00
|
|
|
|
2012-06-28 06:36:24 +00:00
|
|
|
configure_lit_site_cfg(
|
2011-11-04 23:04:05 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
2012-06-28 06:36:24 +00:00
|
|
|
)
|
|
|
|
configure_lit_site_cfg(
|
2011-11-04 23:04:05 +00:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
|
2012-06-28 06:36:24 +00:00
|
|
|
)
|
2009-09-22 07:38:44 +00:00
|
|
|
|
2012-10-10 13:33:00 +00:00
|
|
|
# Don't include check-llvm into check-all without LLVM_BUILD_TOOLS.
|
|
|
|
if(NOT LLVM_BUILD_TOOLS)
|
|
|
|
set(EXCLUDE_FROM_ALL ON)
|
|
|
|
endif()
|
|
|
|
|
2012-11-21 20:38:26 +00:00
|
|
|
# Set the depends list as a variable so that it can grow conditionally.
|
2013-10-28 23:37:49 +00:00
|
|
|
# NOTE: Sync the substitutions in test/lit.cfg when adding to this list.
|
2013-07-08 08:44:30 +00:00
|
|
|
set(LLVM_TEST_DEPENDS
|
|
|
|
BugpointPasses
|
2015-11-12 19:34:21 +00:00
|
|
|
FileCheck
|
2013-07-08 08:44:30 +00:00
|
|
|
LLVMHello
|
2015-11-12 19:34:21 +00:00
|
|
|
UnitTests
|
2014-03-04 16:13:30 +00:00
|
|
|
bugpoint
|
2015-11-12 19:34:21 +00:00
|
|
|
count
|
2013-07-08 08:44:30 +00:00
|
|
|
llc
|
|
|
|
lli
|
2013-10-02 22:27:23 +00:00
|
|
|
lli-child-target
|
2013-07-08 08:44:30 +00:00
|
|
|
llvm-ar
|
|
|
|
llvm-as
|
|
|
|
llvm-bcanalyzer
|
2013-10-23 17:57:04 +00:00
|
|
|
llvm-c-test
|
2016-11-29 20:43:47 +00:00
|
|
|
llvm-cat
|
2016-09-06 19:16:48 +00:00
|
|
|
llvm-cxxfilt
|
2015-11-12 19:34:21 +00:00
|
|
|
llvm-config
|
2013-07-08 08:44:36 +00:00
|
|
|
llvm-cov
|
2015-03-15 01:30:58 +00:00
|
|
|
llvm-cxxdump
|
2017-04-21 20:45:11 +00:00
|
|
|
llvm-cvtres
|
2013-07-08 08:44:30 +00:00
|
|
|
llvm-diff
|
|
|
|
llvm-dis
|
2017-07-18 21:26:38 +00:00
|
|
|
llvm-dlltool
|
2014-12-12 17:31:24 +00:00
|
|
|
llvm-dsymutil
|
2013-07-08 08:44:30 +00:00
|
|
|
llvm-dwarfdump
|
2015-12-01 00:57:05 +00:00
|
|
|
llvm-dwp
|
2014-10-23 02:33:23 +00:00
|
|
|
llvm-extract
|
2017-09-03 03:00:27 +00:00
|
|
|
llvm-isel-fuzzer
|
2015-06-09 21:50:22 +00:00
|
|
|
llvm-lib
|
2012-11-01 02:13:50 +00:00
|
|
|
llvm-link
|
2016-08-11 14:58:12 +00:00
|
|
|
llvm-lto2
|
2012-11-01 02:13:50 +00:00
|
|
|
llvm-mc
|
|
|
|
llvm-mcmarkup
|
2016-11-29 21:54:33 +00:00
|
|
|
llvm-modextract
|
2017-07-20 22:13:16 +00:00
|
|
|
llvm-mt
|
2012-11-01 02:13:50 +00:00
|
|
|
llvm-nm
|
2017-08-01 00:33:58 +00:00
|
|
|
llvm-objcopy
|
2012-11-01 02:13:50 +00:00
|
|
|
llvm-objdump
|
Add an llvm-opt-report tool to generate basic source-annotated optimization summaries
LLVM now has the ability to record information from optimization remarks in a
machine-consumable YAML file for later analysis. This can be enabled in opt
(see r282539), and D25225 adds a Clang flag to do the same. This patch adds
llvm-opt-report, a tool to generate basic optimization "listing" files
(annotated sources with information about what optimizations were performed)
from one of these YAML inputs.
D19678 proposed to add this capability directly to Clang, but this more-general
YAML-based infrastructure was the direction we decided upon in that review
thread.
For this optimization report, I focused on making the output as succinct as
possible while providing information on inlining and loop transformations. The
goal here is that the source code should still be easily readable in the
report. My primary inspiration here is the reports generated by Cray's tools
(http://docs.cray.com/books/S-2496-4101/html-S-2496-4101/z1112823641oswald.html).
These reports are highly regarded within the HPC community. Intel's compiler,
for example, also has an optimization-report capability
(https://software.intel.com/sites/default/files/managed/55/b1/new-compiler-optimization-reports.pdf).
$ cat /tmp/v.c
void bar();
void foo() { bar(); }
void Test(int *res, int *c, int *d, int *p, int n) {
int i;
#pragma clang loop vectorize(assume_safety)
for (i = 0; i < 1600; i++) {
res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
}
for (i = 0; i < 16; i++) {
res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
}
foo();
foo(); bar(); foo();
}
D25225 adds -fsave-optimization-record (and
-fsave-optimization-record=filename), and this would be used as follows:
$ clang -O3 -o /tmp/v.o -c /tmp/v.c -fsave-optimization-record
$ llvm-opt-report /tmp/v.yaml > /tmp/v.lst
$ cat /tmp/v.lst
< /tmp/v.c
2 | void bar();
3 | void foo() { bar(); }
4 |
5 | void Test(int *res, int *c, int *d, int *p, int n) {
6 | int i;
7 |
8 | #pragma clang loop vectorize(assume_safety)
9 V4,2 | for (i = 0; i < 1600; i++) {
10 | res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
11 | }
12 |
13 U16 | for (i = 0; i < 16; i++) {
14 | res[i] = (p[i] == 0) ? res[i] : res[i] + d[i];
15 | }
16 |
17 I | foo();
18 |
19 | foo(); bar(); foo();
I | ^
I | ^
20 | }
Each source line gets a prefix giving the line number, and a few columns for
important optimizations: inlining, loop unrolling and loop vectorization. An
'I' is printed next to a line where a function was inlined, a 'U' next to an
unrolled loop, and 'V' next to a vectorized loop. These are printed on the
relevant code line when that seems unambiguous, or on subsequent lines when
multiple potential options exist (messages, both positive and negative, from
the same optimization with different column numbers are taken to indicate
potential ambiguity). When on subsequent lines, a '^' is output in the relevant
column.
Annotated source for all relevant input files are put into the listing file
(each starting with '<' and then the file name).
You can disable having the unrolling/vectorization factors appear by using the
-s flag.
Differential Revision: https://reviews.llvm.org/D25262
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@283398 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-05 22:10:35 +00:00
|
|
|
llvm-opt-report
|
2017-06-09 20:46:17 +00:00
|
|
|
llvm-pdbutil
|
2014-02-17 23:22:49 +00:00
|
|
|
llvm-profdata
|
2014-12-04 01:34:11 +00:00
|
|
|
llvm-ranlib
|
2017-07-25 01:44:38 +00:00
|
|
|
llvm-rc
|
2012-11-01 02:13:50 +00:00
|
|
|
llvm-readobj
|
2017-07-19 02:09:37 +00:00
|
|
|
llvm-readelf
|
2013-01-25 23:24:07 +00:00
|
|
|
llvm-rtdyld
|
2014-12-04 01:27:53 +00:00
|
|
|
llvm-size
|
2015-08-21 02:48:20 +00:00
|
|
|
llvm-split
|
2016-11-12 03:45:21 +00:00
|
|
|
llvm-strings
|
2013-03-13 09:35:18 +00:00
|
|
|
llvm-symbolizer
|
2014-01-18 19:01:08 +00:00
|
|
|
llvm-tblgen
|
2016-10-26 04:16:05 +00:00
|
|
|
llvm-xray
|
2013-07-08 08:44:30 +00:00
|
|
|
not
|
|
|
|
obj2yaml
|
2015-11-12 19:34:21 +00:00
|
|
|
opt
|
|
|
|
sancov
|
2016-01-16 00:31:11 +00:00
|
|
|
sanstats
|
2014-07-30 17:11:27 +00:00
|
|
|
verify-uselistorder
|
2015-11-12 19:34:21 +00:00
|
|
|
yaml-bench
|
|
|
|
yaml2obj
|
2013-07-08 08:44:30 +00:00
|
|
|
)
|
2012-11-21 20:38:26 +00:00
|
|
|
|
2016-06-02 16:29:07 +00:00
|
|
|
if(TARGET llvm-lto)
|
|
|
|
set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-lto)
|
|
|
|
endif()
|
|
|
|
|
2012-11-21 20:38:26 +00:00
|
|
|
# If Intel JIT events are supported, depend on a tool that tests the listener.
|
|
|
|
if( LLVM_USE_INTEL_JITEVENTS )
|
|
|
|
set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-jitlistener)
|
|
|
|
endif( LLVM_USE_INTEL_JITEVENTS )
|
|
|
|
|
2014-09-10 22:20:49 +00:00
|
|
|
if(TARGET LLVMgold)
|
|
|
|
set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LLVMgold)
|
|
|
|
endif()
|
|
|
|
|
2014-10-23 19:51:40 +00:00
|
|
|
if(TARGET llvm-go)
|
|
|
|
set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} llvm-go)
|
|
|
|
endif()
|
|
|
|
|
2016-06-02 16:29:07 +00:00
|
|
|
if(TARGET LTO)
|
2015-03-19 23:55:38 +00:00
|
|
|
set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS} LTO)
|
|
|
|
endif()
|
|
|
|
|
2016-11-12 14:58:30 +00:00
|
|
|
if(LLVM_BUILD_EXAMPLES)
|
|
|
|
list(APPEND LLVM_TEST_DEPENDS
|
|
|
|
Kaleidoscope-Ch3
|
|
|
|
Kaleidoscope-Ch4
|
|
|
|
Kaleidoscope-Ch5
|
|
|
|
Kaleidoscope-Ch6
|
|
|
|
Kaleidoscope-Ch7
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:50:23 +00:00
|
|
|
if(TARGET ocaml_llvm)
|
2016-11-12 14:58:30 +00:00
|
|
|
# Clear all non-OCaml cross-target dependencies when building out-of-tree.
|
|
|
|
if(LLVM_OCAML_OUT_OF_TREE)
|
|
|
|
set(LLVM_TEST_DEPENDS)
|
|
|
|
endif()
|
|
|
|
|
2014-12-01 19:50:23 +00:00
|
|
|
set(LLVM_TEST_DEPENDS ${LLVM_TEST_DEPENDS}
|
|
|
|
ocaml_llvm
|
|
|
|
ocaml_llvm_all_backends
|
|
|
|
ocaml_llvm_analysis
|
|
|
|
ocaml_llvm_bitreader
|
|
|
|
ocaml_llvm_bitwriter
|
|
|
|
ocaml_llvm_executionengine
|
|
|
|
ocaml_llvm_irreader
|
|
|
|
ocaml_llvm_linker
|
|
|
|
ocaml_llvm_target
|
|
|
|
ocaml_llvm_ipo
|
|
|
|
ocaml_llvm_passmgr_builder
|
|
|
|
ocaml_llvm_scalar_opts
|
2014-12-01 19:50:39 +00:00
|
|
|
ocaml_llvm_transform_utils
|
2014-12-01 19:50:23 +00:00
|
|
|
ocaml_llvm_vectorize
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2016-03-02 00:27:14 +00:00
|
|
|
add_custom_target(llvm-test-depends DEPENDS ${LLVM_TEST_DEPENDS})
|
2016-04-12 15:09:14 +00:00
|
|
|
set_target_properties(llvm-test-depends PROPERTIES FOLDER "Tests")
|
2016-03-02 00:27:14 +00:00
|
|
|
|
2012-11-21 20:38:26 +00:00
|
|
|
add_lit_testsuite(check-llvm "Running the LLVM regression tests"
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
PARAMS llvm_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
|
|
llvm_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
|
|
|
|
DEPENDS ${LLVM_TEST_DEPENDS}
|
2012-06-27 09:44:16 +00:00
|
|
|
)
|
2012-06-30 10:14:14 +00:00
|
|
|
set_target_properties(check-llvm PROPERTIES FOLDER "Tests")
|
2010-12-10 02:15:36 +00:00
|
|
|
|
2015-03-25 08:07:47 +00:00
|
|
|
add_lit_testsuites(LLVM ${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
PARAMS llvm_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
|
|
|
|
llvm_unit_site_config=${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg
|
|
|
|
DEPENDS ${LLVM_TEST_DEPENDS}
|
|
|
|
)
|
|
|
|
|
2012-06-27 09:44:16 +00:00
|
|
|
# Setup a legacy alias for 'check-llvm'. This will likely change to be an
|
|
|
|
# alias for 'check-all' at some point in the future.
|
2012-07-02 21:45:22 +00:00
|
|
|
add_custom_target(check)
|
|
|
|
add_dependencies(check check-llvm)
|
2012-06-30 10:14:14 +00:00
|
|
|
set_target_properties(check PROPERTIES FOLDER "Tests")
|