This is an archive of the discontinued LLVM Phabricator instance.

[ThinLTO] Add MODULE_CODE_METADATA_VALUES record
ClosedPublic

Authored by tejohnson on Nov 19 2015, 9:09 AM.

Details

Summary

This is split out from the ThinLTO metadata mapping patch
http://reviews.llvm.org/D14752.

To avoid needing to parse the module level metadata during function
importing, a new module-level record is added which holds the
number of module-level metadata values. This is required because
metadata value ids are assigned implicitly during parsing, and the
function-level metadata ids start after the module-level metadata ids.

I made a change to this version of the code compared to D14752
in order to add more consistent and thorough assertion checking of the
new record value. We now unconditionally use the record value to
initialize the MDValueList size, and handle it the same in parseMetadata
for all module level metadata cases (lazy loading or not).

Diff Detail

Repository
rL LLVM

Event Timeline

tejohnson updated this revision to Diff 40662.Nov 19 2015, 9:09 AM
tejohnson retitled this revision from to [ThinLTO] Add MODULE_CODE_METADATA_VALUES record.
tejohnson updated this object.
tejohnson added reviewers: dexonsmith, mehdi_amini.
tejohnson added subscribers: llvm-commits, davidxl.
mehdi_amini edited edge metadata.Nov 19 2015, 9:23 AM

Looks good overall, I need to do a second pass later, probably this afternoon.

lib/Bitcode/Reader/BitcodeReader.cpp
157 ↗(On Diff #40662)

One line comment for NumModuleMDs?

158 ↗(On Diff #40662)

I suggest to substitute "this" with "the MODULE_CODE_METADATA_VALUES"

1922 ↗(On Diff #40662)

Is it possible to have NextMDValueNo != 0 and SeenModuleValuesRecord? It there some redundancy here?

3292 ↗(On Diff #40662)

This change does not seem necessary here

5351 ↗(On Diff #40662)

remove

tejohnson marked 3 inline comments as done.Nov 19 2015, 9:30 AM

Thanks, comments addressed and will upload new patch in a moment.

lib/Bitcode/Reader/BitcodeReader.cpp
1922 ↗(On Diff #40662)

Yes when ModuleLevel=true because we always initialize the MDValueList size when we read the MODULE_CODE_METADATA_VALUES record (where we set SeenModuleValuesRecord). This reset ensures that we assign MD value numbers here properly for module level metadata.

3292 ↗(On Diff #40662)

Removed. Leftover from prior approach.

tejohnson updated this revision to Diff 40667.Nov 19 2015, 9:32 AM
tejohnson edited edge metadata.
  • Address Mehdi's comments.
mehdi_amini accepted this revision.Nov 19 2015, 3:28 PM
mehdi_amini edited edge metadata.

LGTM (with one question)

lib/Bitcode/Reader/BitcodeReader.cpp
1924 ↗(On Diff #40667)

I got a typo in my question, I meant: is it possible to have NextMDValueNo != 0 and *not* SeenModuleValuesRecord?

In the end my question is: do we need to check SeenModuleValuesRecord here? Is there a difference between this check and the following:

unsigned NextMDValueNo = ModuleLevel ? 0 : MDValueList.size();

(Not saying you should write it this way, but what about if (ModuleLevel) {)

This revision is now accepted and ready to land.Nov 19 2015, 3:28 PM
This revision was automatically updated to reflect the committed changes.