Skip to content

Commit d5b170c

Browse files
[BOLT] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#139403)
1 parent 6fd3381 commit d5b170c

18 files changed

+50
-50
lines changed

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1499,7 +1499,7 @@ class BinaryContext {
14991499
MCEInstance.LocalCtx.reset(
15001500
new MCContext(*TheTriple, AsmInfo.get(), MRI.get(), STI.get()));
15011501
MCEInstance.LocalMOFI.reset(
1502-
TheTarget->createMCObjectFileInfo(*MCEInstance.LocalCtx.get(),
1502+
TheTarget->createMCObjectFileInfo(*MCEInstance.LocalCtx,
15031503
/*PIC=*/!HasFixedLoadAddress));
15041504
MCEInstance.LocalCtx->setObjectFileInfo(MCEInstance.LocalMOFI.get());
15051505
MCEInstance.MCE.reset(

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,15 +867,15 @@ class BinaryFunction {
867867
/// Returns if BinaryDominatorTree has been constructed for this function.
868868
bool hasDomTree() const { return BDT != nullptr; }
869869

870-
BinaryDominatorTree &getDomTree() { return *BDT.get(); }
870+
BinaryDominatorTree &getDomTree() { return *BDT; }
871871

872872
/// Constructs DomTree for this function.
873873
void constructDomTree();
874874

875875
/// Returns if loop detection has been run for this function.
876876
bool hasLoopInfo() const { return BLI != nullptr; }
877877

878-
const BinaryLoopInfo &getLoopInfo() { return *BLI.get(); }
878+
const BinaryLoopInfo &getLoopInfo() { return *BLI; }
879879

880880
bool isLoopFree() {
881881
if (!hasLoopInfo())

bolt/include/bolt/Core/DIEBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ class DIEBuilder {
137137
std::unordered_map<std::string, uint32_t> NameToIndexMap;
138138

139139
/// Returns current state of the DIEBuilder
140-
State &getState() { return *BuilderState.get(); }
140+
State &getState() { return *BuilderState; }
141141

142142
/// Resolve the reference in DIE, if target is not loaded into IR,
143143
/// pre-allocate it. \p RefCU will be updated to the Unit specific by \p

bolt/lib/Core/DIEBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,10 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
292292

293293
getState().Type = ProcessingType::DWARF4TUs;
294294
for (std::unique_ptr<DWARFUnit> &DU : CU4TURanges)
295-
registerUnit(*DU.get(), false);
295+
registerUnit(*DU, false);
296296

297297
for (std::unique_ptr<DWARFUnit> &DU : CU4TURanges)
298-
constructFromUnit(*DU.get());
298+
constructFromUnit(*DU);
299299

300300
DWARFContext::unit_iterator_range CURanges =
301301
isDWO() ? DwarfContext->dwo_info_section_units()
@@ -308,7 +308,7 @@ void DIEBuilder::buildTypeUnits(DebugStrOffsetsWriter *StrOffsetWriter,
308308
for (std::unique_ptr<DWARFUnit> &DU : CURanges) {
309309
if (!DU->isTypeUnit())
310310
continue;
311-
registerUnit(*DU.get(), false);
311+
registerUnit(*DU, false);
312312
}
313313

314314
for (DWARFUnit *DU : getState().DWARF5TUVector) {
@@ -335,7 +335,7 @@ void DIEBuilder::buildCompileUnits(const bool Init) {
335335
for (std::unique_ptr<DWARFUnit> &DU : CURanges) {
336336
if (DU->isTypeUnit())
337337
continue;
338-
registerUnit(*DU.get(), false);
338+
registerUnit(*DU, false);
339339
}
340340

341341
// Using DULIst since it can be modified by cross CU refrence resolution.

bolt/lib/Core/DebugData.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ DebugRangesSectionWriter::DebugRangesSectionWriter() {
142142

143143
void DebugRangesSectionWriter::initSection() {
144144
// Adds an empty range to the buffer.
145-
writeAddressRanges(*RangesStream.get(), DebugAddressRangesVector{});
145+
writeAddressRanges(*RangesStream, DebugAddressRangesVector{});
146146
}
147147

148148
uint64_t DebugRangesSectionWriter::addRanges(
@@ -169,7 +169,7 @@ uint64_t DebugRangesSectionWriter::addRanges(DebugAddressRangesVector &Ranges) {
169169
// unique and correct offsets in patches.
170170
std::lock_guard<std::mutex> Lock(WriterMutex);
171171
const uint32_t EntryOffset = RangesBuffer->size();
172-
writeAddressRanges(*RangesStream.get(), Ranges);
172+
writeAddressRanges(*RangesStream, Ranges);
173173

174174
return EntryOffset;
175175
}
@@ -321,8 +321,8 @@ void DebugRangeListsSectionWriter::finalizeSection() {
321321
llvm::endianness::little);
322322

323323
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
324-
{static_cast<uint32_t>(SizeOfArraySection + CUBodyBuffer.get()->size()),
325-
5, 8, 0, static_cast<uint32_t>(RangeEntries.size())});
324+
{static_cast<uint32_t>(SizeOfArraySection + CUBodyBuffer->size()), 5, 8,
325+
0, static_cast<uint32_t>(RangeEntries.size())});
326326
*RangesStream << *Header;
327327
*RangesStream << *CUArrayBuffer;
328328
*RangesStream << *CUBodyBuffer;
@@ -747,8 +747,8 @@ void DebugLoclistWriter::finalizeDWARF5(DIEBuilder &DIEBldr, DIE &Die) {
747747
llvm::endianness::little);
748748

749749
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
750-
{static_cast<uint32_t>(SizeOfArraySection + LocBodyBuffer.get()->size()),
751-
5, 8, 0, NumberOfEntries});
750+
{static_cast<uint32_t>(SizeOfArraySection + LocBodyBuffer->size()), 5, 8,
751+
0, NumberOfEntries});
752752
*LocStream << *Header;
753753
*LocStream << *LocArrayBuffer;
754754
*LocStream << *LocBodyBuffer;

bolt/lib/Core/DebugNames.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -648,8 +648,8 @@ void DWARF5AcceleratorTable::writeEntries() {
648648
if (const auto Iter = EntryRelativeOffsets.find(*ParentOffset);
649649
Iter != EntryRelativeOffsets.end()) {
650650
const uint64_t PatchOffset = Entry->getPatchOffset();
651-
uint32_t *Ptr = reinterpret_cast<uint32_t *>(
652-
&EntriesBuffer.get()->data()[PatchOffset]);
651+
uint32_t *Ptr =
652+
reinterpret_cast<uint32_t *>(&EntriesBuffer->data()[PatchOffset]);
653653
*Ptr = Iter->second;
654654
} else {
655655
BC.errs() << "BOLT-WARNING: [internal-dwarf-warning]: Could not find "

bolt/lib/Core/ParallelUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ inline unsigned estimateTotalCost(const BinaryContext &BC,
103103
} // namespace
104104

105105
ThreadPoolInterface &getThreadPool(const unsigned ThreadsCount) {
106-
if (ThreadPoolPtr.get())
106+
if (ThreadPoolPtr)
107107
return *ThreadPoolPtr;
108108

109109
if (ThreadsCount > 1)

bolt/lib/Passes/AsmDump.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void dumpFunction(const BinaryFunction &BF) {
175175
// Dump pseudo instructions (CFI)
176176
if (BC.MIB->isPseudo(Instr)) {
177177
if (BC.MIB->isCFI(Instr))
178-
dumpCFI(BF, Instr, *MAP.get());
178+
dumpCFI(BF, Instr, *MAP);
179179
continue;
180180
}
181181

@@ -227,7 +227,7 @@ void dumpFunction(const BinaryFunction &BF) {
227227
OS << "# Jump tables\n";
228228
// Print all jump tables.
229229
for (auto &JTI : BF.jumpTables())
230-
dumpJumpTableSymbols(OS, JTI.second, *MAP.get(), LastSection);
230+
dumpJumpTableSymbols(OS, JTI.second, *MAP, LastSection);
231231

232232
OS << "# BinaryData\n";
233233
// Print data references.

bolt/lib/Passes/RetpolineInsertion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ BinaryFunction *createNewRetpoline(BinaryContext &BC,
7878
const IndirectBranchInfo &BrInfo,
7979
bool R11Available) {
8080
auto &MIB = *BC.MIB;
81-
MCContext &Ctx = *BC.Ctx.get();
81+
MCContext &Ctx = *BC.Ctx;
8282
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Creating a new retpoline function["
8383
<< RetpolineTag << "]\n");
8484

bolt/lib/Rewrite/DWARFRewriter.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -500,13 +500,13 @@ static void emitDWOBuilder(const std::string &DWOName,
500500
SplitCU.getContext().dwo_info_section_units()) {
501501
if (!CU->isTypeUnit())
502502
continue;
503-
emitUnit(DWODIEBuilder, *Streamer, *CU.get());
503+
emitUnit(DWODIEBuilder, *Streamer, *CU);
504504
}
505505
emitUnit(DWODIEBuilder, *Streamer, SplitCU);
506506
} else {
507507
for (std::unique_ptr<llvm::DWARFUnit> &CU :
508508
SplitCU.getContext().dwo_compile_units())
509-
emitUnit(DWODIEBuilder, *Streamer, *CU.get());
509+
emitUnit(DWODIEBuilder, *Streamer, *CU);
510510

511511
// emit debug_types sections for dwarf4
512512
for (DWARFUnit *CU : DWODIEBuilder.getDWARF4TUVector())
@@ -685,8 +685,8 @@ void DWARFRewriter::updateDebugInfo() {
685685
DebugLocWriter &DebugLocWriter =
686686
*LocListWritersByCU[LocListWritersIndexByCU[Unit.getOffset()]].get();
687687
DebugRangesSectionWriter &RangesSectionWriter =
688-
Unit.getVersion() >= 5 ? *RangeListsSectionWriter.get()
689-
: *LegacyRangesSectionWriter.get();
688+
Unit.getVersion() >= 5 ? *RangeListsSectionWriter
689+
: *LegacyRangesSectionWriter;
690690
DebugAddrWriter &AddressWriter =
691691
*AddressWritersByCU[Unit.getOffset()].get();
692692
if (Unit.getVersion() >= 5)
@@ -698,7 +698,7 @@ void DWARFRewriter::updateDebugInfo() {
698698
if (!SplitCU)
699699
StrOffstsWriter->finalizeSection(Unit, DIEBlder);
700700
} else if (SplitCU) {
701-
RangesBase = LegacyRangesSectionWriter.get()->getSectionOffset();
701+
RangesBase = LegacyRangesSectionWriter->getSectionOffset();
702702
}
703703

704704
updateUnitDebugInfo(Unit, DIEBlder, DebugLocWriter, RangesSectionWriter,
@@ -750,7 +750,7 @@ void DWARFRewriter::updateDebugInfo() {
750750
auto DWODIEBuilderPtr = std::make_unique<DIEBuilder>(
751751
BC, &(**SplitCU).getContext(), DebugNamesTable, CU);
752752
DIEBuilder &DWODIEBuilder =
753-
*DWODIEBuildersByCU.emplace_back(std::move(DWODIEBuilderPtr)).get();
753+
*DWODIEBuildersByCU.emplace_back(std::move(DWODIEBuilderPtr));
754754
if (CU->getVersion() >= 5)
755755
StrOffstsWriter->finalizeSection(*CU, DIEBlder);
756756
// Important to capture CU and SplitCU by value here, otherwise when the
@@ -1403,7 +1403,7 @@ void DWARFRewriter::updateLineTableOffsets(const MCAssembler &Asm) {
14031403
continue;
14041404

14051405
std::optional<uint64_t> StmtOffset =
1406-
GetStatementListValue(CU.get()->getUnitDIE());
1406+
GetStatementListValue(CU->getUnitDIE());
14071407
if (!StmtOffset)
14081408
continue;
14091409

@@ -1479,13 +1479,13 @@ CUOffsetMap DWARFRewriter::finalizeTypeSections(DIEBuilder &DIEBlder,
14791479
for (std::unique_ptr<llvm::DWARFUnit> &CU : BC.DwCtx->info_section_units()) {
14801480
if (!CU->isTypeUnit())
14811481
continue;
1482-
updateLineTable(*CU.get());
1483-
emitUnit(DIEBlder, Streamer, *CU.get());
1482+
updateLineTable(*CU);
1483+
emitUnit(DIEBlder, Streamer, *CU);
14841484
uint32_t StartOffset = CUOffset;
1485-
DIE *UnitDIE = DIEBlder.getUnitDIEbyUnit(*CU.get());
1486-
CUOffset += CU.get()->getHeaderSize();
1485+
DIE *UnitDIE = DIEBlder.getUnitDIEbyUnit(*CU);
1486+
CUOffset += CU->getHeaderSize();
14871487
CUOffset += UnitDIE->getSize();
1488-
CUMap[CU.get()->getOffset()] = {StartOffset, CUOffset - StartOffset - 4};
1488+
CUMap[CU->getOffset()] = {StartOffset, CUOffset - StartOffset - 4};
14891489
}
14901490

14911491
// Emit Type Unit of DWARF 4 to .debug_type section

bolt/lib/Rewrite/MachORewriteInstance.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,21 +108,21 @@ Error MachORewriteInstance::setProfile(StringRef Filename) {
108108
void MachORewriteInstance::preprocessProfileData() {
109109
if (!ProfileReader)
110110
return;
111-
if (Error E = ProfileReader->preprocessProfile(*BC.get()))
111+
if (Error E = ProfileReader->preprocessProfile(*BC))
112112
report_error("cannot pre-process profile", std::move(E));
113113
}
114114

115115
void MachORewriteInstance::processProfileDataPreCFG() {
116116
if (!ProfileReader)
117117
return;
118-
if (Error E = ProfileReader->readProfilePreCFG(*BC.get()))
118+
if (Error E = ProfileReader->readProfilePreCFG(*BC))
119119
report_error("cannot read profile pre-CFG", std::move(E));
120120
}
121121

122122
void MachORewriteInstance::processProfileData() {
123123
if (!ProfileReader)
124124
return;
125-
if (Error E = ProfileReader->readProfile(*BC.get()))
125+
if (Error E = ProfileReader->readProfile(*BC))
126126
report_error("cannot read profile", std::move(E));
127127
}
128128

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3280,7 +3280,7 @@ void RewriteInstance::preprocessProfileData() {
32803280
ProfileReader->setBAT(&*BAT);
32813281
}
32823282

3283-
if (Error E = ProfileReader->preprocessProfile(*BC.get()))
3283+
if (Error E = ProfileReader->preprocessProfile(*BC))
32843284
report_error("cannot pre-process profile", std::move(E));
32853285

32863286
if (!BC->hasSymbolsWithFileName() && ProfileReader->hasLocalsWithFileName() &&
@@ -3335,7 +3335,7 @@ void RewriteInstance::processProfileDataPreCFG() {
33353335
NamedRegionTimer T("processprofile-precfg", "process profile data pre-CFG",
33363336
TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
33373337

3338-
if (Error E = ProfileReader->readProfilePreCFG(*BC.get()))
3338+
if (Error E = ProfileReader->readProfilePreCFG(*BC))
33393339
report_error("cannot read profile pre-CFG", std::move(E));
33403340
}
33413341

@@ -3346,7 +3346,7 @@ void RewriteInstance::processProfileData() {
33463346
NamedRegionTimer T("processprofile", "process profile data", TimerGroupName,
33473347
TimerGroupDesc, opts::TimeRewrite);
33483348

3349-
if (Error E = ProfileReader->readProfile(*BC.get()))
3349+
if (Error E = ProfileReader->readProfile(*BC))
33503350
report_error("cannot read profile", std::move(E));
33513351

33523352
if (opts::PrintProfile || opts::PrintAll) {

bolt/lib/RuntimeLibs/RuntimeLibrary.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void RuntimeLibrary::loadLibrary(StringRef LibPath, BOLTLinker &Linker,
9696

9797
if (Magic == file_magic::archive) {
9898
Error Err = Error::success();
99-
object::Archive Archive(B.get()->getMemBufferRef(), Err);
99+
object::Archive Archive(B->getMemBufferRef(), Err);
100100
for (const object::Archive::Child &C : Archive.children(Err)) {
101101
std::unique_ptr<object::Binary> Bin = cantFail(C.getAsBinary());
102102
if (object::ObjectFile *Obj = dyn_cast<object::ObjectFile>(&*Bin))
@@ -105,9 +105,9 @@ void RuntimeLibrary::loadLibrary(StringRef LibPath, BOLTLinker &Linker,
105105
check_error(std::move(Err), B->getBufferIdentifier());
106106
} else if (Magic == file_magic::elf_relocatable ||
107107
Magic == file_magic::elf_shared_object) {
108-
std::unique_ptr<object::ObjectFile> Obj = cantFail(
109-
object::ObjectFile::createObjectFile(B.get()->getMemBufferRef()),
110-
"error creating in-memory object");
108+
std::unique_ptr<object::ObjectFile> Obj =
109+
cantFail(object::ObjectFile::createObjectFile(B->getMemBufferRef()),
110+
"error creating in-memory object");
111111
Linker.loadObject(Obj->getMemoryBufferRef(), MapSections);
112112
} else {
113113
errs() << "BOLT-ERROR: unrecognized library format: " << LibPath << "\n";

bolt/lib/Target/AArch64/AArch64MCSymbolizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class AArch64MCSymbolizer : public MCSymbolizer {
3333

3434
public:
3535
AArch64MCSymbolizer(BinaryFunction &Function, bool CreateNewSymbols = true)
36-
: MCSymbolizer(*Function.getBinaryContext().Ctx.get(), nullptr),
36+
: MCSymbolizer(*Function.getBinaryContext().Ctx, nullptr),
3737
Function(Function), CreateNewSymbols(CreateNewSymbols) {}
3838

3939
AArch64MCSymbolizer(const AArch64MCSymbolizer &) = delete;

bolt/lib/Target/X86/X86MCSymbolizer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class X86MCSymbolizer : public MCSymbolizer {
2525

2626
public:
2727
X86MCSymbolizer(BinaryFunction &Function, bool CreateNewSymbols = true)
28-
: MCSymbolizer(*Function.getBinaryContext().Ctx.get(), nullptr),
28+
: MCSymbolizer(*Function.getBinaryContext().Ctx, nullptr),
2929
Function(Function), CreateNewSymbols(CreateNewSymbols) {}
3030

3131
X86MCSymbolizer(const X86MCSymbolizer &) = delete;

bolt/unittests/Core/BinaryContext.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ struct BinaryContextTester : public testing::TestWithParam<Triple::ArchType> {
5353
Relocation::Arch = ObjFile->makeTriple().getArch();
5454
BC = cantFail(BinaryContext::createBinaryContext(
5555
ObjFile->makeTriple(), std::make_shared<orc::SymbolStringPool>(),
56-
ObjFile->getFileName(), nullptr, true,
57-
DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));
56+
ObjFile->getFileName(), nullptr, true, DWARFContext::create(*ObjFile),
57+
{llvm::outs(), llvm::errs()}));
5858
ASSERT_FALSE(!BC);
5959
}
6060

bolt/unittests/Core/MCPlusBuilder.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ struct MCPlusBuilderTester : public testing::TestWithParam<Triple::ArchType> {
6464
Relocation::Arch = ObjFile->makeTriple().getArch();
6565
BC = cantFail(BinaryContext::createBinaryContext(
6666
ObjFile->makeTriple(), std::make_shared<orc::SymbolStringPool>(),
67-
ObjFile->getFileName(), nullptr, true,
68-
DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));
67+
ObjFile->getFileName(), nullptr, true, DWARFContext::create(*ObjFile),
68+
{llvm::outs(), llvm::errs()}));
6969
ASSERT_FALSE(!BC);
7070
BC->initializeTarget(std::unique_ptr<MCPlusBuilder>(
7171
createMCPlusBuilder(GetParam(), BC->MIA.get(), BC->MII.get(),

bolt/unittests/Core/MemoryMaps.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ struct MemoryMapsTester : public testing::TestWithParam<Triple::ArchType> {
6363
Relocation::Arch = ObjFile->makeTriple().getArch();
6464
BC = cantFail(BinaryContext::createBinaryContext(
6565
ObjFile->makeTriple(), std::make_shared<orc::SymbolStringPool>(),
66-
ObjFile->getFileName(), nullptr, true,
67-
DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));
66+
ObjFile->getFileName(), nullptr, true, DWARFContext::create(*ObjFile),
67+
{llvm::outs(), llvm::errs()}));
6868
ASSERT_FALSE(!BC);
6969
}
7070

0 commit comments

Comments
 (0)