[lldb] Add DisassemblerLLVMC::IsBarrier API (#169632)

This will allow the instruction emulation unwinder to reason about
instructions that prevent the subsequent instruction from executing.

Part of a sequence of PRs:
[lldb][NFCI] Rewrite UnwindAssemblyInstEmulation in terms of a CFG visit
#169630
[lldb][NFC] Rename forward_branch_offset to branch_offset in
UnwindAssemblyInstEmulation #169631
[lldb] Add DisassemblerLLVMC::IsBarrier API #169632
[lldb] Handle backwards branches in UnwindAssemblyInstEmulation #169633

commit-id:bb5df4aa
This commit is contained in:
Felipe de Azevedo Piovezan
2025-12-03 09:08:05 +00:00
committed by GitHub
parent 7cdb27a4b3
commit 2b725ab8bf
3 changed files with 22 additions and 0 deletions

View File

@@ -167,6 +167,8 @@ public:
virtual bool IsLoad() = 0;
virtual bool IsBarrier() = 0;
virtual bool IsAuthenticated() = 0;
bool CanSetBreakpoint();
@@ -367,6 +369,8 @@ public:
bool IsLoad() override;
bool IsBarrier() override;
bool IsAuthenticated() override;
void CalculateMnemonicOperandsAndComment(

View File

@@ -1341,6 +1341,11 @@ bool PseudoInstruction::DoesBranch() {
return false;
}
bool PseudoInstruction::IsBarrier() {
// This is NOT a valid question for a pseudo instruction.
return false;
}
bool PseudoInstruction::HasDelaySlot() {
// This is NOT a valid question for a pseudo instruction.
return false;

View File

@@ -70,6 +70,7 @@ public:
bool HasDelaySlot(llvm::MCInst &mc_inst) const;
bool IsCall(llvm::MCInst &mc_inst) const;
bool IsLoad(llvm::MCInst &mc_inst) const;
bool IsBarrier(llvm::MCInst &mc_inst) const;
bool IsAuthenticated(llvm::MCInst &mc_inst) const;
private:
@@ -436,6 +437,11 @@ public:
return m_is_load;
}
bool IsBarrier() override {
VisitInstruction();
return m_is_barrier;
}
bool IsAuthenticated() override {
VisitInstruction();
return m_is_authenticated;
@@ -1195,6 +1201,7 @@ protected:
bool m_is_call = false;
bool m_is_load = false;
bool m_is_authenticated = false;
bool m_is_barrier = false;
void VisitInstruction() {
if (m_has_visited_instruction)
@@ -1227,6 +1234,7 @@ protected:
m_is_call = mc_disasm_ptr->IsCall(inst);
m_is_load = mc_disasm_ptr->IsLoad(inst);
m_is_authenticated = mc_disasm_ptr->IsAuthenticated(inst);
m_is_barrier = mc_disasm_ptr->IsBarrier(inst);
}
private:
@@ -1432,6 +1440,11 @@ bool DisassemblerLLVMC::MCDisasmInstance::IsLoad(llvm::MCInst &mc_inst) const {
return m_instr_info_up->get(mc_inst.getOpcode()).mayLoad();
}
bool DisassemblerLLVMC::MCDisasmInstance::IsBarrier(
llvm::MCInst &mc_inst) const {
return m_instr_info_up->get(mc_inst.getOpcode()).isBarrier();
}
bool DisassemblerLLVMC::MCDisasmInstance::IsAuthenticated(
llvm::MCInst &mc_inst) const {
const auto &InstrDesc = m_instr_info_up->get(mc_inst.getOpcode());