diff options
author | Sergei Barannikov <barannikov88@gmail.com> | 2025-05-11 03:37:08 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-05-11 03:37:08 +0300 |
commit | e79c2bd7331ab742f1f535a333870c57798b2c7b (patch) | |
tree | f603cf5f93bffe8b109a9042a467ec583230a985 /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 8e9da213ea406d3afafae2b34233308bb508b36b (diff) | |
download | llvm-e79c2bd7331ab742f1f535a333870c57798b2c7b.zip llvm-e79c2bd7331ab742f1f535a333870c57798b2c7b.tar.gz llvm-e79c2bd7331ab742f1f535a333870c57798b2c7b.tar.bz2 |
[llvm-objdump] Print symbolized labels with increasing index (#139415)
To make it easier to navigate the disassembly listing.
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index 1584547..2f83919 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1500,8 +1500,7 @@ collectLocalBranchTargets(ArrayRef<uint8_t> Bytes, MCInstrAnalysis *MIA, if (MIA) MIA->resetState(); - Labels.clear(); - unsigned LabelCount = 0; + std::set<uint64_t> Targets; Start += SectionAddr; End += SectionAddr; const bool isXCOFF = STI->getTargetTriple().isOSBinFormatXCOFF(); @@ -1521,13 +1520,13 @@ collectLocalBranchTargets(ArrayRef<uint8_t> Bytes, MCInstrAnalysis *MIA, uint64_t Target; bool TargetKnown = MIA->evaluateBranch(Inst, Index, Size, Target); if (TargetKnown && (Target >= Start && Target < End) && - !Labels.count(Target)) { + !Targets.count(Target)) { // On PowerPC and AIX, a function call is encoded as a branch to 0. // On other PowerPC platforms (ELF), a function call is encoded as // a branch to self. Do not add a label for these cases. if (!(isPPC && ((Target == 0 && isXCOFF) || (Target == Index && !isXCOFF)))) - Labels[Target] = ("L" + Twine(LabelCount++)).str(); + Targets.insert(Target); } MIA->updateState(Inst, Index); } else @@ -1535,6 +1534,10 @@ collectLocalBranchTargets(ArrayRef<uint8_t> Bytes, MCInstrAnalysis *MIA, } Index += Size; } + + Labels.clear(); + for (auto [Idx, Target] : enumerate(Targets)) + Labels[Target] = ("L" + Twine(Idx)).str(); } // Create an MCSymbolizer for the target and add it to the MCDisassembler. |