diff options
author | eddyz87 <eddyz87@gmail.com> | 2024-07-31 08:52:34 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-07-31 08:52:34 +0300 |
commit | ee1040b02adc95e376b295c4f59d30b991a8be9a (patch) | |
tree | 390036073f7929286a709d26c1222ac94aba578b /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 7a80c86726f7c37128bfee3618707c1607f5014d (diff) | |
download | llvm-ee1040b02adc95e376b295c4f59d30b991a8be9a.zip llvm-ee1040b02adc95e376b295c4f59d30b991a8be9a.tar.gz llvm-ee1040b02adc95e376b295c4f59d30b991a8be9a.tar.bz2 |
[llvm-objdump][BPF] --symbolize-operands: infer local labels for BPF (#100550)
Enable local labels computation for BPF disassembly when
`--symbolize-operands` option is specified.
This relies on `MCInstrAnalysis::evaluateBranch()` method, which is
already defined in `BPFMCInstrAnalysis::evaluateBranch`.
After this change the assembly code below:
if r1 > 42 goto +1
r1 -= 10
...
Would be printed as:
if r1 > 42 goto +1 <L0>
r1 -= 10
<L0>:
...
(when `--symbolize-operands` option is set).
See https://reviews.llvm.org/D84191 for the main part of the
`--symbolize-operands` implementation logic.
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index d124002..768a976 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1484,9 +1484,11 @@ collectLocalBranchTargets(ArrayRef<uint8_t> Bytes, MCInstrAnalysis *MIA, const MCSubtargetInfo *STI, uint64_t SectionAddr, uint64_t Start, uint64_t End, std::unordered_map<uint64_t, std::string> &Labels) { - // So far only supports PowerPC and X86. + // Supported by certain targets. const bool isPPC = STI->getTargetTriple().isPPC(); - if (!isPPC && !STI->getTargetTriple().isX86()) + const bool isX86 = STI->getTargetTriple().isX86(); + const bool isBPF = STI->getTargetTriple().isBPF(); + if (!isPPC && !isX86 && !isBPF) return; if (MIA) |