diff options
author | Job Noorman <jnoorman@igalia.com> | 2023-10-20 06:36:12 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-20 06:36:12 +0000 |
commit | 95f924f30ae16be0d125646b9e4f1e33d4e5d08b (patch) | |
tree | 023bbfcb24b9d2fed222e572f7f3046b78a2b697 /llvm/tools/llvm-objdump/llvm-objdump.cpp | |
parent | 195f6236c7e67ba814cb1614917ff111ee1fdd29 (diff) | |
download | llvm-95f924f30ae16be0d125646b9e4f1e33d4e5d08b.zip llvm-95f924f30ae16be0d125646b9e4f1e33d4e5d08b.tar.gz llvm-95f924f30ae16be0d125646b9e4f1e33d4e5d08b.tar.bz2 |
[RISCV][MC] Implement evaluateBranch for auipc+jalr pairs (#65480)
This patch implements `MCInstrAnalysis` state in order to be able
analyze auipc+jalr pairs inside `evaluateBranch`.
This is implemented as follows:
- State: array of currently known GPR values;
- Whenever an auipc is detected in `updateState`, update the state value
of RD with the immediate;
- Whenever a jalr is detected in `evaluateBranch`, check if the state
holds a value for RS1 and use that to compute its target.
Note that this is similar to how binutils implements it and the output
of llvm-objdump should now mostly match the one of GNU objdump.
This patch also updates the relevant llvm-objdump patches and adds a new
one testing the output for interleaved auipc+jalr pairs.
Diffstat (limited to 'llvm/tools/llvm-objdump/llvm-objdump.cpp')
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index f02bd6a..a112c50 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1322,6 +1322,8 @@ collectLocalBranchTargets(ArrayRef<uint8_t> Bytes, MCInstrAnalysis *MIA, !(STI->getTargetTriple().isPPC() && Target == Index)) Labels[Target] = ("L" + Twine(LabelCount++)).str(); MIA->updateState(Inst, Index); + } else if (!Disassembled && MIA) { + MIA->resetState(); } Index += Size; } @@ -2194,6 +2196,8 @@ disassembleObject(ObjectFile &Obj, const ObjectFile &DbgObj, } DT->InstrAnalysis->updateState(Inst, SectionAddr + Index); + } else if (!Disassembled && DT->InstrAnalysis) { + DT->InstrAnalysis->resetState(); } } |