2014-04-01 06:45:37 +08:00
|
|
|
# -*- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
2016-02-20 01:52:28 +08:00
|
|
|
def get_required_attr(config, attr_name):
|
|
|
|
attr_value = getattr(config, attr_name, None)
|
|
|
|
if attr_value == None:
|
|
|
|
lit_config.fatal(
|
|
|
|
"No attribute %r in test configuration! You may need to run "
|
|
|
|
"tests from your build directory or add this attribute "
|
2019-06-28 04:56:04 +08:00
|
|
|
"to lit.site.cfg.py " % attr_name)
|
2016-02-20 01:52:28 +08:00
|
|
|
return attr_value
|
|
|
|
|
2014-04-01 06:45:37 +08:00
|
|
|
# Setup config name.
|
2016-02-20 01:52:28 +08:00
|
|
|
config.name = 'Profile-' + config.target_arch
|
2014-04-01 06:45:37 +08:00
|
|
|
|
|
|
|
# Setup source root.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
2014-04-01 07:14:28 +08:00
|
|
|
# Setup executable root.
|
|
|
|
if hasattr(config, 'profile_lit_binary_dir') and \
|
|
|
|
config.profile_lit_binary_dir is not None:
|
2016-02-20 01:52:28 +08:00
|
|
|
config.test_exec_root = os.path.join(config.profile_lit_binary_dir, config.name)
|
2014-04-01 07:14:28 +08:00
|
|
|
|
2014-10-08 03:24:24 +08:00
|
|
|
if config.host_os in ['Linux']:
|
2017-01-10 12:33:04 +08:00
|
|
|
extra_link_flags = ["-ldl"]
|
[InstrProf] Implement static profdata registration
Summary:
The motivating use case is eliminating duplicate profile data registered
for the same inline function in two object files. Before this change,
users would observe multiple symbol definition errors with VC link, but
links with LLD would succeed.
Users (Mozilla) have reported that PGO works well with clang-cl and LLD,
but when using LLD without this static registration, we would get into a
"relocation against a discarded section" situation. I'm not sure what
happens in that situation, but I suspect that duplicate, unused profile
information was retained. If so, this change will reduce the size of
such binaries with LLD.
Now, Windows uses static registration and is in line with all the other
platforms.
Reviewers: davidxl, wmi, inglorion, void, calixte
Subscribers: mgorny, krytarowski, eraman, fedor.sergeev, hiraditya, #sanitizers, dmajor, llvm-commits
Tags: #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D57929
llvm-svn: 353547
2019-02-09 03:03:50 +08:00
|
|
|
elif config.host_os in ['Windows']:
|
|
|
|
# InstrProf is incompatible with incremental linking. Disable it as a
|
|
|
|
# workaround.
|
|
|
|
extra_link_flags = ["-Wl,-incremental:no"]
|
2014-10-08 03:24:24 +08:00
|
|
|
else:
|
2017-01-10 12:33:04 +08:00
|
|
|
extra_link_flags = []
|
2014-10-08 03:24:24 +08:00
|
|
|
|
2014-04-01 06:45:37 +08:00
|
|
|
# Test suffixes.
|
2019-08-05 21:42:31 +08:00
|
|
|
config.suffixes = ['.c', '.cpp', '.m', '.mm', '.ll', '.test']
|
2014-04-01 06:45:37 +08:00
|
|
|
|
2014-05-16 09:30:24 +08:00
|
|
|
# What to exclude.
|
|
|
|
config.excludes = ['Inputs']
|
|
|
|
|
2014-05-01 05:32:30 +08:00
|
|
|
# Clang flags.
|
2016-02-20 01:52:28 +08:00
|
|
|
target_cflags=[get_required_attr(config, "target_cflags")]
|
2017-01-10 12:33:04 +08:00
|
|
|
clang_cflags = target_cflags + extra_link_flags
|
2016-02-20 01:52:28 +08:00
|
|
|
clang_cxxflags = config.cxx_mode_flags + clang_cflags
|
2014-05-01 05:32:30 +08:00
|
|
|
|
2016-10-12 05:48:48 +08:00
|
|
|
def build_invocation(compile_flags, with_lto = False):
|
|
|
|
lto_flags = []
|
|
|
|
lto_prefix = []
|
|
|
|
if with_lto and config.lto_supported:
|
|
|
|
lto_flags += config.lto_flags
|
|
|
|
lto_prefix += config.lto_launch
|
|
|
|
return " " + " ".join(lto_prefix + [config.clang] + lto_flags + compile_flags) + " "
|
2014-05-01 05:32:30 +08:00
|
|
|
|
2014-04-01 06:45:37 +08:00
|
|
|
# Add clang substitutions.
|
2014-05-21 06:04:27 +08:00
|
|
|
config.substitutions.append( ("%clang ", build_invocation(clang_cflags)) )
|
2016-02-20 01:52:28 +08:00
|
|
|
config.substitutions.append( ("%clangxx ", build_invocation(clang_cxxflags)) )
|
2014-05-01 05:32:30 +08:00
|
|
|
config.substitutions.append( ("%clang_profgen ", build_invocation(clang_cflags) + " -fprofile-instr-generate ") )
|
2016-06-12 12:17:57 +08:00
|
|
|
config.substitutions.append( ("%clang_profgen=", build_invocation(clang_cflags) + " -fprofile-instr-generate=") )
|
2016-07-20 05:55:55 +08:00
|
|
|
config.substitutions.append( ("%clang_pgogen ", build_invocation(clang_cflags) + " -fprofile-generate ") )
|
|
|
|
config.substitutions.append( ("%clang_pgogen=", build_invocation(clang_cflags) + " -fprofile-generate=") )
|
|
|
|
|
2016-02-20 01:52:28 +08:00
|
|
|
config.substitutions.append( ("%clangxx_profgen ", build_invocation(clang_cxxflags) + " -fprofile-instr-generate ") )
|
2016-08-01 09:54:40 +08:00
|
|
|
config.substitutions.append( ("%clangxx_profgen=", build_invocation(clang_cxxflags) + " -fprofile-instr-generate=") )
|
2016-07-20 05:55:55 +08:00
|
|
|
config.substitutions.append( ("%clangxx_pgogen ", build_invocation(clang_cxxflags) + " -fprofile-generate ") )
|
2016-08-01 09:54:40 +08:00
|
|
|
config.substitutions.append( ("%clangxx_pgogen=", build_invocation(clang_cxxflags) + " -fprofile-generate=") )
|
2016-07-20 05:55:55 +08:00
|
|
|
|
2015-07-10 01:21:52 +08:00
|
|
|
config.substitutions.append( ("%clang_profgen_gcc=", build_invocation(clang_cflags) + " -fprofile-generate=") )
|
|
|
|
config.substitutions.append( ("%clang_profuse_gcc=", build_invocation(clang_cflags) + " -fprofile-use=") )
|
2014-04-01 06:45:37 +08:00
|
|
|
|
2016-07-20 05:55:55 +08:00
|
|
|
config.substitutions.append( ("%clang_profuse=", build_invocation(clang_cflags) + " -fprofile-instr-use=") )
|
|
|
|
config.substitutions.append( ("%clangxx_profuse=", build_invocation(clang_cxxflags) + " -fprofile-instr-use=") )
|
|
|
|
|
2016-10-12 05:48:48 +08:00
|
|
|
config.substitutions.append( ("%clang_lto_profgen=", build_invocation(clang_cflags, True) + " -fprofile-instr-generate=") )
|
|
|
|
|
[InstrProf] Port test suite to Windows
Summary:
Before this change, check-profile would run, but all tests would be
marked unsupported on Windows. This is the new status of 'check-profile'
after this change:
Testing Time: 6.66s
Expected Passes : 29
Expected Failures : 5
Unsupported Tests : 39
I moved many tests that exercise posix-y features like dlopen and DSOs
into the Posix subdirectory, and ran the tests on Linux to validate my
changes.
These are the remaining tests that I handled on a case by case basis:
- instrprof-path.c
Passes, Fixed some path portability issues
- instrprof-gcov-exceptions.test
Passes, the FileCheck actually succeeds on Windows, so I RUNX'd it
- instrprof-icall-promo.test
XFAILed, probably due to C++ ABI differences in vtables
- instrprof-merge-match.test
- instrprof-merge.c
- instrprof-merging.cpp
XFAILed, These seem like real bugs that need fixing
- instrprof-version-mismatch.c
XFAILed, Overriding the weak version symbol doesn't work
- instrprof-without-libc.c
UNSUPPORTED, test needs an executable symbol table, Windows has none
Reviewers: davidxl, wmi, void
Subscribers: fedor.sergeev, #sanitizers, llvm-commits
Tags: #sanitizers
Differential Revision: https://reviews.llvm.org/D57853
llvm-svn: 353435
2019-02-08 01:52:05 +08:00
|
|
|
if config.host_os not in ['Windows', 'Darwin', 'FreeBSD', 'Linux', 'NetBSD', 'SunOS']:
|
2014-04-01 06:45:37 +08:00
|
|
|
config.unsupported = True
|
2014-10-09 05:13:23 +08:00
|
|
|
|
|
|
|
if config.target_arch in ['armv7l']:
|
|
|
|
config.unsupported = True
|
2017-10-12 05:22:32 +08:00
|
|
|
|
|
|
|
if config.android:
|
|
|
|
config.unsupported = True
|