Skip to content

Commit 62e894e

Browse files
authored
[BOLT][DWARF][NFC] Move Arch assignment out of createBinaryContext (llvm#102054)
Moves the assignment of Arch out of createBinaryContext to prevent data races when parallelized.
1 parent a0ed7d6 commit 62e894e

File tree

5 files changed

+4
-1
lines changed

5 files changed

+4
-1
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ BinaryContext::BinaryContext(std::unique_ptr<MCContext> Ctx,
142142
InstPrinter(std::move(InstPrinter)), MIA(std::move(MIA)),
143143
MIB(std::move(MIB)), MRI(std::move(MRI)), DisAsm(std::move(DisAsm)),
144144
Logger(Logger), InitialDynoStats(isAArch64()) {
145-
Relocation::Arch = this->TheTriple->getArch();
146145
RegularPageSize = isAArch64() ? RegularPageSizeAArch64 : RegularPageSizeX86;
147146
PageAlign = opts::NoHugePages ? RegularPageSize : HugePageSize;
148147
}

bolt/lib/Rewrite/MachORewriteInstance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ MachORewriteInstance::MachORewriteInstance(object::MachOObjectFile *InputFile,
7272
StringRef ToolPath, Error &Err)
7373
: InputFile(InputFile), ToolPath(ToolPath) {
7474
ErrorAsOutParameter EAO(&Err);
75+
Relocation::Arch = InputFile->makeTriple().getArch();
7576
auto BCOrErr = BinaryContext::createBinaryContext(
7677
InputFile->makeTriple(), InputFile->getFileName(), nullptr,
7778
/* IsPIC */ true, DWARFContext::create(*InputFile),

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,7 @@ RewriteInstance::RewriteInstance(ELFObjectFileBase *File, const int Argc,
354354
}
355355
}
356356

357+
Relocation::Arch = TheTriple.getArch();
357358
auto BCOrErr = BinaryContext::createBinaryContext(
358359
TheTriple, File->getFileName(), Features.get(), IsPIC,
359360
DWARFContext::create(*File, DWARFContext::ProcessDebugRelocations::Ignore,

bolt/unittests/Core/BinaryContext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ struct BinaryContextTester : public testing::TestWithParam<Triple::ArchType> {
4646
}
4747

4848
void initializeBOLT() {
49+
Relocation::Arch = ObjFile->makeTriple().getArch();
4950
BC = cantFail(BinaryContext::createBinaryContext(
5051
ObjFile->makeTriple(), ObjFile->getFileName(), nullptr, true,
5152
DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));

bolt/unittests/Core/MCPlusBuilder.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct MCPlusBuilderTester : public testing::TestWithParam<Triple::ArchType> {
5656
}
5757

5858
void initializeBolt() {
59+
Relocation::Arch = ObjFile->makeTriple().getArch();
5960
BC = cantFail(BinaryContext::createBinaryContext(
6061
ObjFile->makeTriple(), ObjFile->getFileName(), nullptr, true,
6162
DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));

0 commit comments

Comments
 (0)