@@ -267,14 +267,14 @@ module Crystal
267
267
object_names = units.map & .object_filename
268
268
269
269
target_triple = target_machine.triple
270
- reused = 0
270
+ reused = [] of String
271
271
272
272
Crystal .timing(" Codegen (bc+obj)" , @stats ) do
273
273
if units.size == 1
274
274
first_unit = units.first
275
275
276
276
codegen_single_unit(program, first_unit, target_triple)
277
- reused += 1 if first_unit.reused_previous_compilation?
277
+ reused << first_unit.name if first_unit.reused_previous_compilation?
278
278
279
279
if emit = @emit
280
280
first_unit.emit(emit, emit_base_filename || output_filename)
@@ -297,12 +297,12 @@ module Crystal
297
297
end
298
298
end
299
299
300
- {units.size , reused}
300
+ {units, reused}
301
301
end
302
302
303
303
private def codegen_many_units (program , units , target_triple )
304
304
jobs_count = 0
305
- reused = 0
305
+ reused = [] of String
306
306
wait_channel = Channel (Nil ).new(@n_threads )
307
307
308
308
# For stats output we want to count how many previous
@@ -311,8 +311,8 @@ module Crystal
311
311
if @stats
312
312
pr, pw = IO .pipe
313
313
spawn do
314
- pr.each_byte do |byte |
315
- reused += byte
314
+ pr.each_line do |line |
315
+ reused << line
316
316
end
317
317
end
318
318
end
@@ -325,7 +325,7 @@ module Crystal
325
325
slice.each do |unit |
326
326
codegen_single_unit(program, unit, target_triple)
327
327
if pipe_w && unit.reused_previous_compilation?
328
- pipe_w.write_byte( 1 _ u8 )
328
+ pipe_w.puts unit.name
329
329
end
330
330
end
331
331
end
@@ -370,16 +370,22 @@ module Crystal
370
370
return unless @stats
371
371
return unless result
372
372
373
- units_size , reused = result
373
+ units , reused = result
374
374
375
375
puts
376
376
puts " Codegen (bc+obj):"
377
- if units_size == reused
377
+ if units.size == reused.size
378
378
puts " - all previous .o files were reused"
379
- elsif reused == 0
379
+ elsif reused.size == 0
380
380
puts " - no previous .o files were reused"
381
381
else
382
- puts " - #{ reused } /#{ units_size } .o files were reused"
382
+ puts " - #{ reused.size } /#{ units.size } .o files were reused"
383
+ not_reused = units.reject { |u | reused.includes?(u.name) }
384
+ puts
385
+ puts " These modules were not reused:"
386
+ not_reused.each do |unit |
387
+ puts " - #{ unit.original_name } (#{ unit.name } .bc)"
388
+ end
383
389
end
384
390
end
385
391
@@ -455,12 +461,15 @@ module Crystal
455
461
# An LLVM::Module with information to compile it.
456
462
class CompilationUnit
457
463
getter compiler
464
+ getter name
465
+ getter original_name
458
466
getter llvm_mod
459
467
getter? reused_previous_compilation = false
460
468
461
469
def initialize (@compiler : Compiler , @name : String , @llvm_mod : LLVM ::Module ,
462
470
@output_dir : String , @bc_flags_changed : Bool )
463
471
@name = " _main" if @name == " "
472
+ @original_name = @name
464
473
@name = String .build do |str |
465
474
@name .each_char do |char |
466
475
case char
0 commit comments