Page MenuHomePhabricator

[llvm-profdata] Add SaturatingAdd/SaturatingMultiply Helper Functions
ClosedPublic

Authored by slingn on Nov 16 2015, 11:41 AM.

Details

Summary

This change adds MathExtras helper functions for handling unsigned, saturating addition and multiplication. It also updates the instrumentation and sample profile merge implementations to use them.

No functional changes.

Diff Detail

Repository
rL LLVM

Event Timeline

slingn updated this revision to Diff 40317.Nov 16 2015, 11:41 AM
slingn retitled this revision from to [llvm-profdata] Add SaturatingAdd/SaturatingMultiply Helper Functions.
slingn updated this object.
slingn added reviewers: dnovillo, davidxl, bogner.
slingn added a subscriber: llvm-commits.
slingn updated this object.Nov 16 2015, 11:42 AM

Related question:

Is it by design that intstr profile count overflow is treated differently from sample profile count overflow?
Instr profile merging appears to skip records that would result in overflow and print a warning. Sample profile count overflow saturates and does not show a warning.

davidxl edited edge metadata.Nov 16 2015, 7:45 PM
davidxl added a subscriber: davidxl.

The way InstrProf handles overflow is a little extreme (by skipping the
record for the whole function). I think Using saturating add with some form
of warning is better.

David

This revision was automatically updated to reflect the committed changes.
dnovillo edited edge metadata.Nov 19 2015, 5:03 AM

Related question:

Is it by design that intstr profile count overflow is treated differently from sample profile count overflow?
Instr profile merging appears to skip records that would result in overflow and print a warning. Sample profile count overflow saturates and does not show a warning.

Sample PGO will warn when the weights read from the profile saturate 32-bit values. Showing a warning in llvm-profdata when adding 64 bit values sounds like a good idea.