diff options
author | Rafael Auler <rafaelauler@fb.com> | 2023-05-16 12:04:03 -0700 |
---|---|---|
committer | Rafael Auler <rafaelauler@fb.com> | 2023-05-16 14:54:16 -0700 |
commit | 62a2feff5784bcee3c7b037501956552acdf736c (patch) | |
tree | 82ad9bcf29afbe900884a095ed362be7b162a819 /bolt/lib/Rewrite/BinaryPassManager.cpp | |
parent | 32ab0978dc3f7f7036df2038ee96a4ab89196255 (diff) | |
download | llvm-62a2feff5784bcee3c7b037501956552acdf736c.zip llvm-62a2feff5784bcee3c7b037501956552acdf736c.tar.gz llvm-62a2feff5784bcee3c7b037501956552acdf736c.tar.bz2 |
[BOLT] Fix state of MCSymbols in lowering pass
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, add a new
clean 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.
Reviewed By: #bolt, Amir
Differential Revision: https://reviews.llvm.org/D137984
Diffstat (limited to 'bolt/lib/Rewrite/BinaryPassManager.cpp')
-rw-r--r-- | bolt/lib/Rewrite/BinaryPassManager.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/bolt/lib/Rewrite/BinaryPassManager.cpp b/bolt/lib/Rewrite/BinaryPassManager.cpp index 53a45ab..dd00d62 100644 --- a/bolt/lib/Rewrite/BinaryPassManager.cpp +++ b/bolt/lib/Rewrite/BinaryPassManager.cpp @@ -488,6 +488,10 @@ void BinaryFunctionPassManager::runAllPasses(BinaryContext &BC) { Manager.registerPass(std::make_unique<LowerAnnotations>(NeverPrint)); + // Check for dirty state of MCSymbols caused by running calculateEmittedSize + // in parallel and restore them + Manager.registerPass(std::make_unique<CleanMCState>(NeverPrint)); + Manager.runPasses(); } |