This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt][profile] Add padding after binary IDs
ClosedPublic

Authored by leonardchan on Sep 21 2021, 11:08 AM.

Details

Summary

Some tests with binary IDs would fail with error: no profile can be merged. This is because raw profiles could have unaligned headers when emitting binary IDs. This means padding should be emitted after binary IDs are emitted to ensure everything else is aligned. This patch accounts for that padding in __llvm_write_binary_ids.

Diff Detail

Event Timeline

leonardchan created this revision.Sep 21 2021, 11:08 AM
leonardchan requested review of this revision.Sep 21 2021, 11:08 AM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptSep 21 2021, 11:08 AM
Herald added subscribers: llvm-commits, Restricted Project. · View Herald Transcript
leonardchan added reviewers: gulfem, phosek.

Is this ready for review?

leonardchan retitled this revision from [WIP][compiler-rt][profile] Fixes for failing profile tests to [compiler-rt][profile] Add padding after binary IDs.
leonardchan edited the summary of this revision. (Show Details)
leonardchan added a reviewer: davidxl.

Is this ready for review?

Yup, ready now.

phosek added inline comments.Sep 22 2021, 4:41 PM
compiler-rt/lib/profile/InstrProfilingPlatformLinux.c
183

Since WriteBinaryIds isn't used from anywhere else, I'd just combine the two functions.

leonardchan marked an inline comment as done.
phosek accepted this revision.Sep 22 2021, 6:06 PM

LGTM

This revision is now accepted and ready to land.Sep 22 2021, 6:06 PM

Thanks for the fix @leonardchan
Other type of paddings are added in:
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingBuffer.c#L86

Do you think we can follow the same pattern?

Thanks for the fix @leonardchan
Other type of paddings are added in:
https://github.com/llvm/llvm-project/blob/main/compiler-rt/lib/profile/InstrProfilingBuffer.c#L86

Do you think we can follow the same pattern?

That could work, but I think that would mean needing to call __llvm_profile_get_padding_sizes_for_counters after each instance we call __llvm_write_binary_ids when we instead could just pack it in __llvm_write_binary_ids. I imagine this is much simpler.

This revision was landed with ongoing or failed builds.Sep 23 2021, 10:30 AM
This revision was automatically updated to reflect the committed changes.

This appears to have broken PPC bots:
https://lab.llvm.org/buildbot/#/builders/105/builds/15291
https://lab.llvm.org/buildbot/#/builders/121/builds/11749

If you don't have an easy fix, please revert.

I have a fix up at https://reviews.llvm.org/D110365 but it looks like it's not ready to land yet. Feel free to revert it now if you can. I'm not at my keyboard right now.