This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Manage section naming/cloning in RewriteInstance
Needs ReviewPublic

Authored by treapster on Mar 16 2023, 10:01 AM.

Details

Summary

This is a first step towards -rewrite option from D144560.

EFMM after https://reviews.llvm.org/D135494 managed section names in the
following manner: if a section was emitted with orgSecPrefix, it updated
original BinarySection, and if it was emitted with original name, the
section was duplicated with newSecPrefix. The problem is that we can't
control what name is used to emit .text or .eh_frame, and the old code
made it impossible to rewrite these sections in-place(correct me if i'm wrong). Here we remove
all the management from EFMM and explicitly rename sections in
RewriteInstance if we want them duplicated, or don't touch them when we
rewrite, thus allowing EFMM to update them. We also have to rename some
sections like eh_frame back in case they were not emitted, which is a
bit combersome, but overall we get more flexibility over what sections
we want and under which names. In case of -reorder-data pass, i think
the simplest solution is to just create new section with .hot suffix,
and emit it under this name.

Diff Detail

Event Timeline

treapster created this revision.Mar 16 2023, 10:01 AM
Herald added a reviewer: Amir. · View Herald Transcript
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: ayermolo. · View Herald Transcript
treapster requested review of this revision.Mar 16 2023, 10:01 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 16 2023, 10:01 AM
treapster added inline comments.Mar 16 2023, 3:28 PM
bolt/lib/Core/BinaryEmitter.cpp
1162

I'm somewhat confused about this part because intuitively we should not have relocations for .bolt.org sections, but there are such cases(e.g instrumentation-dup-jts test) and i'm not sure sure it's ok to not emit them, but it's working.. I'll dig more into it.
As of .text, we should probably fail on assert here if it has relocations?