Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CMake] Support generation of linker order files using dtrace
Summary: This patch extends the lit-based perf-training tooling supplied for PGO data generation to also generate linker order files using dtrace. This patch should work on any system that has dtrace. If CMake can find the dtrace tool it will generate a target 'generate-order-file' which will run the per-training tests wrapped by dtrace to capture function entries. There are several algorithms implemented for sorting the order files which can be experimented with for best performance. The dtrace wrapper also supports bot oneshot and pid probes. The perf-helper.py changes to support order file construction are ported from internal changes by ddunbar; he gets all the credit for the hard work here, I just copy and pasted. Note: I've tested these patches on FreeBSD and OS X 10.10. Reviewers: ddunbar, bogner, silvas Subscribers: llvm-commits, emaste Differential Revision: http://reviews.llvm.org/D16134 llvm-svn: 257934
- Loading branch information
Chris Bieneman
committed
Jan 15, 2016
1 parent
44b3f96
commit d8b5bde
Showing
4 changed files
with
408 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- Python -*- | ||
|
||
from lit import Test | ||
import lit.formats | ||
import lit.util | ||
import os | ||
|
||
def getSysrootFlagsOnDarwin(config, lit_config): | ||
# On Darwin, support relocatable SDKs by providing Clang with a | ||
# default system root path. | ||
if 'darwin' in config.target_triple: | ||
try: | ||
out = lit.util.capture(['xcrun', '--show-sdk-path']).strip() | ||
res = 0 | ||
except OSError: | ||
res = -1 | ||
if res == 0 and out: | ||
sdk_path = out | ||
lit_config.note('using SDKROOT: %r' % sdk_path) | ||
return '-isysroot %s' % sdk_path | ||
return '' | ||
|
||
sysroot_flags = getSysrootFlagsOnDarwin(config, lit_config) | ||
|
||
config.clang = os.path.realpath(lit.util.which('clang', config.clang_tools_dir)).replace('\\', '/') | ||
|
||
config.name = 'Clang Perf Training' | ||
config.suffixes = ['.c', '.cpp', '.m', '.mm', '.cu', '.ll', '.cl', '.s', '.S', '.modulemap'] | ||
|
||
dtrace_wrapper = '%s %s/perf-helper.py dtrace' % (config.python_exe, config.test_source_root) | ||
|
||
use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") | ||
config.test_format = lit.formats.ShTest(use_lit_shell == "0") | ||
config.substitutions.append( ('%clang_cpp', ' %s %s --driver-mode=cpp %s ' % (dtrace_wrapper, config.clang, sysroot_flags))) | ||
config.substitutions.append( ('%clang_cc1', ' %s %s -cc1 %s ' % (dtrace_wrapper, config.clang, sysroot_flags))) | ||
config.substitutions.append( ('%clang', ' %s %s %s ' % (dtrace_wrapper, config.clang, sysroot_flags) ) ) | ||
config.substitutions.append( ('%test_root', config.test_exec_root ) ) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import sys | ||
|
||
## Autogenerated by LLVM/Clang configuration. | ||
# Do not edit! | ||
config.clang_tools_dir = "@CLANG_TOOLS_DIR@" | ||
config.test_exec_root = "@CMAKE_CURRENT_BINARY_DIR@" | ||
config.test_source_root = "@CMAKE_CURRENT_SOURCE_DIR@" | ||
config.target_triple = "@TARGET_TRIPLE@" | ||
config.python_exe = "@PYTHON_EXECUTABLE@" | ||
|
||
# Support substitution of the tools and libs dirs with user parameters. This is | ||
# used when we can't determine the tool dir at configuration time. | ||
try: | ||
config.clang_tools_dir = config.clang_tools_dir % lit_config.params | ||
except KeyError: | ||
e = sys.exc_info()[1] | ||
key, = e.args | ||
lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) | ||
|
||
# Let the main config do the real work. | ||
lit_config.load_config(config, "@CLANG_SOURCE_DIR@/utils/perf-training/order-files.lit.cfg") |
Oops, something went wrong.