unsigned Spills = 0;
unsigned FoldedSpills = 0;
unsigned Copies = 0;
+ float ReloadsCost = 0.0f;
+ float FoldedReloadsCost = 0.0f;
+ float SpillsCost = 0.0f;
+ float FoldedSpillsCost = 0.0f;
+ float CopiesCost = 0.0f;
bool isEmpty() {
return !(Reloads || FoldedReloads || Spills || FoldedSpills ||
Spills += other.Spills;
FoldedSpills += other.FoldedSpills;
Copies += other.Copies;
+ ReloadsCost += other.ReloadsCost;
+ FoldedReloadsCost += other.FoldedReloadsCost;
+ SpillsCost += other.SpillsCost;
+ FoldedSpillsCost += other.FoldedSpillsCost;
+ CopiesCost += other.CopiesCost;
}
void report(MachineOptimizationRemarkMissed &R);
void RAGreedy::RAGreedyStats::report(MachineOptimizationRemarkMissed &R) {
using namespace ore;
- if (Spills)
+ if (Spills) {
R << NV("NumSpills", Spills) << " spills ";
- if (FoldedSpills)
+ R << NV("TotalSpillsCost", SpillsCost) << " total spills cost ";
+ }
+ if (FoldedSpills) {
R << NV("NumFoldedSpills", FoldedSpills) << " folded spills ";
- if (Reloads)
+ R << NV("TotalFoldedSpillsCost", FoldedSpillsCost)
+ << " total folded spills cost ";
+ }
+ if (Reloads) {
R << NV("NumReloads", Reloads) << " reloads ";
- if (FoldedReloads)
+ R << NV("TotalReloadsCost", ReloadsCost) << " total reloads cost ";
+ }
+ if (FoldedReloads) {
R << NV("NumFoldedReloads", FoldedReloads) << " folded reloads ";
+ R << NV("TotalFoldedReloadsCost", FoldedReloadsCost)
+ << " total folded reloads cost ";
+ }
if (ZeroCostFoldedReloads)
R << NV("NumZeroCostFoldedReloads", ZeroCostFoldedReloads)
<< " zero cost folded reloads ";
- if (Copies)
+ if (Copies) {
R << NV("NumVRCopies", Copies) << " virtual registers copies ";
+ R << NV("TotalCopiesCost", CopiesCost) << " total copies cost ";
+ }
}
RAGreedy::RAGreedyStats RAGreedy::computeStats(MachineBasicBlock &MBB) {
Stats.FoldedSpills += Accesses.size();
}
}
+ // Set cost of collected statistic by multiplication to relative frequency of
+ // this basic block.
+ float RelFreq = MBFI->getBlockFreqRelativeToEntryBlock(&MBB);
+ Stats.ReloadsCost = RelFreq * Stats.Reloads;
+ Stats.FoldedReloadsCost = RelFreq * Stats.FoldedReloads;
+ Stats.SpillsCost = RelFreq * Stats.Spills;
+ Stats.FoldedSpillsCost = RelFreq * Stats.FoldedSpills;
+ Stats.CopiesCost = RelFreq * Stats.Copies;
return Stats;
}
; RUN: -pass-remarks-with-hotness -pass-remarks-hotness-threshold=1 \
; RUN: 2>&1 | FileCheck -check-prefix=THRESHOLD %s
-; CHECK: remark: /tmp/kk.c:3:20: 1 spills 1 reloads generated in loop{{$}}
+; CHECK: remark: /tmp/kk.c:3:20: 1 spills 3.187500e+01 total spills cost 1 reloads 3.187500e+01 total reloads cost generated in loop{{$}}
; THRESHOLD-NOT: remark
define void @fpr128(<4 x float>* %p) nounwind ssp {
; then reloaded.
; (loop3:)
-; REMARK: remark: /tmp/kk.c:3:20: 1 spills 1 reloads generated in loop{{$}}
+; REMARK: remark: /tmp/kk.c:3:20: 1 spills 1.000000e+02 total spills cost 1 reloads 1.000000e+02 total reloads cost generated in loop{{$}}
; (loop2:)
-; REMARK: remark: /tmp/kk.c:2:20: 1 spills 1 reloads generated in loop{{$}}
+; REMARK: remark: /tmp/kk.c:2:20: 1 spills 1.000000e+04 total spills cost 1 reloads 1.000000e+04 total reloads cost generated in loop{{$}}
; (loop:)
-; REMARK: remark: /tmp/kk.c:1:20: 2 spills 2 reloads generated in loop{{$}}
+; REMARK: remark: /tmp/kk.c:1:20: 2 spills 1.010000e+04 total spills cost 2 reloads 1.010000e+04 total reloads cost generated in loop{{$}}
; (func:)
-; REMARK: remark: /tmp/kk.c:1:1: 3 spills 3 reloads generated in function{{$}}
+; REMARK: remark: /tmp/kk.c:1:1: 3 spills 1.020000e+04 total spills cost 3 reloads 1.020000e+04 total reloads cost generated in function
; (loop3:)
-; HOTNESS: remark: /tmp/kk.c:3:20: 1 spills 1 reloads generated in loop (hotness: 300)
+; HOTNESS: remark: /tmp/kk.c:3:20: 1 spills 1.000000e+02 total spills cost 1 reloads 1.000000e+02 total reloads cost generated in loop (hotness: 300)
; (loop2:)
-; HOTNESS: remark: /tmp/kk.c:2:20: 1 spills 1 reloads generated in loop (hotness: 30000)
+; HOTNESS: remark: /tmp/kk.c:2:20: 1 spills 1.000000e+04 total spills cost 1 reloads 1.000000e+04 total reloads cost generated in loop (hotness: 30000)
; (loop:)
-; HOTNESS: remark: /tmp/kk.c:1:20: 2 spills 2 reloads generated in loop (hotness: 300)
+; HOTNESS: remark: /tmp/kk.c:1:20: 2 spills 1.010000e+04 total spills cost 2 reloads 1.010000e+04 total reloads cost generated in loop (hotness: 300)
; NO_REMARK-NOT: remark
; THRESHOLD-NOT: (hotness: 300)
-; THRESHOLD: remark: /tmp/kk.c:2:20: 1 spills 1 reloads generated in loop (hotness: 30000)
+; THRESHOLD: remark: /tmp/kk.c:2:20: 1 spills 1.000000e+04 total spills cost 1 reloads 1.000000e+04 total reloads cost generated in loop (hotness: 30000)
; YAML: --- !Missed
; YAML: Pass: regalloc
; YAML: Args:
; YAML: - NumSpills: '1'
; YAML: - String: ' spills '
+; YAML: - TotalSpillsCost: '1.000000e+02'
+; YAML: - String: ' total spills cost '
; YAML: - NumReloads: '1'
; YAML: - String: ' reloads '
+; YAML: - TotalReloadsCost: '1.000000e+02'
+; YAML: - String: ' total reloads cost '
; YAML: - String: generated in loop
; YAML: ...
; YAML: --- !Missed
; YAML: Args:
; YAML: - NumSpills: '1'
; YAML: - String: ' spills '
+; YAML: - TotalSpillsCost: '1.000000e+04'
+; YAML: - String: ' total spills cost '
; YAML: - NumReloads: '1'
; YAML: - String: ' reloads '
+; YAML: - TotalReloadsCost: '1.000000e+04'
+; YAML: - String: ' total reloads cost '
; YAML: - String: generated in loop
; YAML: ...
; YAML: --- !Missed
; YAML: Args:
; YAML: - NumSpills: '2'
; YAML: - String: ' spills '
+; YAML: - TotalSpillsCost: '1.010000e+04'
+; YAML: - String: ' total spills cost '
; YAML: - NumReloads: '2'
; YAML: - String: ' reloads '
+; YAML: - TotalReloadsCost: '1.010000e+04'
+; YAML: - String: ' total reloads cost '
; YAML: - String: generated in loop
; YAML: ...
; YAML: --- !Missed
; YAML: Args:
; YAML: - NumSpills: '3'
; YAML: - String: ' spills '
+; YAML: - TotalSpillsCost: '1.020000e+04'
+; YAML: - String: ' total spills cost '
; YAML: - NumReloads: '3'
; YAML: - String: ' reloads '
+; YAML: - TotalReloadsCost: '1.020000e+04'
+; YAML: - String: ' total reloads cost '
; YAML: - String: generated in function
; YAML: ...
; THRESHOLD_YAML: Args:
; THRESHOLD_YAML: - NumSpills: '1'
; THRESHOLD_YAML: - String: ' spills '
+; THRESHOLD_YAML: - TotalSpillsCost: '1.000000e+04'
+; THRESHOLD_YAML: - String: ' total spills cost '
; THRESHOLD_YAML: - NumReloads: '1'
; THRESHOLD_YAML: - String: ' reloads '
+; THRESHOLD_YAML: - TotalReloadsCost: '1.000000e+04'
+; THRESHOLD_YAML: - String: ' total reloads cost '
; THRESHOLD_YAML: - String: generated in loop
; THRESHOLD_YAML: ...
;YAML: Args:
;YAML: - NumSpills: '10'
;YAML: - String: ' spills '
+;YAML: - TotalSpillsCost: '7.000000e+00'
+;YAML: - String: ' total spills cost '
;YAML: - NumReloads: '7'
;YAML: - String: ' reloads '
+;YAML: - TotalReloadsCost: '3.109004e-15'
+;YAML: - String: ' total reloads cost '
;YAML: - NumZeroCostFoldedReloads: '20'
;YAML: - String: ' zero cost folded reloads '
;YAML: - NumVRCopies: '2'
;YAML: - String: ' virtual registers copies '
+;YAML: - TotalCopiesCost: '8.882868e-16'
+;YAML: - String: ' total copies cost '
;YAML: - String: generated in function
define void @barney(i8 addrspace(1)* %arg, double %arg1, double %arg2, double %arg3, double %arg4, double %arg5, double %arg6, double %arg7, double %arg8, double %arg9, double %arg10, double %arg11, double %arg12) gc "statepoint-example" personality i32* ()* @widget {