This is an archive of the discontinued LLVM Phabricator instance.

[llvm] Handle missing debug info when updating sample counts
Needs ReviewPublic

Authored by mtrofin on May 6 2019, 1:20 PM.

Details

Reviewers
davidxl
wmi
Summary

Clear profiling metadata when trying to update it, and debug info is missing.

Event Timeline

mtrofin created this revision.May 6 2019, 1:20 PM
davidxl added inline comments.May 6 2019, 1:30 PM
llvm/test/Transforms/SampleProfile/entry_counts_missing_dbginfo.ll
4

Can you explain exactly what happens that triggers the div by zero? when bar is inlined?

mtrofin retitled this revision from [llv] Handle missing debug info when updating sample counts to [llvm] Handle missing debug info when updating sample counts.May 6 2019, 5:10 PM
mtrofin updated this revision to Diff 198389.May 6 2019, 8:11 PM
  • Comments, tests pass.
davidxl added inline comments.May 6 2019, 8:34 PM
llvm/lib/Transforms/IPO/SampleProfile.cpp
1667

why 'WantAccurateProfile' guard?

llvm/test/Transforms/SampleProfile/entry_counts_missing_dbginfo.ll
8

Needs clarification. When the function is not inlined, why is there need to update its profile? Can you point to the compiler source that does this?

mtrofin updated this revision to Diff 198391.May 6 2019, 9:01 PM
mtrofin marked an inline comment as done.
  • Comments, tests pass.
mtrofin marked 3 inline comments as done.May 6 2019, 9:19 PM
mtrofin added inline comments.
llvm/lib/Transforms/IPO/SampleProfile.cpp
1667

To avoid breaking existing tests & code. When we don't want accurate profiles, we set the entry count to -1 ("invalid"), which is recognized by existing code and handled appropriately.

However, come to think of it, that would still leave the prof data valid within the function. For consistency, we could perhaps set those to -1 as well.

I would prefer changing the current behavior in the non-precise case in a separate CL - thoughts?

llvm/test/Transforms/SampleProfile/entry_counts_missing_dbginfo.ll
8

Added more detail.

davidxl added inline comments.May 7 2019, 2:10 PM
llvm/test/Transforms/SampleProfile/entry_counts_missing_dbginfo.ll
8

what I meant is the what the callstack is when div by 0 happens. In particular, why the update occurs when there is no inline (as mentioned in the comment).

davidxl added inline comments.May 7 2019, 3:08 PM
llvm/lib/Transforms/Utils/InlineFunction.cpp
1472

See line 1468 above -- the priorEntryCount can be zero which will trigger assertion at 1473. line 1468 can be executed before becaue updateProfileCallee can be invoked in two different contexts:

  1. during inline transformation
  2. after sample loading for the function.
  1. can happen before 2).

In other words, the div by zero can still happen with when debug information is avaiable.