Page MenuHomePhabricator

[BOLT] Disable -lite when split function is present
AcceptedPublic

Authored by nhuhuan on Fri, Aug 5, 12:52 PM.

Details

Summary

In lite mode, BOLT only transforms a subset of functions, leave the
remaining functions intact.

For NoPIC, it is fine. BOLT can scan relocations and fix-up all refs
that point to any function body in the subset.

For no-split function PIC, it is fine. Since jump tables are intra-
procedural transfer, BOLT can find both the jump table base and the
target within same function. Thus, BOLT can update and/or move jump
tables.

However, it is wrong to process a subset of functions in split function
PIC. This is because BOLT does not know if functions in the subset are
isolated, i.e., cannot be accessed by functions out of the subset,
especially via split jump table.

For example, BOLT only process three functions A, B and C. Suppose that
A is reached via jump table from A.cold, which is not processed. When
A is moved (due to optimization), the jump table in A.cold is invalid.
We cannot fix-up this jump table since it is only recognized in A.cold,
which BOLT does not process.

Solution: Disable lite mode if split function is present.

Future improvement: In lite mode, if split function is found, BOLT
processes both functions in the subset and all of their sibling
fragments.

Test Plan:

ninja check-bolt

Diff Detail

Event Timeline

nhuhuan created this revision.Fri, Aug 5, 12:52 PM
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
nhuhuan requested review of this revision.Fri, Aug 5, 12:52 PM
Herald added a project: Restricted Project. · View Herald TranscriptFri, Aug 5, 12:52 PM
Amir added inline comments.Fri, Aug 5, 2:14 PM
bolt/lib/Rewrite/RewriteInstance.cpp
1443

Let's move it under !PrintedWarning to only print it once.

nhuhuan updated this revision to Diff 450419.Fri, Aug 5, 2:47 PM

Avoid printing duplicate warnings.

nhuhuan updated this revision to Diff 450420.Fri, Aug 5, 2:49 PM

Clang-formatted.

nhuhuan marked an inline comment as done.Fri, Aug 5, 2:49 PM
Amir accepted this revision.Fri, Aug 5, 3:01 PM

Thanks!

This revision is now accepted and ready to land.Fri, Aug 5, 3:01 PM
maksfb requested changes to this revision.Fri, Aug 5, 3:03 PM
maksfb added inline comments.
bolt/lib/Rewrite/RewriteInstance.cpp
1438

Check if the lite mode is enabled before issuing the warning.

This revision now requires changes to proceed.Fri, Aug 5, 3:03 PM
nhuhuan updated this revision to Diff 450433.Fri, Aug 5, 3:26 PM

Check before issue the warning.

nhuhuan marked an inline comment as done.Fri, Aug 5, 3:27 PM
maksfb accepted this revision.Fri, Aug 5, 3:50 PM
maksfb added inline comments.
bolt/lib/Rewrite/RewriteInstance.cpp
1440

nit: drop the trailing period.

This revision is now accepted and ready to land.Fri, Aug 5, 3:50 PM
nhuhuan updated this revision to Diff 450445.Fri, Aug 5, 4:21 PM

Remove trailing dots.

nhuhuan marked an inline comment as done.Fri, Aug 5, 4:22 PM