[PATCH] D97592: [PGO] Fix two issues in PGOMemOPSizeOpt.

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 26 15:23:10 PST 2021


yamauchi created this revision.
yamauchi added a reviewer: davidxl.
Herald added subscribers: wenlei, hiraditya.
yamauchi requested review of this revision.
Herald added projects: Sanitizers, LLVM.
Herald added a subscriber: Sanitizers.

1. PGOMemOPSizeOpt grabs only the first, up to five (by default) entries from

the value profile metadata and preserves the remaining entries for the fallback
memop call site. If there are more than five entries, the rest of the entries
would get dropped. This is fine for PGOMemOPSizeOpt itself as it only promotes
up to 3 (by default) values, but potentially not for other downstream passes
that may use the value profile metadata.

2. PGOMemOPSizeOpt originally assumed that only values 0 through 8 are kept

track of. When the range buckets were introduced, it was changed to skip the
range buckets, but since it does not grab all entries (only five), if some range
buckets exist in the first five entries, it could potentially cause fewer
promotion opportunities (eg. if 4 out of 5 were range buckets, it may be able to
promote up to one non-range bucket, as opposed to 3.) Also, combined with 1, it
means that wrong entries may be preserved, as it didn't correctly keep track of
which were entries were skipped.

To fix this, PGOMemOPSizeOpt now grabs all the entries (up to the maximum number
of value profile buckets), keeps track of which entries were skipped, and
preserves all the remaining entries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97592

Files:
  compiler-rt/include/profile/InstrProfData.inc
  llvm/include/llvm/ProfileData/InstrProfData.inc
  llvm/lib/Transforms/Instrumentation/PGOMemOPSizeOpt.cpp
  llvm/test/Transforms/PGOProfile/memop_size_opt.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97592.326821.patch
Type: text/x-patch
Size: 10461 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210226/a1fc4627/attachment.bin>


More information about the llvm-commits mailing list