Skip to content

Commit

Permalink
[llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazutakahirata committed Jul 6, 2024
1 parent 02c7be5 commit 42dc4b7
Show file tree
Hide file tree
Showing 27 changed files with 43 additions and 45 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/BranchProbabilityInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ class BranchProbabilityInfo {

/// Helper to construct LoopBlock for \p BB.
LoopBlock getLoopBlock(const BasicBlock *BB) const {
return LoopBlock(BB, *LI, *SccI.get());
return LoopBlock(BB, *LI, *SccI);
}

/// Returns true if destination block belongs to some loop and source block is
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/MLInlineAdvisor.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class MLInlineAdvisor : public InlineAdvisor {

bool isForcedToStop() const { return ForceStop; }
int64_t getLocalCalls(Function &F);
const MLModelRunner &getModelRunner() const { return *ModelRunner.get(); }
const MLModelRunner &getModelRunner() const { return *ModelRunner; }
FunctionPropertiesInfo &getCachedFPI(Function &) const;

protected:
Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/MemorySSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ class MemorySSAAnalysis : public AnalysisInfoMixin<MemorySSAAnalysis> {
struct Result {
Result(std::unique_ptr<MemorySSA> &&MSSA) : MSSA(std::move(MSSA)) {}

MemorySSA &getMSSA() { return *MSSA.get(); }
MemorySSA &getMSSA() { return *MSSA; }

std::unique_ptr<MemorySSA> MSSA;

Expand Down
2 changes: 1 addition & 1 deletion llvm/include/llvm/ProfileData/SampleProfReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ class SampleProfileReader {
StringRef RemapFilename = "");

/// Return the profile summary.
ProfileSummary &getSummary() const { return *(Summary.get()); }
ProfileSummary &getSummary() const { return *Summary; }

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

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/GISelKnownBits.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -859,5 +859,5 @@ GISelKnownBits &GISelKnownBitsAnalysis::get(MachineFunction &MF) {
MF.getTarget().getOptLevel() == CodeGenOptLevel::None ? 2 : 6;
Info = std::make_unique<GISelKnownBits>(MF, MaxDepth);
}
return *Info.get();
return *Info;
}
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3968,7 +3968,7 @@ bool IRTranslator::runOnMachineFunction(MachineFunction &CurMF) {
#endif // ifndef NDEBUG

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

if (translate(Inst))
continue;
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1843,13 +1843,13 @@ bool CompileUnit::resolveDependenciesAndMarkLiveness(
bool CompileUnit::updateDependenciesCompleteness() {
assert(Dependencies.get());

return Dependencies.get()->updateDependenciesCompleteness();
return Dependencies->updateDependenciesCompleteness();
}

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

Dependencies.get()->verifyKeepChain();
Dependencies->verifyKeepChain();
}

ArrayRef<dwarf::Attribute> dwarf_linker::parallel::getODRAttributes() {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ Error DWARFLinkerImpl::link() {
// twice. And then following handling might be removed.
for (const std::unique_ptr<DWARFUnit> &OrigCU :
Context->InputDWARFFile.Dwarf->compile_units()) {
DWARFDie UnitDie = OrigCU.get()->getUnitDIE();
DWARFDie UnitDie = OrigCU->getUnitDIE();

if (!Language) {
if (std::optional<DWARFFormValue> Val =
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/IR/DebugProgramInstruction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ DbgVariableIntrinsic *
DbgVariableRecord::createDebugIntrinsic(Module *M,
Instruction *InsertBefore) const {
[[maybe_unused]] DICompileUnit *Unit =
getDebugLoc().get()->getScope()->getSubprogram()->getUnit();
getDebugLoc()->getScope()->getSubprogram()->getUnit();
assert(M && Unit &&
"Cannot clone from BasicBlock that is not part of a Module or "
"DICompileUnit!");
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ObjectYAML/XCOFFYAML.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ void MappingTraits<std::unique_ptr<XCOFFYAML::AuxSymbolEnt>>::mapping(

XCOFFYAML::AuxSymbolType AuxType;
if (IO.outputting())
AuxType = AuxSym.get()->Type;
AuxType = AuxSym->Type;
IO.mapRequired("Type", AuxType);
switch (AuxType) {
case XCOFFYAML::AUX_EXCEPT:
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Support/TimeProfiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ struct llvm::TimeTraceProfiler {

void end() {
assert(!Stack.empty() && "Must call begin() first");
end(*Stack.back().get());
end(*Stack.back());
}

void end(TimeTraceProfilerEntry &E) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ToolDrivers/llvm-lib/LibDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ static void doList(opt::InputArgList &Args) {
return;

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

std::vector<StringRef> Names;
Expand Down
12 changes: 6 additions & 6 deletions llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8001,7 +8001,7 @@ getGEPCosts(const TargetTransformInfo &TTI, ArrayRef<Value *> Ptrs,
void BoUpSLP::transformNodes() {
constexpr TTI::TargetCostKind CostKind = TTI::TCK_RecipThroughput;
for (std::unique_ptr<TreeEntry> &TE : VectorizableTree) {
TreeEntry &E = *TE.get();
TreeEntry &E = *TE;
switch (E.getOpcode()) {
case Instruction::Load: {
// No need to reorder masked gather loads, just reorder the scalar
Expand Down Expand Up @@ -10462,7 +10462,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
}
// Add reduced value cost, if resized.
if (!VectorizedVals.empty()) {
const TreeEntry &Root = *VectorizableTree.front().get();
const TreeEntry &Root = *VectorizableTree.front();
auto BWIt = MinBWs.find(&Root);
if (BWIt != MinBWs.end()) {
Type *DstTy = Root.Scalars.front()->getType();
Expand Down Expand Up @@ -10570,7 +10570,7 @@ InstructionCost BoUpSLP::getTreeCost(ArrayRef<Value *> VectorizedVals) {
// Add the cost for reduced value resize (if required).
if (ReductionBitWidth != 0) {
assert(UserIgnoreList && "Expected reduction tree.");
const TreeEntry &E = *VectorizableTree.front().get();
const TreeEntry &E = *VectorizableTree.front();
auto It = MinBWs.find(&E);
if (It != MinBWs.end() && It->second.first != ReductionBitWidth) {
unsigned SrcSize = It->second.first;
Expand Down Expand Up @@ -14099,7 +14099,7 @@ Value *BoUpSLP::vectorizeTree(
Builder.ClearInsertionPoint();
InstrElementSize.clear();

const TreeEntry &RootTE = *VectorizableTree.front().get();
const TreeEntry &RootTE = *VectorizableTree.front();
Value *Vec = RootTE.VectorizedValue;
if (auto It = MinBWs.find(&RootTE); ReductionBitWidth != 0 &&
It != MinBWs.end() &&
Expand Down Expand Up @@ -15486,8 +15486,8 @@ void BoUpSLP::computeMinimumValueSizes() {
VectorizableTree.front()->Scalars.front()->getType()))
Limit = 3;
unsigned MaxBitWidth = ComputeMaxBitWidth(
*VectorizableTree[NodeIdx].get(), IsTopRoot, IsProfitableToDemoteRoot,
Opcode, Limit, IsTruncRoot, IsSignedCmp);
*VectorizableTree[NodeIdx], IsTopRoot, IsProfitableToDemoteRoot, Opcode,
Limit, IsTruncRoot, IsSignedCmp);
if (ReductionBitWidth != 0 && (IsTopRoot || !RootDemotes.empty())) {
if (MaxBitWidth != 0 && ReductionBitWidth < MaxBitWidth)
ReductionBitWidth = bit_ceil(MaxBitWidth);
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/bugpoint/CrashDebugger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ cl::opt<bool> VerboseErrors("verbose-errors",

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

if (ExitOnFailure) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/tools/llvm-as/llvm-as.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ int main(int argc, char **argv) {
if (!DisableVerify) {
std::string ErrorStr;
raw_string_ostream OS(ErrorStr);
if (verifyModule(*M.get(), &OS)) {
if (verifyModule(*M, &OS)) {
errs() << argv[0]
<< ": assembly parsed, but does not verify as correct!\n";
errs() << OS.str();
Expand All @@ -163,7 +163,7 @@ int main(int argc, char **argv) {
}

if (DumpAsm) {
errs() << "Here's the assembly:\n" << *M.get();
errs() << "Here's the assembly:\n" << *M;
if (Index.get() && Index->begin() != Index->end())
Index->print(errs());
}
Expand Down
2 changes: 1 addition & 1 deletion llvm/tools/llvm-objdump/MachODump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7179,7 +7179,7 @@ objdump::getMachODSymObject(const MachOObjectFile *MachOOF, StringRef Filename,
DSYMBuf = std::move(BufOrErr.get());

Expected<std::unique_ptr<Binary>> BinaryOrErr =
createBinary(DSYMBuf.get()->getMemBufferRef());
createBinary(DSYMBuf->getMemBufferRef());
if (!BinaryOrErr) {
reportError(BinaryOrErr.takeError(), DSYMPath);
return nullptr;
Expand Down
9 changes: 4 additions & 5 deletions llvm/tools/llvm-profgen/ProfiledBinary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ void BinarySizeContextTracker::trackInlineesOptimizedAway(
MCPseudoProbeDecoder &ProbeDecoder) {
ProbeFrameStack ProbeContext;
for (const auto &Child : ProbeDecoder.getDummyInlineRoot().getChildren())
trackInlineesOptimizedAway(ProbeDecoder, *Child.second.get(), ProbeContext);
trackInlineesOptimizedAway(ProbeDecoder, *Child.second, ProbeContext);
}

void BinarySizeContextTracker::trackInlineesOptimizedAway(
Expand Down Expand Up @@ -161,8 +161,7 @@ void BinarySizeContextTracker::trackInlineesOptimizedAway(
for (const auto &ChildNode : ProbeNode.getChildren()) {
InlineSite Location = ChildNode.first;
ProbeContext.back().second = std::get<1>(Location);
trackInlineesOptimizedAway(ProbeDecoder, *ChildNode.second.get(),
ProbeContext);
trackInlineesOptimizedAway(ProbeDecoder, *ChildNode.second, ProbeContext);
}

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

for (const auto &CompilationUnit : DebugContext->compile_units())
loadSymbolsFromDWARFUnit(*CompilationUnit.get());
loadSymbolsFromDWARFUnit(*CompilationUnit);

// Handles DWO sections that can either be in .o, .dwo or .dwp files.
uint32_t NumOfDWOMissing = 0;
Expand Down
6 changes: 3 additions & 3 deletions llvm/tools/llvm-readobj/llvm-readobj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -700,14 +700,14 @@ int llvm_readobj_main(int argc, char **argv, const llvm::ToolContext &) {
std::unique_ptr<ScopedPrinter> Writer = createWriter();

for (const std::string &I : opts::InputFilenames)
dumpInput(I, *Writer.get());
dumpInput(I, *Writer);

if (opts::CodeViewMergedTypes) {
if (opts::CodeViewEnableGHash)
dumpCodeViewMergedTypes(*Writer.get(), CVTypes.GlobalIDTable.records(),
dumpCodeViewMergedTypes(*Writer, CVTypes.GlobalIDTable.records(),
CVTypes.GlobalTypeTable.records());
else
dumpCodeViewMergedTypes(*Writer.get(), CVTypes.IDTable.records(),
dumpCodeViewMergedTypes(*Writer, CVTypes.IDTable.records(),
CVTypes.TypeTable.records());
}

Expand Down
3 changes: 1 addition & 2 deletions llvm/unittests/CodeGen/GlobalISel/GISelMITest.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ static inline bool CheckMachineFunction(const MachineFunction &MF,
SmallString<4096> CheckFileBuffer;
FileCheckRequest Req;
FileCheck FC(Req);
StringRef CheckFileText =
FC.CanonicalizeFile(*CheckBuf.get(), CheckFileBuffer);
StringRef CheckFileText = FC.CanonicalizeFile(*CheckBuf, CheckFileBuffer);
SourceMgr SM;
SM.AddNewSourceBuffer(MemoryBuffer::getMemBuffer(CheckFileText, "CheckFile"),
SMLoc());
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/DebugInfo/BTF/BTFParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct MockData1 {

Obj = yaml::yaml2ObjectFile(Storage, Buffer,
[](const Twine &Err) { errs() << Err; });
return *Obj.get();
return *Obj;
}
};

Expand Down Expand Up @@ -521,7 +521,7 @@ class MockData2 {

Obj = yaml::yaml2ObjectFile(ObjStorage, YamlBuffer,
[](const Twine &Err) { errs() << Err; });
return *Obj.get();
return *Obj;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ DWARFExpressionCopyBytesTest::createStreamer(raw_pwrite_stream &OS) {
Res.Ctx =
std::make_unique<MCContext>(Triple(TripleName), MAI.get(), MRI.get(),
/*MSTI=*/nullptr);
Res.MOFI.reset(TheTarget->createMCObjectFileInfo(*Res.Ctx.get(),
Res.MOFI.reset(TheTarget->createMCObjectFileInfo(*Res.Ctx,
/*PIC=*/false));
Res.Ctx->setObjectFileInfo(Res.MOFI.get());

Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/IR/VFABIDemanglerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class VFABIParserTest : public ::testing::Test {
M = parseAssemblyString("declare void @dummy()", Err, Ctx);
EXPECT_NE(M.get(), nullptr)
<< "Loading an invalid module.\n " << Err.getMessage() << "\n";
Type *Ty = parseType(ScalarFTyStr, Err, *(M.get()));
Type *Ty = parseType(ScalarFTyStr, Err, *(M));
ScalarFTy = dyn_cast<FunctionType>(Ty);
EXPECT_NE(ScalarFTy, nullptr)
<< "Invalid function type string: " << ScalarFTyStr << "\n"
Expand Down
5 changes: 3 additions & 2 deletions llvm/unittests/Linker/LinkModulesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,9 @@ class LinkModuleTest : public testing::Test {

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

GV = new GlobalVariable(*M.get(), AT, false /*=isConstant*/,
GlobalValue::InternalLinkage, nullptr,"switch.bas");
GV =
new GlobalVariable(*M, AT, false /*=isConstant*/,
GlobalValue::InternalLinkage, nullptr, "switch.bas");

// Global Initializer
std::vector<Constant *> Init;
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/MC/DwarfLineTableHeaders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class DwarfLineTableHeaders : public ::testing::Test {
Res.Ctx =
std::make_unique<MCContext>(Triple(TripleName), MAI.get(), MRI.get(),
/*MSTI=*/nullptr);
Res.MOFI.reset(TheTarget->createMCObjectFileInfo(*Res.Ctx.get(),
Res.MOFI.reset(TheTarget->createMCObjectFileInfo(*Res.Ctx,
/*PIC=*/false));
Res.Ctx->setObjectFileInfo(Res.MOFI.get());

Expand Down
3 changes: 1 addition & 2 deletions llvm/unittests/MIR/MachineMetadata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,7 @@ static bool checkOutput(std::string CheckString, std::string Output) {
SmallString<4096> CheckFileBuffer;
FileCheckRequest Req;
FileCheck FC(Req);
StringRef CheckFileText =
FC.CanonicalizeFile(*CheckBuffer.get(), CheckFileBuffer);
StringRef CheckFileText = FC.CanonicalizeFile(*CheckBuffer, CheckFileBuffer);

SourceMgr SM;
SM.AddNewSourceBuffer(MemoryBuffer::getMemBuffer(CheckFileText, "CheckFile"),
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/Target/X86/MachineSizeOptsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class MachineSizeOptsTest : public testing::Test {
M->setTargetTriple(TM->getTargetTriple().getTriple());
M->setDataLayout(TM->createDataLayout());
MMI = std::make_unique<MachineModuleInfo>(TM.get());
if (Parser->parseMachineFunctions(*M, *MMI.get()))
if (Parser->parseMachineFunctions(*M, *MMI))
report_fatal_error("parseMachineFunctions failed");
}

Expand All @@ -98,7 +98,7 @@ TEST_F(MachineSizeOptsTest, Test) {
ASSERT_TRUE(G != nullptr);
MachineFunction *H = getMachineFunction(M.get(), "h");
ASSERT_TRUE(H != nullptr);
ProfileSummaryInfo PSI = ProfileSummaryInfo(*M.get());
ProfileSummaryInfo PSI = ProfileSummaryInfo(*M);
ASSERT_TRUE(PSI.hasProfileSummary());
BFIData BFID_F(*F);
BFIData BFID_G(*G);
Expand Down
2 changes: 1 addition & 1 deletion llvm/unittests/Transforms/Utils/SizeOptsTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ TEST_F(SizeOptsTest, Test) {
Function *G = M->getFunction("g");
Function *H = M->getFunction("h");

ProfileSummaryInfo PSI(*M.get());
ProfileSummaryInfo PSI(*M);
BFIData BFID_F(*F);
BFIData BFID_G(*G);
BFIData BFID_H(*H);
Expand Down

0 comments on commit 42dc4b7

Please sign in to comment.