This is an archive of the discontinued LLVM Phabricator instance.

[BOLT][YAML] Only read first profile per function
ClosedPublic

Authored by Amir on Sep 18 2023, 6:17 PM.

Details

Reviewers
rafauler
maksfb
Group Reviewers
Restricted Project
Commits
rG6a1cf545cc0b: [BOLT][YAML] Only read first profile per function
Summary

D159460 regressed the bugfix in D156644. Fix that and emit a warning.
Add a test case.

Diff Detail

Event Timeline

Amir created this revision.Sep 18 2023, 6:17 PM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Amir requested review of this revision.Sep 18 2023, 6:17 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 18 2023, 6:17 PM
maksfb added inline comments.Sep 18 2023, 6:28 PM
bolt/lib/Profile/YAMLProfileReader.cpp
307

Unneeded.

Amir added inline comments.Sep 18 2023, 6:36 PM
bolt/lib/Profile/YAMLProfileReader.cpp
307

It is needed because the attaching happens in lines 341-354. Preliminary exec count assignment is a suitable place where it's easy/cheap to check if the profile was attached already.

maksfb added inline comments.Sep 18 2023, 6:49 PM
bolt/lib/Profile/YAMLProfileReader.cpp
307

Then you need auto &BF.

Amir added inline comments.Sep 18 2023, 8:07 PM
bolt/lib/Profile/YAMLProfileReader.cpp
307

As discussed offline, this structured binding expands into reference types so modifying BF here has an effect.

Amir added inline comments.Sep 18 2023, 8:11 PM
bolt/lib/Profile/YAMLProfileReader.cpp
307

Relevant note from Programmer's Manual:

Note that the elements are provided through a ‘reference wrapper’ proxy type (tuple of references), which combined with the structured bindings declaration makes Letter and Count references to range elements. Any modification to these references will affect the elements of Letters or Counts.

https://llvm.org/docs/ProgrammersManual.html#the-zip-functions

maksfb accepted this revision.Sep 18 2023, 8:32 PM
maksfb added inline comments.
bolt/lib/Profile/YAMLProfileReader.cpp
307

Cool.

This revision is now accepted and ready to land.Sep 18 2023, 8:32 PM
This revision was automatically updated to reflect the committed changes.