This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Fix state of MCSymbols in lowering pass
Needs ReviewPublic

Authored by rafauler on May 10 2023, 6:48 PM.

Details

Reviewers
Amir
maksfb
Group Reviewers
Restricted Project
Summary

We have mostly harmless data races when running
BinaryContext::calculateEmittedSize() in parallel, while performing
split function pass. However, it is possible to end up in a state
where some MCSymbols are still registered and our clean up
failed. This happens rarely but it does happen, and when it happens,
it is a difficult to diagnose heisenbug. To avoid this, change our
lowering pass to perform a last check on MCSymbols, before they
undergo our final emission pass, to verify that they are in a sane
state. If we fail to do this, we might resolve some symbols to zero
and crash the output binary.

Diff Detail

Event Timeline

rafauler created this revision.May 10 2023, 6:48 PM
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
rafauler requested review of this revision.May 10 2023, 6:48 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 10 2023, 6:48 PM
Amir added a comment.May 10 2023, 8:29 PM

Can you please run clang-format?

rafauler updated this revision to Diff 521378.May 11 2023, 11:13 AM

Not sure what's off format. Removing an extra new line just in case.

Amir added a comment.May 11 2023, 1:22 PM

Regarding testing: can we come up with some synthetic test with 1000s or millions of (non-zero) symbols and check their values after BOLT with forced split-functions?

Amir added a comment.May 11 2023, 2:05 PM

I mean leveraging altmacro to define a million functions with two basic blocks each, and force splitting them with split-functions=all.