Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

Identified with bugprone-unused-local-non-trivial-variable.

Identified with bugprone-unused-local-non-trivial-variable.
@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2025

@llvm/pr-subscribers-vectorizers

@llvm/pr-subscribers-backend-arm

Author: Kazu Hirata (kazutakahirata)

Changes

Identified with bugprone-unused-local-non-trivial-variable.


Full diff: https://github.com/llvm/llvm-project/pull/167106.diff

5 Files Affected:

  • (modified) llvm/lib/CAS/UnifiedOnDiskCache.cpp (-2)
  • (modified) llvm/lib/CodeGen/WindowsSecureHotPatching.cpp (-2)
  • (modified) llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp (-1)
  • (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (-1)
  • (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (-2)
diff --git a/llvm/lib/CAS/UnifiedOnDiskCache.cpp b/llvm/lib/CAS/UnifiedOnDiskCache.cpp
index 7b790bb005ce9..e6b676accb0fe 100644
--- a/llvm/lib/CAS/UnifiedOnDiskCache.cpp
+++ b/llvm/lib/CAS/UnifiedOnDiskCache.cpp
@@ -331,8 +331,6 @@ Expected<ValidationResult> UnifiedOnDiskCache::validateIfNeeded(
     if (Error E = getBootTime().moveInto(BootTime))
       return std::move(E);
 
-  std::string LogValidationError;
-
   if (ValidationBootTime == BootTime && !ForceValidation)
     return ValidationResult::Skipped;
 
diff --git a/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp b/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
index fd54190b04468..dab1416d254a2 100644
--- a/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
+++ b/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
@@ -461,8 +461,6 @@ static bool searchConstantExprForGlobalVariables(
     Value *V, SmallDenseMap<GlobalVariable *, Value *> &GVLoadMap,
     SmallVector<GlobalVariableUse> &GVUses) {
 
-  SmallVector<Value *, 8> ReplacedOperands;
-
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
     if (globalVariableNeedsRedirect(GV)) {
       GVLoadMap[GV] = nullptr;
diff --git a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
index 597d311989b2f..1719165fb6717 100644
--- a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
+++ b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
@@ -1051,7 +1051,6 @@ bool LowOverheadLoop::ValidateLiveOuts() {
       // check where it gets its false lanes from, if any.
       int InactiveIdx = findVPTInactiveOperandIdx(*MI);
       if (InactiveIdx != -1) {
-        SmallPtrSet<MachineInstr *, 2> Defs;
         MachineInstr *FalseSrc = RDI.getUniqueReachingMIDef(
             MI, MI->getOperand(InactiveIdx).getReg());
         if (FalseSrc) {
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index e39e311dd795f..bd74388aaf217 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -2293,7 +2293,6 @@ bool SampleProfileLoader::runOnFunction(Function &F,
   // count value.
   if (!F.getEntryCount())
     F.setEntryCount(ProfileCount(initialEntryCount, Function::PCT_Real));
-  std::unique_ptr<OptimizationRemarkEmitter> OwnedORE;
   auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(*F.getParent())
                   .getManager();
   ORE = &FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index df835a077f2a0..c27d1ac99dd80 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5368,7 +5368,6 @@ class BoUpSLP {
           Lane = P.first->ReorderIndices[Lane];
         assert(Lane < static_cast<int>(P.first->Scalars.size()) &&
                "Couldn't find extract lane");
-        SmallVector<unsigned> OpIndices;
         for (unsigned OpIdx :
              seq<unsigned>(::getNumberOfPotentiallyCommutativeOps(
                  P.first->getMainOp()))) {
@@ -8815,7 +8814,6 @@ void BoUpSLP::buildExternalUses(
     const ExtraValueToDebugLocsMap &ExternallyUsedValues) {
   const size_t NumVectScalars = ScalarToTreeEntries.size() + 1;
   DenseMap<Value *, unsigned> ScalarToExtUses;
-  SmallPtrSet<Value *, 4> ExternalUsers;
   // Collect the values that we need to extract from the tree.
   for (auto &TEPtr : VectorizableTree) {
     TreeEntry *Entry = TEPtr.get();

@llvmbot
Copy link
Member

llvmbot commented Nov 8, 2025

@llvm/pr-subscribers-pgo

Author: Kazu Hirata (kazutakahirata)

Changes

Identified with bugprone-unused-local-non-trivial-variable.


Full diff: https://github.com/llvm/llvm-project/pull/167106.diff

5 Files Affected:

  • (modified) llvm/lib/CAS/UnifiedOnDiskCache.cpp (-2)
  • (modified) llvm/lib/CodeGen/WindowsSecureHotPatching.cpp (-2)
  • (modified) llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp (-1)
  • (modified) llvm/lib/Transforms/IPO/SampleProfile.cpp (-1)
  • (modified) llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp (-2)
diff --git a/llvm/lib/CAS/UnifiedOnDiskCache.cpp b/llvm/lib/CAS/UnifiedOnDiskCache.cpp
index 7b790bb005ce9..e6b676accb0fe 100644
--- a/llvm/lib/CAS/UnifiedOnDiskCache.cpp
+++ b/llvm/lib/CAS/UnifiedOnDiskCache.cpp
@@ -331,8 +331,6 @@ Expected<ValidationResult> UnifiedOnDiskCache::validateIfNeeded(
     if (Error E = getBootTime().moveInto(BootTime))
       return std::move(E);
 
-  std::string LogValidationError;
-
   if (ValidationBootTime == BootTime && !ForceValidation)
     return ValidationResult::Skipped;
 
diff --git a/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp b/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
index fd54190b04468..dab1416d254a2 100644
--- a/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
+++ b/llvm/lib/CodeGen/WindowsSecureHotPatching.cpp
@@ -461,8 +461,6 @@ static bool searchConstantExprForGlobalVariables(
     Value *V, SmallDenseMap<GlobalVariable *, Value *> &GVLoadMap,
     SmallVector<GlobalVariableUse> &GVUses) {
 
-  SmallVector<Value *, 8> ReplacedOperands;
-
   if (GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) {
     if (globalVariableNeedsRedirect(GV)) {
       GVLoadMap[GV] = nullptr;
diff --git a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
index 597d311989b2f..1719165fb6717 100644
--- a/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
+++ b/llvm/lib/Target/ARM/ARMLowOverheadLoops.cpp
@@ -1051,7 +1051,6 @@ bool LowOverheadLoop::ValidateLiveOuts() {
       // check where it gets its false lanes from, if any.
       int InactiveIdx = findVPTInactiveOperandIdx(*MI);
       if (InactiveIdx != -1) {
-        SmallPtrSet<MachineInstr *, 2> Defs;
         MachineInstr *FalseSrc = RDI.getUniqueReachingMIDef(
             MI, MI->getOperand(InactiveIdx).getReg());
         if (FalseSrc) {
diff --git a/llvm/lib/Transforms/IPO/SampleProfile.cpp b/llvm/lib/Transforms/IPO/SampleProfile.cpp
index e39e311dd795f..bd74388aaf217 100644
--- a/llvm/lib/Transforms/IPO/SampleProfile.cpp
+++ b/llvm/lib/Transforms/IPO/SampleProfile.cpp
@@ -2293,7 +2293,6 @@ bool SampleProfileLoader::runOnFunction(Function &F,
   // count value.
   if (!F.getEntryCount())
     F.setEntryCount(ProfileCount(initialEntryCount, Function::PCT_Real));
-  std::unique_ptr<OptimizationRemarkEmitter> OwnedORE;
   auto &FAM = AM.getResult<FunctionAnalysisManagerModuleProxy>(*F.getParent())
                   .getManager();
   ORE = &FAM.getResult<OptimizationRemarkEmitterAnalysis>(F);
diff --git a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
index df835a077f2a0..c27d1ac99dd80 100644
--- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
+++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
@@ -5368,7 +5368,6 @@ class BoUpSLP {
           Lane = P.first->ReorderIndices[Lane];
         assert(Lane < static_cast<int>(P.first->Scalars.size()) &&
                "Couldn't find extract lane");
-        SmallVector<unsigned> OpIndices;
         for (unsigned OpIdx :
              seq<unsigned>(::getNumberOfPotentiallyCommutativeOps(
                  P.first->getMainOp()))) {
@@ -8815,7 +8814,6 @@ void BoUpSLP::buildExternalUses(
     const ExtraValueToDebugLocsMap &ExternallyUsedValues) {
   const size_t NumVectScalars = ScalarToTreeEntries.size() + 1;
   DenseMap<Value *, unsigned> ScalarToExtUses;
-  SmallPtrSet<Value *, 4> ExternalUsers;
   // Collect the values that we need to extract from the tree.
   for (auto &TEPtr : VectorizableTree) {
     TreeEntry *Entry = TEPtr.get();

@kazutakahirata kazutakahirata merged commit 0028ef6 into llvm:main Nov 8, 2025
16 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_20251107_clang_tidy_bugprone-unused-local-non-trivial-variable_llvm branch November 8, 2025 15:43
vinay-deshmukh pushed a commit to vinay-deshmukh/llvm-project that referenced this pull request Nov 8, 2025
Identified with bugprone-unused-local-non-trivial-variable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants