[BOLT] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#139403)
diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h
index 88313a6..64e524e 100644
--- a/bolt/include/bolt/Core/BinaryContext.h
+++ b/bolt/include/bolt/Core/BinaryContext.h
@@ -1499,7 +1499,7 @@
MCEInstance.LocalCtx.reset(
new MCContext(*TheTriple, AsmInfo.get(), MRI.get(), STI.get()));
MCEInstance.LocalMOFI.reset(
- TheTarget->createMCObjectFileInfo(*MCEInstance.LocalCtx.get(),
+ TheTarget->createMCObjectFileInfo(*MCEInstance.LocalCtx,
/*PIC=*/!HasFixedLoadAddress));
MCEInstance.LocalCtx->setObjectFileInfo(MCEInstance.LocalMOFI.get());
MCEInstance.MCE.reset(
diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index d140202..c237f4a 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -867,7 +867,7 @@
/// Returns if BinaryDominatorTree has been constructed for this function.
bool hasDomTree() const { return BDT != nullptr; }
- BinaryDominatorTree &getDomTree() { return *BDT.get(); }
+ BinaryDominatorTree &getDomTree() { return *BDT; }
/// Constructs DomTree for this function.
void constructDomTree();
@@ -875,7 +875,7 @@
/// Returns if loop detection has been run for this function.
bool hasLoopInfo() const { return BLI != nullptr; }
- const BinaryLoopInfo &getLoopInfo() { return *BLI.get(); }
+ const BinaryLoopInfo &getLoopInfo() { return *BLI; }
bool isLoopFree() {
if (!hasLoopInfo())
diff --git a/bolt/include/bolt/Core/DIEBuilder.h b/bolt/include/bolt/Core/DIEBuilder.h
index bd22c53..32e455a 100644
--- a/bolt/include/bolt/Core/DIEBuilder.h
+++ b/bolt/include/bolt/Core/DIEBuilder.h
@@ -137,7 +137,7 @@
std::unordered_map<std::string, uint32_t> NameToIndexMap;
/// Returns current state of the DIEBuilder
- State &getState() { return *BuilderState.get(); }
+ State &getState() { return *BuilderState; }
/// Resolve the reference in DIE, if target is not loaded into IR,
/// pre-allocate it. \p RefCU will be updated to the Unit specific by \p
diff --git a/bolt/lib/Core/DIEBuilder.cpp b/bolt/lib/Core/DIEBuilder.cpp
index 80ad583..136c23d 100644
--- a/bolt/lib/Core/DIEBuilder.cpp
+++ b/bolt/lib/Core/DIEBuilder.cpp
@@ -292,10 +292,10 @@
getState().Type = ProcessingType::DWARF4TUs;
for (std::unique_ptr<DWARFUnit> &DU : CU4TURanges)
- registerUnit(*DU.get(), false);
+ registerUnit(*DU, false);
for (std::unique_ptr<DWARFUnit> &DU : CU4TURanges)
- constructFromUnit(*DU.get());
+ constructFromUnit(*DU);
DWARFContext::unit_iterator_range CURanges =
isDWO() ? DwarfContext->dwo_info_section_units()
@@ -308,7 +308,7 @@
for (std::unique_ptr<DWARFUnit> &DU : CURanges) {
if (!DU->isTypeUnit())
continue;
- registerUnit(*DU.get(), false);
+ registerUnit(*DU, false);
}
for (DWARFUnit *DU : getState().DWARF5TUVector) {
@@ -335,7 +335,7 @@
for (std::unique_ptr<DWARFUnit> &DU : CURanges) {
if (DU->isTypeUnit())
continue;
- registerUnit(*DU.get(), false);
+ registerUnit(*DU, false);
}
// Using DULIst since it can be modified by cross CU refrence resolution.
diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index bd8aa80..e11be49 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -142,7 +142,7 @@
void DebugRangesSectionWriter::initSection() {
// Adds an empty range to the buffer.
- writeAddressRanges(*RangesStream.get(), DebugAddressRangesVector{});
+ writeAddressRanges(*RangesStream, DebugAddressRangesVector{});
}
uint64_t DebugRangesSectionWriter::addRanges(
@@ -169,7 +169,7 @@
// unique and correct offsets in patches.
std::lock_guard<std::mutex> Lock(WriterMutex);
const uint32_t EntryOffset = RangesBuffer->size();
- writeAddressRanges(*RangesStream.get(), Ranges);
+ writeAddressRanges(*RangesStream, Ranges);
return EntryOffset;
}
@@ -321,8 +321,8 @@
llvm::endianness::little);
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
- {static_cast<uint32_t>(SizeOfArraySection + CUBodyBuffer.get()->size()),
- 5, 8, 0, static_cast<uint32_t>(RangeEntries.size())});
+ {static_cast<uint32_t>(SizeOfArraySection + CUBodyBuffer->size()), 5, 8,
+ 0, static_cast<uint32_t>(RangeEntries.size())});
*RangesStream << *Header;
*RangesStream << *CUArrayBuffer;
*RangesStream << *CUBodyBuffer;
@@ -747,8 +747,8 @@
llvm::endianness::little);
std::unique_ptr<DebugBufferVector> Header = getDWARF5Header(
- {static_cast<uint32_t>(SizeOfArraySection + LocBodyBuffer.get()->size()),
- 5, 8, 0, NumberOfEntries});
+ {static_cast<uint32_t>(SizeOfArraySection + LocBodyBuffer->size()), 5, 8,
+ 0, NumberOfEntries});
*LocStream << *Header;
*LocStream << *LocArrayBuffer;
*LocStream << *LocBodyBuffer;
diff --git a/bolt/lib/Core/DebugNames.cpp b/bolt/lib/Core/DebugNames.cpp
index 82cabe6..aa1c8f3 100644
--- a/bolt/lib/Core/DebugNames.cpp
+++ b/bolt/lib/Core/DebugNames.cpp
@@ -648,8 +648,8 @@
if (const auto Iter = EntryRelativeOffsets.find(*ParentOffset);
Iter != EntryRelativeOffsets.end()) {
const uint64_t PatchOffset = Entry->getPatchOffset();
- uint32_t *Ptr = reinterpret_cast<uint32_t *>(
- &EntriesBuffer.get()->data()[PatchOffset]);
+ uint32_t *Ptr =
+ reinterpret_cast<uint32_t *>(&EntriesBuffer->data()[PatchOffset]);
*Ptr = Iter->second;
} else {
BC.errs() << "BOLT-WARNING: [internal-dwarf-warning]: Could not find "
diff --git a/bolt/lib/Core/ParallelUtilities.cpp b/bolt/lib/Core/ParallelUtilities.cpp
index 3a8a7dc..0f13aa1 100644
--- a/bolt/lib/Core/ParallelUtilities.cpp
+++ b/bolt/lib/Core/ParallelUtilities.cpp
@@ -103,7 +103,7 @@
} // namespace
ThreadPoolInterface &getThreadPool(const unsigned ThreadsCount) {
- if (ThreadPoolPtr.get())
+ if (ThreadPoolPtr)
return *ThreadPoolPtr;
if (ThreadsCount > 1)
diff --git a/bolt/lib/Passes/AsmDump.cpp b/bolt/lib/Passes/AsmDump.cpp
index ffc920a..c0be011 100644
--- a/bolt/lib/Passes/AsmDump.cpp
+++ b/bolt/lib/Passes/AsmDump.cpp
@@ -175,7 +175,7 @@
// Dump pseudo instructions (CFI)
if (BC.MIB->isPseudo(Instr)) {
if (BC.MIB->isCFI(Instr))
- dumpCFI(BF, Instr, *MAP.get());
+ dumpCFI(BF, Instr, *MAP);
continue;
}
@@ -227,7 +227,7 @@
OS << "# Jump tables\n";
// Print all jump tables.
for (auto &JTI : BF.jumpTables())
- dumpJumpTableSymbols(OS, JTI.second, *MAP.get(), LastSection);
+ dumpJumpTableSymbols(OS, JTI.second, *MAP, LastSection);
OS << "# BinaryData\n";
// Print data references.
diff --git a/bolt/lib/Passes/RetpolineInsertion.cpp b/bolt/lib/Passes/RetpolineInsertion.cpp
index f870289..98e5a8f 100644
--- a/bolt/lib/Passes/RetpolineInsertion.cpp
+++ b/bolt/lib/Passes/RetpolineInsertion.cpp
@@ -78,7 +78,7 @@
const IndirectBranchInfo &BrInfo,
bool R11Available) {
auto &MIB = *BC.MIB;
- MCContext &Ctx = *BC.Ctx.get();
+ MCContext &Ctx = *BC.Ctx;
LLVM_DEBUG(dbgs() << "BOLT-DEBUG: Creating a new retpoline function["
<< RetpolineTag << "]\n");
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 3088810..9c9bdef 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -500,13 +500,13 @@
SplitCU.getContext().dwo_info_section_units()) {
if (!CU->isTypeUnit())
continue;
- emitUnit(DWODIEBuilder, *Streamer, *CU.get());
+ emitUnit(DWODIEBuilder, *Streamer, *CU);
}
emitUnit(DWODIEBuilder, *Streamer, SplitCU);
} else {
for (std::unique_ptr<llvm::DWARFUnit> &CU :
SplitCU.getContext().dwo_compile_units())
- emitUnit(DWODIEBuilder, *Streamer, *CU.get());
+ emitUnit(DWODIEBuilder, *Streamer, *CU);
// emit debug_types sections for dwarf4
for (DWARFUnit *CU : DWODIEBuilder.getDWARF4TUVector())
@@ -685,8 +685,8 @@
DebugLocWriter &DebugLocWriter =
*LocListWritersByCU[LocListWritersIndexByCU[Unit.getOffset()]].get();
DebugRangesSectionWriter &RangesSectionWriter =
- Unit.getVersion() >= 5 ? *RangeListsSectionWriter.get()
- : *LegacyRangesSectionWriter.get();
+ Unit.getVersion() >= 5 ? *RangeListsSectionWriter
+ : *LegacyRangesSectionWriter;
DebugAddrWriter &AddressWriter =
*AddressWritersByCU[Unit.getOffset()].get();
if (Unit.getVersion() >= 5)
@@ -698,7 +698,7 @@
if (!SplitCU)
StrOffstsWriter->finalizeSection(Unit, DIEBlder);
} else if (SplitCU) {
- RangesBase = LegacyRangesSectionWriter.get()->getSectionOffset();
+ RangesBase = LegacyRangesSectionWriter->getSectionOffset();
}
updateUnitDebugInfo(Unit, DIEBlder, DebugLocWriter, RangesSectionWriter,
@@ -750,7 +750,7 @@
auto DWODIEBuilderPtr = std::make_unique<DIEBuilder>(
BC, &(**SplitCU).getContext(), DebugNamesTable, CU);
DIEBuilder &DWODIEBuilder =
- *DWODIEBuildersByCU.emplace_back(std::move(DWODIEBuilderPtr)).get();
+ *DWODIEBuildersByCU.emplace_back(std::move(DWODIEBuilderPtr));
if (CU->getVersion() >= 5)
StrOffstsWriter->finalizeSection(*CU, DIEBlder);
// Important to capture CU and SplitCU by value here, otherwise when the
@@ -1403,7 +1403,7 @@
continue;
std::optional<uint64_t> StmtOffset =
- GetStatementListValue(CU.get()->getUnitDIE());
+ GetStatementListValue(CU->getUnitDIE());
if (!StmtOffset)
continue;
@@ -1479,13 +1479,13 @@
for (std::unique_ptr<llvm::DWARFUnit> &CU : BC.DwCtx->info_section_units()) {
if (!CU->isTypeUnit())
continue;
- updateLineTable(*CU.get());
- emitUnit(DIEBlder, Streamer, *CU.get());
+ updateLineTable(*CU);
+ emitUnit(DIEBlder, Streamer, *CU);
uint32_t StartOffset = CUOffset;
- DIE *UnitDIE = DIEBlder.getUnitDIEbyUnit(*CU.get());
- CUOffset += CU.get()->getHeaderSize();
+ DIE *UnitDIE = DIEBlder.getUnitDIEbyUnit(*CU);
+ CUOffset += CU->getHeaderSize();
CUOffset += UnitDIE->getSize();
- CUMap[CU.get()->getOffset()] = {StartOffset, CUOffset - StartOffset - 4};
+ CUMap[CU->getOffset()] = {StartOffset, CUOffset - StartOffset - 4};
}
// Emit Type Unit of DWARF 4 to .debug_type section
diff --git a/bolt/lib/Rewrite/MachORewriteInstance.cpp b/bolt/lib/Rewrite/MachORewriteInstance.cpp
index 335b7b4..a1c2cef 100644
--- a/bolt/lib/Rewrite/MachORewriteInstance.cpp
+++ b/bolt/lib/Rewrite/MachORewriteInstance.cpp
@@ -108,21 +108,21 @@
void MachORewriteInstance::preprocessProfileData() {
if (!ProfileReader)
return;
- if (Error E = ProfileReader->preprocessProfile(*BC.get()))
+ if (Error E = ProfileReader->preprocessProfile(*BC))
report_error("cannot pre-process profile", std::move(E));
}
void MachORewriteInstance::processProfileDataPreCFG() {
if (!ProfileReader)
return;
- if (Error E = ProfileReader->readProfilePreCFG(*BC.get()))
+ if (Error E = ProfileReader->readProfilePreCFG(*BC))
report_error("cannot read profile pre-CFG", std::move(E));
}
void MachORewriteInstance::processProfileData() {
if (!ProfileReader)
return;
- if (Error E = ProfileReader->readProfile(*BC.get()))
+ if (Error E = ProfileReader->readProfile(*BC))
report_error("cannot read profile", std::move(E));
}
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 1c24200..520bd67 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -3280,7 +3280,7 @@
ProfileReader->setBAT(&*BAT);
}
- if (Error E = ProfileReader->preprocessProfile(*BC.get()))
+ if (Error E = ProfileReader->preprocessProfile(*BC))
report_error("cannot pre-process profile", std::move(E));
if (!BC->hasSymbolsWithFileName() && ProfileReader->hasLocalsWithFileName() &&
@@ -3335,7 +3335,7 @@
NamedRegionTimer T("processprofile-precfg", "process profile data pre-CFG",
TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
- if (Error E = ProfileReader->readProfilePreCFG(*BC.get()))
+ if (Error E = ProfileReader->readProfilePreCFG(*BC))
report_error("cannot read profile pre-CFG", std::move(E));
}
@@ -3346,7 +3346,7 @@
NamedRegionTimer T("processprofile", "process profile data", TimerGroupName,
TimerGroupDesc, opts::TimeRewrite);
- if (Error E = ProfileReader->readProfile(*BC.get()))
+ if (Error E = ProfileReader->readProfile(*BC))
report_error("cannot read profile", std::move(E));
if (opts::PrintProfile || opts::PrintAll) {
diff --git a/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp b/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
index 8f5719e..98852ee 100644
--- a/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
+++ b/bolt/lib/RuntimeLibs/RuntimeLibrary.cpp
@@ -96,7 +96,7 @@
if (Magic == file_magic::archive) {
Error Err = Error::success();
- object::Archive Archive(B.get()->getMemBufferRef(), Err);
+ object::Archive Archive(B->getMemBufferRef(), Err);
for (const object::Archive::Child &C : Archive.children(Err)) {
std::unique_ptr<object::Binary> Bin = cantFail(C.getAsBinary());
if (object::ObjectFile *Obj = dyn_cast<object::ObjectFile>(&*Bin))
@@ -105,9 +105,9 @@
check_error(std::move(Err), B->getBufferIdentifier());
} else if (Magic == file_magic::elf_relocatable ||
Magic == file_magic::elf_shared_object) {
- std::unique_ptr<object::ObjectFile> Obj = cantFail(
- object::ObjectFile::createObjectFile(B.get()->getMemBufferRef()),
- "error creating in-memory object");
+ std::unique_ptr<object::ObjectFile> Obj =
+ cantFail(object::ObjectFile::createObjectFile(B->getMemBufferRef()),
+ "error creating in-memory object");
Linker.loadObject(Obj->getMemoryBufferRef(), MapSections);
} else {
errs() << "BOLT-ERROR: unrecognized library format: " << LibPath << "\n";
diff --git a/bolt/lib/Target/AArch64/AArch64MCSymbolizer.h b/bolt/lib/Target/AArch64/AArch64MCSymbolizer.h
index 859c57c..153806a 100644
--- a/bolt/lib/Target/AArch64/AArch64MCSymbolizer.h
+++ b/bolt/lib/Target/AArch64/AArch64MCSymbolizer.h
@@ -33,7 +33,7 @@
public:
AArch64MCSymbolizer(BinaryFunction &Function, bool CreateNewSymbols = true)
- : MCSymbolizer(*Function.getBinaryContext().Ctx.get(), nullptr),
+ : MCSymbolizer(*Function.getBinaryContext().Ctx, nullptr),
Function(Function), CreateNewSymbols(CreateNewSymbols) {}
AArch64MCSymbolizer(const AArch64MCSymbolizer &) = delete;
diff --git a/bolt/lib/Target/X86/X86MCSymbolizer.h b/bolt/lib/Target/X86/X86MCSymbolizer.h
index 189941e..c9c475b 100644
--- a/bolt/lib/Target/X86/X86MCSymbolizer.h
+++ b/bolt/lib/Target/X86/X86MCSymbolizer.h
@@ -25,7 +25,7 @@
public:
X86MCSymbolizer(BinaryFunction &Function, bool CreateNewSymbols = true)
- : MCSymbolizer(*Function.getBinaryContext().Ctx.get(), nullptr),
+ : MCSymbolizer(*Function.getBinaryContext().Ctx, nullptr),
Function(Function), CreateNewSymbols(CreateNewSymbols) {}
X86MCSymbolizer(const X86MCSymbolizer &) = delete;
diff --git a/bolt/unittests/Core/BinaryContext.cpp b/bolt/unittests/Core/BinaryContext.cpp
index ba3e4ce..3fa0851 100644
--- a/bolt/unittests/Core/BinaryContext.cpp
+++ b/bolt/unittests/Core/BinaryContext.cpp
@@ -53,8 +53,8 @@
Relocation::Arch = ObjFile->makeTriple().getArch();
BC = cantFail(BinaryContext::createBinaryContext(
ObjFile->makeTriple(), std::make_shared<orc::SymbolStringPool>(),
- ObjFile->getFileName(), nullptr, true,
- DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));
+ ObjFile->getFileName(), nullptr, true, DWARFContext::create(*ObjFile),
+ {llvm::outs(), llvm::errs()}));
ASSERT_FALSE(!BC);
}
diff --git a/bolt/unittests/Core/MCPlusBuilder.cpp b/bolt/unittests/Core/MCPlusBuilder.cpp
index 7016dec..af4cc9d 100644
--- a/bolt/unittests/Core/MCPlusBuilder.cpp
+++ b/bolt/unittests/Core/MCPlusBuilder.cpp
@@ -64,8 +64,8 @@
Relocation::Arch = ObjFile->makeTriple().getArch();
BC = cantFail(BinaryContext::createBinaryContext(
ObjFile->makeTriple(), std::make_shared<orc::SymbolStringPool>(),
- ObjFile->getFileName(), nullptr, true,
- DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));
+ ObjFile->getFileName(), nullptr, true, DWARFContext::create(*ObjFile),
+ {llvm::outs(), llvm::errs()}));
ASSERT_FALSE(!BC);
BC->initializeTarget(std::unique_ptr<MCPlusBuilder>(
createMCPlusBuilder(GetParam(), BC->MIA.get(), BC->MII.get(),
diff --git a/bolt/unittests/Core/MemoryMaps.cpp b/bolt/unittests/Core/MemoryMaps.cpp
index 2e1bc4d..b0cab54 100644
--- a/bolt/unittests/Core/MemoryMaps.cpp
+++ b/bolt/unittests/Core/MemoryMaps.cpp
@@ -63,8 +63,8 @@
Relocation::Arch = ObjFile->makeTriple().getArch();
BC = cantFail(BinaryContext::createBinaryContext(
ObjFile->makeTriple(), std::make_shared<orc::SymbolStringPool>(),
- ObjFile->getFileName(), nullptr, true,
- DWARFContext::create(*ObjFile.get()), {llvm::outs(), llvm::errs()}));
+ ObjFile->getFileName(), nullptr, true, DWARFContext::create(*ObjFile),
+ {llvm::outs(), llvm::errs()}));
ASSERT_FALSE(!BC);
}