Skip to content

Conversation

@kazutakahirata
Copy link
Contributor

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

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

llvmbot commented May 18, 2025

@llvm/pr-subscribers-bolt

Author: Kazu Hirata (kazutakahirata)

Changes

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


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

5 Files Affected:

  • (modified) bolt/lib/Core/DebugData.cpp (-1)
  • (modified) bolt/lib/Passes/FrameAnalysis.cpp (-1)
  • (modified) bolt/lib/Passes/HFSort.cpp (-1)
  • (modified) bolt/lib/Rewrite/RewriteInstance.cpp (-1)
  • (modified) bolt/tools/bat-dump/bat-dump.cpp (-11)
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())

@kazutakahirata kazutakahirata merged commit d08833f into llvm:main May 18, 2025
12 checks passed
@kazutakahirata kazutakahirata deleted the cleanup_001_tidy_bugprone-unused-local-non-trivial-variable_bolt branch May 18, 2025 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants