[llvm] [BOLT] Remove unused local variables (NFC) (PR #140421)

Kazu Hirata via llvm-commits llvm-commits at lists.llvm.org
Sat May 17 17:17:44 PDT 2025


https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/140421

While I'm at it, this patch removes GetExecutablePath, which becomes
unused after removing the sole use.


>From a324f62ae5eaec0fb6dcc26f3a8091c8f4c64fb2 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 3 May 2025 23:50:31 -0700
Subject: [PATCH] [BOLT] Remove unused local variables (NFC)

While I'm at it, this patch removes GetExecutablePath, which becomes
unused after removing the sole use.
---
 bolt/lib/Core/DebugData.cpp          |  1 -
 bolt/lib/Passes/FrameAnalysis.cpp    |  1 -
 bolt/lib/Passes/HFSort.cpp           |  1 -
 bolt/lib/Rewrite/RewriteInstance.cpp |  1 -
 bolt/tools/bat-dump/bat-dump.cpp     | 11 -----------
 5 files changed, 15 deletions(-)

diff --git a/bolt/lib/Core/DebugData.cpp b/bolt/lib/Core/DebugData.cpp
index e11be499f2c34..521eb8d91bbc0 100644
--- a/bolt/lib/Core/DebugData.cpp
+++ b/bolt/lib/Core/DebugData.cpp
@@ -676,7 +676,6 @@ static void writeDWARF5LocList(uint32_t &NumberOfEntries, DIEValue &AttrInfo,
     return;
   }
 
-  std::vector<uint64_t> OffsetsArray;
   auto writeExpression = [&](uint32_t Index) -> void {
     const DebugLocationEntry &Entry = LocList[Index];
     encodeULEB128(Entry.Expr.size(), LocBodyStream);
diff --git a/bolt/lib/Passes/FrameAnalysis.cpp b/bolt/lib/Passes/FrameAnalysis.cpp
index e027fc0403cd9..f568039bbf163 100644
--- a/bolt/lib/Passes/FrameAnalysis.cpp
+++ b/bolt/lib/Passes/FrameAnalysis.cpp
@@ -320,7 +320,6 @@ bool FrameAnalysis::updateArgsTouchedFor(const BinaryFunction &BF, MCInst &Inst,
   if (!BC.MIB->isCall(Inst))
     return false;
 
-  std::set<int64_t> Res;
   const MCSymbol *TargetSymbol = BC.MIB->getTargetSymbol(Inst);
   // If indirect call, we conservatively assume it accesses all stack positions
   if (TargetSymbol == nullptr) {
diff --git a/bolt/lib/Passes/HFSort.cpp b/bolt/lib/Passes/HFSort.cpp
index 6569de7d6258f..2dcf089c6ebcb 100644
--- a/bolt/lib/Passes/HFSort.cpp
+++ b/bolt/lib/Passes/HFSort.cpp
@@ -239,7 +239,6 @@ std::vector<Cluster> clusterize(const CallGraph &Cg) {
 }
 
 std::vector<Cluster> randomClusters(const CallGraph &Cg) {
-  std::vector<NodeId> FuncIds(Cg.numNodes(), 0);
   std::vector<Cluster> Clusters;
   Clusters.reserve(Cg.numNodes());
 
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index dd519431fb2e3..ad062ea3622d1 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -4703,7 +4703,6 @@ RewriteInstance::getOutputSections(ELFObjectFile<ELFT> *File,
   }
 
   // Assign indices to sections.
-  std::unordered_map<std::string, uint64_t> NameToIndex;
   for (uint32_t Index = 1; Index < OutputSections.size(); ++Index)
     OutputSections[Index].first->setIndex(Index);
 
diff --git a/bolt/tools/bat-dump/bat-dump.cpp b/bolt/tools/bat-dump/bat-dump.cpp
index 8a743cba17540..f25f4c70f23b9 100644
--- a/bolt/tools/bat-dump/bat-dump.cpp
+++ b/bolt/tools/bat-dump/bat-dump.cpp
@@ -73,16 +73,6 @@ static void report_error(StringRef Message, Error E) {
   exit(1);
 }
 
-static std::string GetExecutablePath(const char *Argv0) {
-  SmallString<256> ExecutablePath(Argv0);
-  // Do a PATH lookup if Argv0 isn't a valid path.
-  if (!llvm::sys::fs::exists(ExecutablePath))
-    if (llvm::ErrorOr<std::string> P =
-            llvm::sys::findProgramByName(ExecutablePath))
-      ExecutablePath = *P;
-  return std::string(ExecutablePath);
-}
-
 void dumpBATFor(llvm::object::ELFObjectFileBase *InputFile) {
   BoltAddressTranslation BAT;
   if (!BAT.enabledFor(InputFile)) {
@@ -163,7 +153,6 @@ int main(int argc, char **argv) {
     report_error(opts::InputFilename, errc::no_such_file_or_directory);
 
   ToolName = argv[0];
-  std::string ToolPath = GetExecutablePath(argv[0]);
   Expected<llvm::object::OwningBinary<llvm::object::Binary>> BinaryOrErr =
       llvm::object::createBinary(opts::InputFilename);
   if (Error E = BinaryOrErr.takeError())



More information about the llvm-commits mailing list