[BOLT][AArch64] add lock to FixRelaxations pass
authorDenis Revunov <revunov.denis@huawei-partners.com>
Wed, 11 Jan 2023 08:38:47 +0000 (03:38 -0500)
committerDenis Revunov <revunov.denis@huawei-partners.com>
Wed, 11 Jan 2023 10:05:42 +0000 (05:05 -0500)
Since the pass is multithreaded, BC.Ctx must be protected. Otherwise we get crashes when processing.

Reviewed by: yota9

Differential Revision: https://reviews.llvm.org/D141465

bolt/lib/Passes/FixRelaxationPass.cpp

index 549624f..3dd19b6 100644 (file)
@@ -39,6 +39,7 @@ void FixRelaxations::runOnFunction(BinaryFunction &BF) {
       if (!Symbol || AdrpSymbol == Symbol)
         continue;
 
+      auto L = BC.scopeLock();
       const int64_t Addend = BC.MIB->getTargetAddend(Add);
       BC.MIB->setOperandToSymbolRef(Adrp, /*OpNum*/ 1, Symbol, Addend,
                                     BC.Ctx.get(), ELF::R_AARCH64_NONE);