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

0 commit comments

Comments
 (0)