Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: pydir/szbuild.py

Issue 1147023007: Subzero: Basic Block Profiler. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Adds Basic Block Profiling. Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 #!/usr/bin/env python2 1 #!/usr/bin/env python2
2 2
3 import argparse 3 import argparse
4 import os 4 import os
5 import pipes 5 import pipes
6 import re 6 import re
7 import sys 7 import sys
8 8
9 from utils import shellcmd 9 from utils import shellcmd
10 from utils import FindBaseNaCl 10 from utils import FindBaseNaCl
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 argparser.add_argument('-O', default='2', dest='optlevel', 78 argparser.add_argument('-O', default='2', dest='optlevel',
79 choices=['m1', '-1', '0', '1', '2'], 79 choices=['m1', '-1', '0', '1', '2'],
80 help='Optimization level ' + 80 help='Optimization level ' +
81 '(m1 and -1 are equivalent).' + 81 '(m1 and -1 are equivalent).' +
82 ' Default %(default)s.') 82 ' Default %(default)s.')
83 argparser.add_argument('--filetype', default='iasm', dest='filetype', 83 argparser.add_argument('--filetype', default='iasm', dest='filetype',
84 choices=['obj', 'asm', 'iasm'], 84 choices=['obj', 'asm', 'iasm'],
85 help='Output file type. Default %(default)s.') 85 help='Output file type. Default %(default)s.')
86 argparser.add_argument('--sandbox', dest='sandbox', action='store_true', 86 argparser.add_argument('--sandbox', dest='sandbox', action='store_true',
87 help='Enabled sandboxing in the translator') 87 help='Enabled sandboxing in the translator')
88 argparser.add_argument('--enable-block-profile', dest='enable_block_profile' ,
Jim Stichnoth 2015/06/08 23:45:31 80-col
John 2015/06/09 15:36:17 Done.
89 action='store_true',
90 help='Enabled Basic Block profiling.')
Jim Stichnoth 2015/06/08 23:45:30 Enabled ==> Enable and lowercase "basic block" Al
John 2015/06/09 15:36:17 Done.
88 argparser.add_argument('--verbose', '-v', dest='verbose', 91 argparser.add_argument('--verbose', '-v', dest='verbose',
89 action='store_true', 92 action='store_true',
90 help='Display some extra debugging output') 93 help='Display some extra debugging output')
91 argparser.add_argument('--sz', dest='sz_args', action='append', default=[], 94 argparser.add_argument('--sz', dest='sz_args', action='append', default=[],
92 help='Extra arguments for Subzero') 95 help='Extra arguments for Subzero')
93 argparser.add_argument('--llc', dest='llc_args', action='append', 96 argparser.add_argument('--llc', dest='llc_args', action='append',
94 default=[], help='Extra arguments for llc') 97 default=[], help='Extra arguments for llc')
95 98
96 def main(): 99 def main():
97 """Create a hybrid translation from Subzero and llc. 100 """Create a hybrid translation from Subzero and llc.
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 # Run pnacl-sz regardless of hybrid mode. 213 # Run pnacl-sz regardless of hybrid mode.
211 shellcmd([pnacl_sz, 214 shellcmd([pnacl_sz,
212 '-O' + opt_level, 215 '-O' + opt_level,
213 '-bitcode-format=pnacl', 216 '-bitcode-format=pnacl',
214 '-filetype=' + args.filetype, 217 '-filetype=' + args.filetype,
215 '-o', obj_sz if args.filetype == 'obj' else asm_sz] + 218 '-o', obj_sz if args.filetype == 'obj' else asm_sz] +
216 (['-externalize', 219 (['-externalize',
217 '-ffunction-sections', 220 '-ffunction-sections',
218 '-fdata-sections'] if hybrid else []) + 221 '-fdata-sections'] if hybrid else []) +
219 (['-sandbox'] if args.sandbox else []) + 222 (['-sandbox'] if args.sandbox else []) +
223 (['-enable-block-profile'] if args.enable_block_profile and not args.sandbox else []) +
Jim Stichnoth 2015/06/08 23:45:30 80-col
John 2015/06/09 15:36:17 Done.
220 args.sz_args + 224 args.sz_args +
221 [pexe], 225 [pexe],
222 echo=args.verbose) 226 echo=args.verbose)
223 if args.filetype != 'obj': 227 if args.filetype != 'obj':
224 shellcmd(( 228 shellcmd((
225 'llvm-mc -triple={triple} -filetype=obj -o {obj} {asm}' 229 'llvm-mc -triple={triple} -filetype=obj -o {obj} {asm}'
226 ).format(asm=asm_sz, obj=obj_sz, 230 ).format(asm=asm_sz, obj=obj_sz,
227 triple='i686-nacl' if args.sandbox else 'i686'), 231 triple='i686-nacl' if args.sandbox else 'i686'),
228 echo=args.verbose) 232 echo=args.verbose)
229 if not args.sandbox: 233 if not args.sandbox:
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 '--defsym=__Sz_AbsoluteZero=0 ' + 304 '--defsym=__Sz_AbsoluteZero=0 ' +
301 '-o {exe}' 305 '-o {exe}'
302 ).format(gold=gold, linklib=linklib, partial=obj_partial, exe=exe, 306 ).format(gold=gold, linklib=linklib, partial=obj_partial, exe=exe,
303 root=nacl_root), 307 root=nacl_root),
304 echo=args.verbose) 308 echo=args.verbose)
305 else: 309 else:
306 shellcmd(( 310 shellcmd((
307 '{ld} -m32 {partial} -o {exe} ' + 311 '{ld} -m32 {partial} -o {exe} ' +
308 # Keep the rest of this command line (except szrt_native_x8632.o) in 312 # Keep the rest of this command line (except szrt_native_x8632.o) in
309 # sync with RunHostLD() in pnacl-translate.py. 313 # sync with RunHostLD() in pnacl-translate.py.
310 '{root}/toolchain/linux_x86/pnacl_newlib_raw/translator/' + 314 '{root}/toolchain/linux_x86/pnacl_newlib/translator/x86-32-linux/' +
Jim Stichnoth 2015/06/08 23:45:31 Please keep pnacl_newlib_raw instead of pnacl_newl
John 2015/06/09 15:36:17 Done.
311 'x86-32-linux/lib/' + 315 'lib/{{unsandboxed_irt,irt_random,irt_query_list}}.o ' +
312 '{{unsandboxed_irt,irt_random,irt_query_list}}.o ' +
313 '{root}/toolchain_build/src/subzero/build/runtime/' + 316 '{root}/toolchain_build/src/subzero/build/runtime/' +
314 'szrt_native_x8632.o -lpthread -lrt ' + 317 'szrt_native_x8632.o -lpthread -lrt ' +
315 '-Wl,--defsym=__Sz_AbsoluteZero=0' 318 '-Wl,--defsym=__Sz_AbsoluteZero=0'
316 ).format(ld=linker, partial=obj_partial, exe=exe, root=nacl_root), 319 ).format(ld=linker, partial=obj_partial, exe=exe, root=nacl_root),
317 echo=args.verbose) 320 echo=args.verbose)
318 321
319 # Put the extra verbose printing at the end. 322 # Put the extra verbose printing at the end.
320 if args.verbose: 323 if args.verbose:
321 print 'PATH: {path}'.format(path=path_addition) 324 print 'PATH: {path}'.format(path=path_addition)
322 if hybrid: 325 if hybrid:
323 print 'include={regex}'.format(regex=re_include_str) 326 print 'include={regex}'.format(regex=re_include_str)
324 print 'exclude={regex}'.format(regex=re_exclude_str) 327 print 'exclude={regex}'.format(regex=re_exclude_str)
325 print 'default_match={dm}'.format(dm=default_match) 328 print 'default_match={dm}'.format(dm=default_match)
326 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms)) 329 print 'Number of Subzero syms = {num}'.format(num=len(sz_syms))
327 330
328 if __name__ == '__main__': 331 if __name__ == '__main__':
329 main() 332 main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698