Skip to content

Commit dba9d76

Browse files
[lldb] Add DisassemblerLLVMC::IsBarrier API (llvm#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 llvm#169630 [lldb][NFC] Rename forward_branch_offset to branch_offset in UnwindAssemblyInstEmulation llvm#169631 [lldb] Add DisassemblerLLVMC::IsBarrier API llvm#169632 [lldb] Handle backwards branches in UnwindAssemblyInstEmulation llvm#169633 commit-id:bb5df4aa (cherry picked from commit 2b725ab)
1 parent 298e62f commit dba9d76

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

lldb/include/lldb/Core/Disassembler.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ class Instruction {
167167

168168
virtual bool IsLoad() = 0;
169169

170+
virtual bool IsBarrier() = 0;
171+
170172
virtual bool IsAuthenticated() = 0;
171173

172174
bool CanSetBreakpoint ();
@@ -368,6 +370,8 @@ class PseudoInstruction : public Instruction {
368370

369371
bool IsLoad() override;
370372

373+
bool IsBarrier() override;
374+
371375
bool IsAuthenticated() override;
372376

373377
void CalculateMnemonicOperandsAndComment(

lldb/source/Core/Disassembler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,6 +1201,11 @@ bool PseudoInstruction::DoesBranch() {
12011201
return false;
12021202
}
12031203

1204+
bool PseudoInstruction::IsBarrier() {
1205+
// This is NOT a valid question for a pseudo instruction.
1206+
return false;
1207+
}
1208+
12041209
bool PseudoInstruction::HasDelaySlot() {
12051210
// This is NOT a valid question for a pseudo instruction.
12061211
return false;

lldb/source/Plugins/Disassembler/LLVMC/DisassemblerLLVMC.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class DisassemblerLLVMC::MCDisasmInstance {
7070
bool HasDelaySlot(llvm::MCInst &mc_inst) const;
7171
bool IsCall(llvm::MCInst &mc_inst) const;
7272
bool IsLoad(llvm::MCInst &mc_inst) const;
73+
bool IsBarrier(llvm::MCInst &mc_inst) const;
7374
bool IsAuthenticated(llvm::MCInst &mc_inst) const;
7475

7576
private:
@@ -436,6 +437,11 @@ class InstructionLLVMC : public lldb_private::Instruction {
436437
return m_is_load;
437438
}
438439

440+
bool IsBarrier() override {
441+
VisitInstruction();
442+
return m_is_barrier;
443+
}
444+
439445
bool IsAuthenticated() override {
440446
VisitInstruction();
441447
return m_is_authenticated;
@@ -1195,6 +1201,7 @@ class InstructionLLVMC : public lldb_private::Instruction {
11951201
bool m_is_call = false;
11961202
bool m_is_load = false;
11971203
bool m_is_authenticated = false;
1204+
bool m_is_barrier = false;
11981205

11991206
void VisitInstruction() {
12001207
if (m_has_visited_instruction)
@@ -1227,6 +1234,7 @@ class InstructionLLVMC : public lldb_private::Instruction {
12271234
m_is_call = mc_disasm_ptr->IsCall(inst);
12281235
m_is_load = mc_disasm_ptr->IsLoad(inst);
12291236
m_is_authenticated = mc_disasm_ptr->IsAuthenticated(inst);
1237+
m_is_barrier = mc_disasm_ptr->IsBarrier(inst);
12301238
}
12311239

12321240
private:
@@ -1429,6 +1437,11 @@ bool DisassemblerLLVMC::MCDisasmInstance::IsLoad(llvm::MCInst &mc_inst) const {
14291437
return m_instr_info_up->get(mc_inst.getOpcode()).mayLoad();
14301438
}
14311439

1440+
bool DisassemblerLLVMC::MCDisasmInstance::IsBarrier(
1441+
llvm::MCInst &mc_inst) const {
1442+
return m_instr_info_up->get(mc_inst.getOpcode()).isBarrier();
1443+
}
1444+
14321445
bool DisassemblerLLVMC::MCDisasmInstance::IsAuthenticated(
14331446
llvm::MCInst &mc_inst) const {
14341447
const auto &InstrDesc = m_instr_info_up->get(mc_inst.getOpcode());

0 commit comments

Comments
 (0)