@@ -52,13 +52,34 @@ def run_once_with_primary(args, ast, rng, primary_idx):
52
52
inputs = [write_input_file (args , ast , d , i ) for i in rng ]
53
53
primary = inputs [primary_idx ]
54
54
ofile = os .path .join (d , "out.o" )
55
+
55
56
mode = "-c"
56
57
if args .parse :
57
58
mode = "-parse"
59
+
60
+ focus = ["-primary-file" , primary ]
61
+ if args .whole_module_optimization :
62
+ focus = ['-whole-module-optimization' ]
63
+
64
+ opts = []
65
+ if args .optimize :
66
+ opts = ['-O' ]
67
+ elif args .optimize_none :
68
+ opts = ['-Onone' ]
69
+ elif args .optimize_unchecked :
70
+ opts = ['-Ounchecked' ]
71
+
72
+ extra = args .Xfrontend [:]
73
+ if args .debuginfo :
74
+ extra .append ('-g' )
75
+
58
76
command = [args .swiftc_binary ,
59
77
"-frontend" , mode ,
60
- "-o" , ofile ,
61
- "-primary-file" , primary ] + inputs
78
+ "-o" , ofile ] + opts + focus + extra + inputs
79
+
80
+ if args .trace :
81
+ print "running: " + " " .join (command )
82
+
62
83
if args .dtrace :
63
84
trace = os .path .join (d , "trace.txt" )
64
85
script = "pid$target:swiftc:*%s*:entry { @[probefunc] = count() }" % args .select
@@ -164,11 +185,10 @@ def report(args, rng, runs):
164
185
b = 0 if abs (b ) < 1e-9 else b
165
186
rows .append ((b , k , vals ))
166
187
rows .sort ()
167
- tolerance = 1.2
168
188
for (b , k , vals ) in rows :
169
- if b >= tolerance :
189
+ if b >= args . threshold :
170
190
bad = True
171
- if not args .quiet or b >= tolerance :
191
+ if not args .quiet or b >= args . threshold :
172
192
print "O(n^%1.1f) : %s" % (b , k )
173
193
if args .values :
174
194
print " = " , vals
@@ -185,21 +205,30 @@ def main():
185
205
parser .add_argument (
186
206
'--values' , action = 'store_true' ,
187
207
default = False , help = 'print stat values' )
208
+ parser .add_argument (
209
+ '--trace' , action = 'store_true' ,
210
+ default = False , help = 'trace compiler invocations' )
188
211
parser .add_argument (
189
212
'--quiet' , action = 'store_true' ,
190
213
default = False , help = 'only print superlinear stats' )
191
214
parser .add_argument (
192
- '--parse' , action = 'store_true' ,
215
+ '--threshold' , type = float ,
216
+ default = 1.2 , help = 'exponent beyond which to consider "bad scaling"' )
217
+ parser .add_argument (
218
+ '-parse' , '--parse' , action = 'store_true' ,
193
219
default = False , help = 'only run compiler with -parse' )
220
+ parser .add_argument (
221
+ '-g' , '--debuginfo' , action = 'store_true' ,
222
+ default = False , help = 'run compiler with -g' )
223
+ parser .add_argument (
224
+ '-wmo' , '--whole-module-optimization' , action = 'store_true' ,
225
+ default = False , help = 'run compiler with -whole-module-optimization' )
194
226
parser .add_argument (
195
227
'--dtrace' , action = 'store_true' ,
196
228
default = False , help = 'use dtrace to sample all functions' )
197
229
parser .add_argument (
198
- '--multi-file' , action = 'store_true' ,
199
- default = False , help = 'vary number of input files as well' )
200
- parser .add_argument (
201
- '--sum-multi' , action = 'store_true' ,
202
- default = False , help = 'simulate a multi-primary run and sum stats' )
230
+ '-Xfrontend' , action = 'append' ,
231
+ default = [], help = 'pass additional args to frontend jobs' )
203
232
parser .add_argument (
204
233
'--begin' , type = int ,
205
234
default = 10 , help = 'first value for N' )
@@ -219,6 +248,25 @@ def main():
219
248
'--debug' , action = 'store_true' ,
220
249
default = False , help = 'invoke lldb on each scale test' )
221
250
251
+ group = parser .add_mutually_exclusive_group ()
252
+ group .add_argument (
253
+ '-O' , '--optimize' , action = 'store_true' ,
254
+ default = False , help = 'run compiler with -O' )
255
+ group .add_argument (
256
+ '-Onone' , '--optimize-none' , action = 'store_true' ,
257
+ default = False , help = 'run compiler with -Onone' )
258
+ group .add_argument (
259
+ '-Ounchecked' , '--optimize-unchecked' , action = 'store_true' ,
260
+ default = False , help = 'run compiler with -Ounchecked' )
261
+
262
+ group = parser .add_mutually_exclusive_group ()
263
+ group .add_argument (
264
+ '--multi-file' , action = 'store_true' ,
265
+ default = False , help = 'vary number of input files as well' )
266
+ group .add_argument (
267
+ '--sum-multi' , action = 'store_true' ,
268
+ default = False , help = 'simulate a multi-primary run and sum stats' )
269
+
222
270
args = parser .parse_args (sys .argv [1 :])
223
271
(rng , runs ) = run_many (args )
224
272
if report (args , rng , runs ):
0 commit comments