@@ -96,6 +96,17 @@ function(_construct_sources_for_multibench sources_out objfile_out)
96
96
set (${objfile_out} ${objfiles} PARENT_SCOPE )
97
97
endfunction ()
98
98
99
+ function (add_opt_view opt_view_main_dir, module_name, opt_view_dir_out )
100
+ set (opt_view_dir "${opt_view_main_dir} /${module_name} " )
101
+ set (opt_record "${objdir} /${module_name} .opt.yaml" )
102
+ set (opt_viewer "${LLVM_BUILD_MAIN_SRC_DIR} /tools/opt-viewer/opt-viewer.py" )
103
+ add_custom_command (
104
+ OUTPUT ${opt_view_dir}
105
+ DEPENDS "${objfile} "
106
+ COMMAND ${opt_viewer} ${opt_record} "-o" ${opt_view_dir} )
107
+ set (${opt_view_dir_out} ${opt_view_dir} PARENT_SCOPE )
108
+ endfunction ()
109
+
99
110
# Regular whole-module-compilation: only a single object file is
100
111
# generated.
101
112
function (add_swift_multisource_wmo_benchmark_library objfile_out )
@@ -201,14 +212,14 @@ function (swift_benchmark_compile_archopts)
201
212
"-no-link-objc-runtime"
202
213
"-I" "${srcdir} /utils/ObjectiveCTests" )
203
214
204
- set (optview_main_dir )
215
+ set (opt_view_main_dir )
205
216
if (SWIFT_BENCHMARK_GENERATE_OPT_VIEW AND LLVM_HAVE_OPT_VIEWER_MODULES )
206
217
precondition (SWIFT_BENCHMARK_BUILT_STANDALONE NEGATE
207
218
"Opt-viewer is not supported when running the benchmarks outside the Swift tree" )
208
219
209
220
if (NOT ${optflag} STREQUAL "Onone" AND "${bench_flags} " MATCHES "-whole-module.*" )
210
221
list (APPEND common_options "-save-optimization-record" )
211
- set (optview_main_dir "${objdir} /opt-view" )
222
+ set (opt_view_main_dir "${objdir} /opt-view" )
212
223
endif ()
213
224
endif ()
214
225
@@ -337,14 +348,10 @@ function (swift_benchmark_compile_archopts)
337
348
"${source} " )
338
349
endif ()
339
350
340
- if (optview_main_dir )
341
- set (opt_record "${objdir} /${module_name} .opt.yaml" )
342
- set (opt_viewer "${LLVM_BUILD_MAIN_SRC_DIR} /tools/opt-viewer/opt-viewer.py" )
343
- set (opt_view_dir "${optview_main_dir} /${module_name} " )
344
- add_custom_command (
345
- OUTPUT ${opt_view_dir}
346
- DEPENDS "${objfile} "
347
- COMMAND ${opt_viewer} ${opt_record} "-o" ${opt_view_dir} )
351
+ if (opt_view_main_dir )
352
+ set (opt_view_dir )
353
+ add_opt_view (${opt_view_main_dir} , ${module_name} , opt_view_dir )
354
+ precondition (opt_view_dir )
348
355
list (APPEND opt_view_dirs ${opt_view_dir} )
349
356
endif ()
350
357
endif ()
@@ -365,6 +372,13 @@ function (swift_benchmark_compile_archopts)
365
372
DEPENDS ${bench_library_objects} ${stdlib_dependencies} )
366
373
precondition (objfile_out )
367
374
list (APPEND SWIFT_BENCH_OBJFILES "${objfile_out} " )
375
+
376
+ if (opt_view_main_dir )
377
+ set (opt_view_dir )
378
+ add_opt_view (${opt_view_main_dir} , ${module_name} , opt_view_dir )
379
+ precondition (opt_view_dir )
380
+ list (APPEND opt_view_dirs ${opt_view_dir} )
381
+ endif ()
368
382
else ()
369
383
set (objfiles_out )
370
384
add_swift_multisource_nonwmo_benchmark_library (objfiles_out
@@ -394,6 +408,13 @@ function (swift_benchmark_compile_archopts)
394
408
DEPENDS ${bench_library_objects} ${stdlib_dependencies} )
395
409
precondition (objfile_out )
396
410
list (APPEND SWIFT_BENCH_OBJFILES "${objfile_out} " )
411
+
412
+ if (opt_view_main_dir )
413
+ set (opt_view_dir )
414
+ add_opt_view (${opt_view_main_dir} , ${module_name} , opt_view_dir )
415
+ precondition (opt_view_dir )
416
+ list (APPEND opt_view_dirs ${opt_view_dir} )
417
+ endif ()
397
418
else ()
398
419
set (objfiles_out )
399
420
add_swift_multisource_nonwmo_benchmark_library (objfiles_out
0 commit comments