[llvm] [llvm] Remove redundant calls to std::unique_ptr<T>::get (NFC) (PR #97778)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 4 18:07:03 PDT 2024
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/97778
None
>From e3396282f71af1066f800b9043cbb7ac60ef2487 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Thu, 4 Jul 2024 17:47:15 -0700
Subject: [PATCH] [llvm] Remove redundant calls to std::unique_ptr<T>::get
(NFC)
---
llvm/include/llvm/CodeGen/TargetInstrInfo.h | 2 +-
.../Parallel/DWARFLinkerCompileUnit.cpp | 2 +-
.../DWARFLinker/Parallel/DWARFLinkerImpl.cpp | 28 +++++++++----------
llvm/lib/Target/AMDGPU/SIInstrInfo.h | 2 +-
llvm/tools/bugpoint/BugDriver.cpp | 2 +-
llvm/tools/llvm-as/llvm-as.cpp | 2 +-
llvm/tools/llvm-extract/llvm-extract.cpp | 2 +-
llvm/tools/llvm-link/llvm-link.cpp | 4 +--
.../verify-uselistorder.cpp | 4 +--
9 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/llvm/include/llvm/CodeGen/TargetInstrInfo.h b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
index 75cb17f357241..5c7f6ddc94840 100644
--- a/llvm/include/llvm/CodeGen/TargetInstrInfo.h
+++ b/llvm/include/llvm/CodeGen/TargetInstrInfo.h
@@ -2214,7 +2214,7 @@ class TargetInstrInfo : public MCInstrInfo {
/// Return MIR formatter to format/parse MIR operands. Target can override
/// this virtual function and return target specific MIR formatter.
virtual const MIRFormatter *getMIRFormatter() const {
- if (!Formatter.get())
+ if (!Formatter)
Formatter = std::make_unique<MIRFormatter>();
return Formatter.get();
}
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
index 8a7313628b992..0cb9cd5f9ea31 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerCompileUnit.cpp
@@ -1833,7 +1833,7 @@ TypeUnit *CompileUnit::OutputUnitVariantPtr::getAsTypeUnit() {
bool CompileUnit::resolveDependenciesAndMarkLiveness(
bool InterCUProcessingStarted, std::atomic<bool> &HasNewInterconnectedCUs) {
- if (!Dependencies.get())
+ if (!Dependencies)
Dependencies.reset(new DependencyTracker(*this));
return Dependencies->resolveDependenciesAndMarkLiveness(
diff --git a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
index c060f8f4c1718..84fd0806f0705 100644
--- a/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
+++ b/llvm/lib/DWARFLinker/Parallel/DWARFLinkerImpl.cpp
@@ -107,7 +107,7 @@ Error DWARFLinkerImpl::link() {
std::optional<uint16_t> Language;
for (std::unique_ptr<LinkContext> &Context : ObjectContexts) {
- if (Context->InputDWARFFile.Dwarf.get() == nullptr) {
+ if (Context->InputDWARFFile.Dwarf == nullptr) {
Context->setOutputFormat(Context->getFormParams(), GlobalEndianness);
continue;
}
@@ -203,13 +203,13 @@ Error DWARFLinkerImpl::link() {
Pool.wait();
}
- if (ArtificialTypeUnit.get() != nullptr && !ArtificialTypeUnit->getTypePool()
- .getRoot()
- ->getValue()
- .load()
- ->Children.empty()) {
+ if (ArtificialTypeUnit != nullptr && !ArtificialTypeUnit->getTypePool()
+ .getRoot()
+ ->getValue()
+ .load()
+ ->Children.empty()) {
if (GlobalData.getTargetTriple().has_value())
- if (Error Err = ArtificialTypeUnit.get()->finishCloningAndEmit(
+ if (Error Err = ArtificialTypeUnit->finishCloningAndEmit(
(*GlobalData.getTargetTriple()).get()))
return Err;
}
@@ -732,7 +732,7 @@ Error DWARFLinkerImpl::LinkContext::cloneAndEmitDebugFrame() {
if (!GlobalData.getTargetTriple().has_value())
return Error::success();
- if (InputDWARFFile.Dwarf.get() == nullptr)
+ if (InputDWARFFile.Dwarf == nullptr)
return Error::success();
const DWARFObject &InputDWARFObj = InputDWARFFile.Dwarf->getDWARFObj();
@@ -865,7 +865,7 @@ void DWARFLinkerImpl::glueCompileUnitsAndWriteToTheOutput() {
// units into the resulting file.
emitCommonSectionsAndWriteCompileUnitsToTheOutput();
- if (ArtificialTypeUnit.get() != nullptr)
+ if (ArtificialTypeUnit != nullptr)
ArtificialTypeUnit.reset();
// Write common debug sections into the resulting file.
@@ -1018,7 +1018,7 @@ void DWARFLinkerImpl::forEachOutputString(
});
});
- if (ArtificialTypeUnit.get() != nullptr) {
+ if (ArtificialTypeUnit != nullptr) {
ArtificialTypeUnit->forEach([&](SectionDescriptor &OutSection) {
OutSection.ListDebugStrPatch.forEach([&](DebugStrPatch &Patch) {
StringHandler(StringDestinationKind::DebugStr, Patch.String);
@@ -1049,7 +1049,7 @@ void DWARFLinkerImpl::forEachOutputString(
void DWARFLinkerImpl::forEachObjectSectionsSet(
function_ref<void(OutputSections &)> SectionsSetHandler) {
// Handle artificial type unit first.
- if (ArtificialTypeUnit.get() != nullptr)
+ if (ArtificialTypeUnit != nullptr)
SectionsSetHandler(*ArtificialTypeUnit);
// Then all modules(before regular compilation units).
@@ -1072,7 +1072,7 @@ void DWARFLinkerImpl::forEachObjectSectionsSet(
void DWARFLinkerImpl::forEachCompileAndTypeUnit(
function_ref<void(DwarfUnit *CU)> UnitHandler) {
- if (ArtificialTypeUnit.get() != nullptr)
+ if (ArtificialTypeUnit != nullptr)
UnitHandler(ArtificialTypeUnit.get());
// Enumerate module units.
@@ -1348,7 +1348,7 @@ void DWARFLinkerImpl::emitDWARFv5DebugNamesSection(const Triple &TargetTriple) {
forEachCompileAndTypeUnit([&](DwarfUnit *CU) {
bool HasRecords = false;
CU->forEachAcceleratorRecord([&](const DwarfUnit::AccelInfo &Info) {
- if (DebugNames.get() == nullptr)
+ if (DebugNames == nullptr)
DebugNames = std::make_unique<DWARF5AccelTable>();
HasRecords = true;
@@ -1375,7 +1375,7 @@ void DWARFLinkerImpl::emitDWARFv5DebugNamesSection(const Triple &TargetTriple) {
}
});
- if (DebugNames.get() != nullptr) {
+ if (DebugNames != nullptr) {
// FIXME: we use AsmPrinter to emit accelerator sections.
// It might be beneficial to directly emit accelerator data
// to the raw_svector_ostream.
diff --git a/llvm/lib/Target/AMDGPU/SIInstrInfo.h b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
index 84bb73cc9a796..1e2b687854c77 100644
--- a/llvm/lib/Target/AMDGPU/SIInstrInfo.h
+++ b/llvm/lib/Target/AMDGPU/SIInstrInfo.h
@@ -1384,7 +1384,7 @@ class SIInstrInfo final : public AMDGPUGenInstrInfo {
getGenericInstructionUniformity(const MachineInstr &MI) const;
const MIRFormatter *getMIRFormatter() const override {
- if (!Formatter.get())
+ if (!Formatter)
Formatter = std::make_unique<AMDGPUMIRFormatter>();
return Formatter.get();
}
diff --git a/llvm/tools/bugpoint/BugDriver.cpp b/llvm/tools/bugpoint/BugDriver.cpp
index 32c747fdd5166..f9b8d09501672 100644
--- a/llvm/tools/bugpoint/BugDriver.cpp
+++ b/llvm/tools/bugpoint/BugDriver.cpp
@@ -142,7 +142,7 @@ bool BugDriver::addSources(const std::vector<std::string> &Filenames) {
for (unsigned i = 1, e = Filenames.size(); i != e; ++i) {
std::unique_ptr<Module> M = parseInputFile(Filenames[i], Context);
- if (!M.get())
+ if (!M)
return true;
outs() << "Linking in input file: '" << Filenames[i] << "'\n";
diff --git a/llvm/tools/llvm-as/llvm-as.cpp b/llvm/tools/llvm-as/llvm-as.cpp
index 082565a9ef3d9..9b9af76267619 100644
--- a/llvm/tools/llvm-as/llvm-as.cpp
+++ b/llvm/tools/llvm-as/llvm-as.cpp
@@ -137,7 +137,7 @@ int main(int argc, char **argv) {
nullptr, SetDataLayout);
}
std::unique_ptr<Module> M = std::move(ModuleAndIndex.Mod);
- if (!M.get()) {
+ if (!M) {
Err.print(argv[0], errs());
return 1;
}
diff --git a/llvm/tools/llvm-extract/llvm-extract.cpp b/llvm/tools/llvm-extract/llvm-extract.cpp
index 5915f92ea05c3..4ee644f1e2906 100644
--- a/llvm/tools/llvm-extract/llvm-extract.cpp
+++ b/llvm/tools/llvm-extract/llvm-extract.cpp
@@ -147,7 +147,7 @@ int main(int argc, char **argv) {
SMDiagnostic Err;
std::unique_ptr<Module> M = getLazyIRFileModule(InputFilename, Err, Context);
- if (!M.get()) {
+ if (!M) {
Err.print(argv[0], errs());
return 1;
}
diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp
index 24ee02be7e9ee..b311820ce5870 100644
--- a/llvm/tools/llvm-link/llvm-link.cpp
+++ b/llvm/tools/llvm-link/llvm-link.cpp
@@ -231,7 +231,7 @@ static std::unique_ptr<Module> loadArFile(const char *Argv0,
M = getLazyIRModule(MemoryBuffer::getMemBuffer(MemBuf.get(), false),
ParseErr, Context);
- if (!M.get()) {
+ if (!M) {
errs() << Argv0 << ": ";
WithColor::error() << " parsing member '" << ChildName
<< "' of archive library failed'" << ArchiveName
@@ -417,7 +417,7 @@ static bool linkFiles(const char *argv0, LLVMContext &Context, Linker &L,
identify_magic(Buffer->getBuffer()) == file_magic::archive
? loadArFile(argv0, std::move(Buffer), Context)
: loadFile(argv0, std::move(Buffer), Context);
- if (!M.get()) {
+ if (!M) {
errs() << argv0 << ": ";
WithColor::error() << " loading file '" << File << "'\n";
return false;
diff --git a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
index 84fc777e1fdff..f316bff1e49a5 100644
--- a/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
+++ b/llvm/tools/verify-uselistorder/verify-uselistorder.cpp
@@ -176,7 +176,7 @@ std::unique_ptr<Module> TempFile::readAssembly(LLVMContext &Context) const {
LLVM_DEBUG(dbgs() << " - read assembly\n");
SMDiagnostic Err;
std::unique_ptr<Module> M = parseAssemblyFile(Filename, Err, Context);
- if (!M.get())
+ if (!M)
Err.print("verify-uselistorder", errs());
return M;
}
@@ -555,7 +555,7 @@ int main(int argc, char **argv) {
// Load the input module...
std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);
- if (!M.get()) {
+ if (!M) {
Err.print(argv[0], errs());
return 1;
}
More information about the llvm-commits
mailing list