Skip to content

Commit 75bc20f

Browse files
[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) (#97914)
1 parent f767295 commit 75bc20f

File tree

27 files changed

+43
-45
lines changed

27 files changed

+43
-45
lines changed

llvm/include/llvm/Analysis/BranchProbabilityInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ class BranchProbabilityInfo {
345345

346346
/// Helper to construct LoopBlock for \p BB.
347347
LoopBlock getLoopBlock(const BasicBlock *BB) const {
348-
return LoopBlock(BB, *LI, *SccI.get());
348+
return LoopBlock(BB, *LI, *SccI);
349349
}
350350

351351
/// Returns true if destination block belongs to some loop and source block is

llvm/include/llvm/Analysis/MLInlineAdvisor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ class MLInlineAdvisor : public InlineAdvisor {
4545

4646
bool isForcedToStop() const { return ForceStop; }
4747
int64_t getLocalCalls(Function &F);
48-
const MLModelRunner &getModelRunner() const { return *ModelRunner.get(); }
48+
const MLModelRunner &getModelRunner() const { return *ModelRunner; }
4949
FunctionPropertiesInfo &getCachedFPI(Function &) const;
5050

5151
protected:

llvm/include/llvm/Analysis/MemorySSA.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ class MemorySSAAnalysis : public AnalysisInfoMixin<MemorySSAAnalysis> {
937937
struct Result {
938938
Result(std::unique_ptr<MemorySSA> &&MSSA) : MSSA(std::move(MSSA)) {}
939939

940-
MemorySSA &getMSSA() { return *MSSA.get(); }
940+
MemorySSA &getMSSA() { return *MSSA; }
941941

942942
std::unique_ptr<MemorySSA> MSSA;
943943

llvm/include/llvm/ProfileData/SampleProfReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ class SampleProfileReader {
449449
StringRef RemapFilename = "");
450450

451451
/// Return the profile summary.
452-
ProfileSummary &getSummary() const { return *(Summary.get()); }
452+
ProfileSummary &getSummary() const { return *Summary; }
453453

454454
MemoryBuffer *getBuffer() const { return Buffer.get(); }
455455

llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,5 +859,5 @@ GISelKnownBits &GISelKnownBitsAnalysis::get(MachineFunction &MF) {
859859
MF.getTarget().getOptLevel() == CodeGenOptLevel::None ? 2 : 6;
860860
Info = std::make_unique<GISelKnownBits>(MF, MaxDepth);
861861
}
862-
return *Info.get();
862+
return *Info;
863863
}

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3968,7 +3968,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
39683968
#endif // ifndef NDEBUG
39693969

39703970
// Translate any debug-info attached to the instruction.
3971-
translateDbgInfo(Inst, *CurBuilder.get());
3971+
translateDbgInfo(Inst, *CurBuilder);
39723972

39733973
if (translate(Inst))
39743974
continue;

llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1843,13 +1843,13 @@ bool CompileUnit::resolveDependenciesAndMarkLiveness(
18431843
bool CompileUnit::updateDependenciesCompleteness() {
18441844
assert(Dependencies.get());
18451845

1846-
return Dependencies.get()->updateDependenciesCompleteness();
1846+
return Dependencies->updateDependenciesCompleteness();
18471847
}
18481848

18491849
void CompileUnit::verifyDependencies() {
18501850
assert(Dependencies.get());
18511851

1852-
Dependencies.get()->verifyKeepChain();
1852+
Dependencies->verifyKeepChain();
18531853
}
18541854

18551855
ArrayRef<dwarf::Attribute> dwarf_linker::parallel::getODRAttributes() {

llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ Error DWARFLinkerImpl::link() {
142142
// twice. And then following handling might be removed.
143143
for (const std::unique_ptr<DWARFUnit> &OrigCU :
144144
Context->InputDWARFFile.Dwarf->compile_units()) {
145-
DWARFDie UnitDie = OrigCU.get()->getUnitDIE();
145+
DWARFDie UnitDie = OrigCU->getUnitDIE();
146146

147147
if (!Language) {
148148
if (std::optional<DWARFFormValue> Val =

llvm/lib/IR/DebugProgramInstruction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,7 @@ DbgVariableIntrinsic *
399399
DbgVariableRecord::createDebugIntrinsic(Module *M,
400400
Instruction *InsertBefore) const {
401401
[[maybe_unused]] DICompileUnit *Unit =
402-
getDebugLoc().get()->getScope()->getSubprogram()->getUnit();
402+
getDebugLoc()->getScope()->getSubprogram()->getUnit();
403403
assert(M && Unit &&
404404
"Cannot clone from BasicBlock that is not part of a Module or "
405405
"DICompileUnit!");

llvm/lib/ObjectYAML/XCOFFYAML.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ void MappingTraits<std::unique_ptr<XCOFFYAML::AuxSymbolEnt>>::mapping(
327327

328328
XCOFFYAML::AuxSymbolType AuxType;
329329
if (IO.outputting())
330-
AuxType = AuxSym.get()->Type;
330+
AuxType = AuxSym->Type;
331331
IO.mapRequired("Type", AuxType);
332332
switch (AuxType) {
333333
case XCOFFYAML::AUX_EXCEPT:

llvm/lib/Support/TimeProfiler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ struct llvm::TimeTraceProfiler {
115115

116116
void end() {
117117
assert(!Stack.empty() && "Must call begin() first");
118-
end(*Stack.back().get());
118+
end(*Stack.back());
119119
}
120120

121121
void end(TimeTraceProfilerEntry &E) {

llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ static void doList(opt::InputArgList &Args) {
145145
return;
146146

147147
Error Err = Error::success();
148-
object::Archive Archive(B.get()->getMemBufferRef(), Err);
148+
object::Archive Archive(B->getMemBufferRef(), Err);
149149
fatalOpenError(std::move(Err), B->getBufferIdentifier());
150150

151151
std::vector<StringRef> Names;

llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8001,7 +8001,7 @@ getGEPCosts(const TargetTransformInfo &TTI, ArrayRef<Value *> Ptrs,
80018001
void BoUpSLP::transformNodes() {
80028002
constexpr TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
80038003
for (std::unique_ptr<TreeEntry> &TE : VectorizableTree) {
8004-
TreeEntry &E = *TE.get();
8004+
TreeEntry &E = *TE;
80058005
switch (E.getOpcode()) {
80068006
case Instruction::Load: {
80078007
// No need to reorder masked gather loads, just reorder the scalar
@@ -10462,7 +10462,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
1046210462
}
1046310463
// Add reduced value cost, if resized.
1046410464
if (!VectorizedVals.empty()) {
10465-
const TreeEntry &Root = *VectorizableTree.front().get();
10465+
const TreeEntry &Root = *VectorizableTree.front();
1046610466
auto BWIt = MinBWs.find(&Root);
1046710467
if (BWIt != MinBWs.end()) {
1046810468
Type *DstTy = Root.Scalars.front()->getType();
@@ -10570,7 +10570,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
1057010570
// Add the cost for reduced value resize (if required).
1057110571
if (ReductionBitWidth != 0) {
1057210572
assert(UserIgnoreList && "Expected reduction tree.");
10573-
const TreeEntry &E = *VectorizableTree.front().get();
10573+
const TreeEntry &E = *VectorizableTree.front();
1057410574
auto It = MinBWs.find(&E);
1057510575
if (It != MinBWs.end() && It->second.first != ReductionBitWidth) {
1057610576
unsigned SrcSize = It->second.first;
@@ -14099,7 +14099,7 @@ Value *BoUpSLP::vectorizeTree(
1409914099
Builder.ClearInsertionPoint();
1410014100
InstrElementSize.clear();
1410114101

14102-
const TreeEntry &RootTE = *VectorizableTree.front().get();
14102+
const TreeEntry &RootTE = *VectorizableTree.front();
1410314103
Value *Vec = RootTE.VectorizedValue;
1410414104
if (auto It = MinBWs.find(&RootTE); ReductionBitWidth != 0 &&
1410514105
It != MinBWs.end() &&
@@ -15486,8 +15486,8 @@ void BoUpSLP::computeMinimumValueSizes() {
1548615486
VectorizableTree.front()->Scalars.front()->getType()))
1548715487
Limit = 3;
1548815488
unsigned MaxBitWidth = ComputeMaxBitWidth(
15489-
*VectorizableTree[NodeIdx].get(), IsTopRoot, IsProfitableToDemoteRoot,
15490-
Opcode, Limit, IsTruncRoot, IsSignedCmp);
15489+
*VectorizableTree[NodeIdx], IsTopRoot, IsProfitableToDemoteRoot, Opcode,
15490+
Limit, IsTruncRoot, IsSignedCmp);
1549115491
if (ReductionBitWidth != 0 && (IsTopRoot || !RootDemotes.empty())) {
1549215492
if (MaxBitWidth != 0 && ReductionBitWidth < MaxBitWidth)
1549315493
ReductionBitWidth = bit_ceil(MaxBitWidth);

llvm/tools/bugpoint/CrashDebugger.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ cl::opt<bool> VerboseErrors("verbose-errors",
7272

7373
static bool isValidModule(std::unique_ptr<Module> &M,
7474
bool ExitOnFailure = true) {
75-
if (!llvm::verifyModule(*M.get(), &llvm::errs()))
75+
if (!llvm::verifyModule(*M, &llvm::errs()))
7676
return true;
7777

7878
if (ExitOnFailure) {

llvm/tools/llvm-as/llvm-as.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ int main(int argc, char **argv) {
153153
if (!DisableVerify) {
154154
std::string ErrorStr;
155155
raw_string_ostream OS(ErrorStr);
156-
if (verifyModule(*M.get(), &OS)) {
156+
if (verifyModule(*M, &OS)) {
157157
errs() << argv[0]
158158
<< ": assembly parsed, but does not verify as correct!\n";
159159
errs() << OS.str();
@@ -163,7 +163,7 @@ int main(int argc, char **argv) {
163163
}
164164

165165
if (DumpAsm) {
166-
errs() << "Here's the assembly:\n" << *M.get();
166+
errs() << "Here's the assembly:\n" << *M;
167167
if (Index.get() && Index->begin() != Index->end())
168168
Index->print(errs());
169169
}

llvm/tools/llvm-objdump/MachODump.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7179,7 +7179,7 @@ objdump::getMachODSymObject(const MachOObjectFile *MachOOF, StringRef Filename,
71797179
DSYMBuf = std::move(BufOrErr.get());
71807180

71817181
Expected<std::unique_ptr<Binary>> BinaryOrErr =
7182-
createBinary(DSYMBuf.get()->getMemBufferRef());
7182+
createBinary(DSYMBuf->getMemBufferRef());
71837183
if (!BinaryOrErr) {
71847184
reportError(BinaryOrErr.takeError(), DSYMPath);
71857185
return nullptr;

llvm/tools/llvm-profgen/ProfiledBinary.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ void BinarySizeContextTracker::trackInlineesOptimizedAway(
132132
MCPseudoProbeDecoder &ProbeDecoder) {
133133
ProbeFrameStack ProbeContext;
134134
for (const auto &Child : ProbeDecoder.getDummyInlineRoot().getChildren())
135-
trackInlineesOptimizedAway(ProbeDecoder, *Child.second.get(), ProbeContext);
135+
trackInlineesOptimizedAway(ProbeDecoder, *Child.second, ProbeContext);
136136
}
137137

138138
void BinarySizeContextTracker::trackInlineesOptimizedAway(
@@ -161,8 +161,7 @@ void BinarySizeContextTracker::trackInlineesOptimizedAway(
161161
for (const auto &ChildNode : ProbeNode.getChildren()) {
162162
InlineSite Location = ChildNode.first;
163163
ProbeContext.back().second = std::get<1>(Location);
164-
trackInlineesOptimizedAway(ProbeDecoder, *ChildNode.second.get(),
165-
ProbeContext);
164+
trackInlineesOptimizedAway(ProbeDecoder, *ChildNode.second, ProbeContext);
166165
}
167166

168167
ProbeContext.pop_back();
@@ -527,7 +526,7 @@ bool ProfiledBinary::dissassembleSymbol(std::size_t SI, ArrayRef<uint8_t> Bytes,
527526
outs() << format("%8" PRIx64 ":", Address);
528527
size_t Start = outs().tell();
529528
if (Disassembled)
530-
IPrinter->printInst(&Inst, Address + Size, "", *STI.get(), outs());
529+
IPrinter->printInst(&Inst, Address + Size, "", *STI, outs());
531530
else
532531
outs() << "\t<unknown>";
533532
if (ShowSourceLocations) {
@@ -845,7 +844,7 @@ void ProfiledBinary::loadSymbolsFromDWARF(ObjectFile &Obj) {
845844
exitWithError("Error creating the debug info context", Path);
846845

847846
for (const auto &CompilationUnit : DebugContext->compile_units())
848-
loadSymbolsFromDWARFUnit(*CompilationUnit.get());
847+
loadSymbolsFromDWARFUnit(*CompilationUnit);
849848

850849
// Handles DWO sections that can either be in .o, .dwo or .dwp files.
851850
uint32_t NumOfDWOMissing = 0;

llvm/tools/llvm-readobj/llvm-readobj.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -700,14 +700,14 @@ int llvm_readobj_main(int argc, char **argv, const llvm::ToolContext &) {
700700
std::unique_ptr<ScopedPrinter> Writer = createWriter();
701701

702702
for (const std::string &I : opts::InputFilenames)
703-
dumpInput(I, *Writer.get());
703+
dumpInput(I, *Writer);
704704

705705
if (opts::CodeViewMergedTypes) {
706706
if (opts::CodeViewEnableGHash)
707-
dumpCodeViewMergedTypes(*Writer.get(), CVTypes.GlobalIDTable.records(),
707+
dumpCodeViewMergedTypes(*Writer, CVTypes.GlobalIDTable.records(),
708708
CVTypes.GlobalTypeTable.records());
709709
else
710-
dumpCodeViewMergedTypes(*Writer.get(), CVTypes.IDTable.records(),
710+
dumpCodeViewMergedTypes(*Writer, CVTypes.IDTable.records(),
711711
CVTypes.TypeTable.records());
712712
}
713713

llvm/unittests/CodeGen/GlobalISel/GISelMITest.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,7 @@ static inline bool CheckMachineFunction(const MachineFunction &MF,
184184
SmallString<4096> CheckFileBuffer;
185185
FileCheckRequest Req;
186186
FileCheck FC(Req);
187-
StringRef CheckFileText =
188-
FC.CanonicalizeFile(*CheckBuf.get(), CheckFileBuffer);
187+
StringRef CheckFileText = FC.CanonicalizeFile(*CheckBuf, CheckFileBuffer);
189188
SourceMgr SM;
190189
SM.AddNewSourceBuffer(MemoryBuffer::getMemBuffer(CheckFileText, "CheckFile"),
191190
SMLoc());

llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ struct MockData1 {
147147

148148
Obj = yaml::yaml2ObjectFile(Storage, Buffer,
149149
[](const Twine &Err) { errs() << Err; });
150-
return *Obj.get();
150+
return *Obj;
151151
}
152152
};
153153

@@ -521,7 +521,7 @@ class MockData2 {
521521

522522
Obj = yaml::yaml2ObjectFile(ObjStorage, YamlBuffer,
523523
[](const Twine &Err) { errs() << Err; });
524-
return *Obj.get();
524+
return *Obj;
525525
}
526526
};
527527

llvm/unittests/DebugInfo/DWARF/DWARFExpressionCopyBytesTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ DWARFExpressionCopyBytesTest::createStreamer(raw_pwrite_stream &OS) {
101101
Res.Ctx =
102102
std::make_unique<MCContext>(Triple(TripleName), MAI.get(), MRI.get(),
103103
/*MSTI=*/nullptr);
104-
Res.MOFI.reset(TheTarget->createMCObjectFileInfo(*Res.Ctx.get(),
104+
Res.MOFI.reset(TheTarget->createMCObjectFileInfo(*Res.Ctx,
105105
/*PIC=*/false));
106106
Res.Ctx->setObjectFileInfo(Res.MOFI.get());
107107

llvm/unittests/IR/VFABIDemanglerTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class VFABIParserTest : public ::testing::Test {
4343
M = parseAssemblyString("declare void @dummy()", Err, Ctx);
4444
EXPECT_NE(M.get(), nullptr)
4545
<< "Loading an invalid module.\n " << Err.getMessage() << "\n";
46-
Type *Ty = parseType(ScalarFTyStr, Err, *(M.get()));
46+
Type *Ty = parseType(ScalarFTyStr, Err, *(M));
4747
ScalarFTy = dyn_cast<FunctionType>(Ty);
4848
EXPECT_NE(ScalarFTy, nullptr)
4949
<< "Invalid function type string: " << ScalarFTyStr << "\n"

llvm/unittests/Linker/LinkModulesTest.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@ class LinkModuleTest : public testing::Test {
4040

4141
AT = ArrayType::get(PointerType::getUnqual(Ctx), 3);
4242

43-
GV = new GlobalVariable(*M.get(), AT, false /*=isConstant*/,
44-
GlobalValue::InternalLinkage, nullptr,"switch.bas");
43+
GV =
44+
new GlobalVariable(*M, AT, false /*=isConstant*/,
45+
GlobalValue::InternalLinkage, nullptr, "switch.bas");
4546

4647
// Global Initializer
4748
std::vector<Constant *> Init;

llvm/unittests/MC/DwarfLineTableHeaders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class DwarfLineTableHeaders : public ::testing::Test {
7272
Res.Ctx =
7373
std::make_unique<MCContext>(Triple(TripleName), MAI.get(), MRI.get(),
7474
/*MSTI=*/nullptr);
75-
Res.MOFI.reset(TheTarget->createMCObjectFileInfo(*Res.Ctx.get(),
75+
Res.MOFI.reset(TheTarget->createMCObjectFileInfo(*Res.Ctx,
7676
/*PIC=*/false));
7777
Res.Ctx->setObjectFileInfo(Res.MOFI.get());
7878

llvm/unittests/MIR/MachineMetadata.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ static bool checkOutput(std::string CheckString, std::string Output) {
188188
SmallString<4096> CheckFileBuffer;
189189
FileCheckRequest Req;
190190
FileCheck FC(Req);
191-
StringRef CheckFileText =
192-
FC.CanonicalizeFile(*CheckBuffer.get(), CheckFileBuffer);
191+
StringRef CheckFileText = FC.CanonicalizeFile(*CheckBuffer, CheckFileBuffer);
193192

194193
SourceMgr SM;
195194
SM.AddNewSourceBuffer(MemoryBuffer::getMemBuffer(CheckFileText, "CheckFile"),

llvm/unittests/Target/X86/MachineSizeOptsTest.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ class MachineSizeOptsTest : public testing::Test {
7878
M->setTargetTriple(TM->getTargetTriple().getTriple());
7979
M->setDataLayout(TM->createDataLayout());
8080
MMI = std::make_unique<MachineModuleInfo>(TM.get());
81-
if (Parser->parseMachineFunctions(*M, *MMI.get()))
81+
if (Parser->parseMachineFunctions(*M, *MMI))
8282
report_fatal_error("parseMachineFunctions failed");
8383
}
8484

@@ -98,7 +98,7 @@ TEST_F(MachineSizeOptsTest, Test) {
9898
ASSERT_TRUE(G != nullptr);
9999
MachineFunction *H = getMachineFunction(M.get(), "h");
100100
ASSERT_TRUE(H != nullptr);
101-
ProfileSummaryInfo PSI = ProfileSummaryInfo(*M.get());
101+
ProfileSummaryInfo PSI = ProfileSummaryInfo(*M);
102102
ASSERT_TRUE(PSI.hasProfileSummary());
103103
BFIData BFID_F(*F);
104104
BFIData BFID_G(*G);

llvm/unittests/Transforms/Utils/SizeOptsTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ TEST_F(SizeOptsTest, Test) {
5555
Function *G = M->getFunction("g");
5656
Function *H = M->getFunction("h");
5757

58-
ProfileSummaryInfo PSI(*M.get());
58+
ProfileSummaryInfo PSI(*M);
5959
BFIData BFID_F(*F);
6060
BFIData BFID_G(*G);
6161
BFIData BFID_H(*H);

0 commit comments

Comments
 (0)