This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Mark fragments related to split jump table as non-simple
ClosedPublic

Authored by nhuhuan on Jun 9 2022, 6:48 PM.

Details

Summary

Mark fragments related to split jump table as non-simple.

A function could be splitted into hot and cold fragments. A split jump table is
challenging for correctly reconstructing control flow graphs, so it was marked
as ignored. This update marks those fragments as non-simple, allowing them
to be printed and partial control flow graph construction.

Test Plan:

llvm-lit -a tools/bolt/test/X86/split-func-icf.s

This test has two functions (main, main2), each has a jump table target to the
same cold portion main2.cold.1(*2). We try to print out only this cold portion.
If it is ignored, it cannot be printed. If it is non-simple, it can be printed. We
verify that it can be printed.

Diff Detail

Event Timeline

nhuhuan created this revision.Jun 9 2022, 6:48 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.Jun 9 2022, 6:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptJun 9 2022, 6:48 PM
nhuhuan updated this revision to Diff 435765.Jun 9 2022, 7:06 PM

Update the warning messages

nhuhuan updated this revision to Diff 435769.Jun 9 2022, 7:15 PM

update FileCheck rules

nhuhuan retitled this revision from mark skipped fragments as non-simple to Mark fragments related to split jump table as non-simple.Jun 9 2022, 7:29 PM
nhuhuan edited the summary of this revision. (Show Details)
nhuhuan retitled this revision from Mark fragments related to split jump table as non-simple to [BOLT] Mark fragments related to split jump table as non-simple.Jun 9 2022, 7:31 PM
nhuhuan updated this revision to Diff 436026.Jun 10 2022, 1:23 PM

Propagate hasSplitJumpTable property to all relevant fragments.
Update assertion to address split jump table cases.

Amir added inline comments.Jun 10 2022, 1:36 PM
bolt/lib/Core/BinaryContext.cpp
709

This lambda is for adding to a worklist and filtering out repetitions. Let's keep it this way and move this line down to setSimple

nhuhuan updated this revision to Diff 436033.Jun 10 2022, 1:40 PM

Move the propagation of hasSplitJumpTable out of the lambda.

Amir accepted this revision.Jun 10 2022, 1:47 PM

Please update the test plan (test name).
LGTM otherwise

This revision is now accepted and ready to land.Jun 10 2022, 1:47 PM
nhuhuan added a comment.EditedJun 10 2022, 1:49 PM

Fixed.
The assertion guarantees that non-simple functions are either an empty function or has no relocation, which is not the case for split jump table.
We propagate hasSplitJumpTable to all fragments that can reach or be reached by the fragment with split jump table. Then we use this property to make an exception for the assertion.

Example:

FragmentA:

  • has split jump table target FragmentA.cold

FragmentB:

  • has direct jump to FragmentA.cold

FragmentA.cold.1:

  • some code

Initially, the property HasSplitJumpTable of FragmentA is set to true.
Propagate to FragmentA.cold.1, so the property of FragmentA.cold.1 is also set to true.
FragmentB, despite not having split jump table, is also set to true because it reaches the non-simple fragment FragmentA.cold.1.

nhuhuan edited the summary of this revision. (Show Details)Jun 10 2022, 2:46 PM
This revision was automatically updated to reflect the committed changes.
hzq added a subscriber: hzq.Apr 23 2023, 12:48 AM

@nhuhuan Hello, see issue 62307, add this patch in the use of a problem, can you help to see?