Skip to content

Commit 2b725ab

Browse files
[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
1 parent 7cdb27a commit 2b725ab

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();
@@ -367,6 +369,8 @@ class PseudoInstruction : public Instruction {
367369

368370
bool IsLoad() override;
369371

372+
bool IsBarrier() override;
373+
370374
bool IsAuthenticated() override;
371375

372376
void CalculateMnemonicOperandsAndComment(

lldb/source/Core/Disassembler.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1341,6 +1341,11 @@ bool PseudoInstruction::DoesBranch() {
13411341
return false;
13421342
}
13431343

1344+
bool PseudoInstruction::IsBarrier() {
1345+
// This is NOT a valid question for a pseudo instruction.
1346+
return false;
1347+
}
1348+
13441349
bool PseudoInstruction::HasDelaySlot() {
13451350
// This is NOT a valid question for a pseudo instruction.
13461351
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:
@@ -1432,6 +1440,11 @@ bool DisassemblerLLVMC::MCDisasmInstance::IsLoad(llvm::MCInst &mc_inst) const {
14321440
return m_instr_info_up->get(mc_inst.getOpcode()).mayLoad();
14331441
}
14341442

1443+
bool DisassemblerLLVMC::MCDisasmInstance::IsBarrier(
1444+
llvm::MCInst &mc_inst) const {
1445+
return m_instr_info_up->get(mc_inst.getOpcode()).isBarrier();
1446+
}
1447+
14351448
bool DisassemblerLLVMC::MCDisasmInstance::IsAuthenticated(
14361449
llvm::MCInst &mc_inst) const {
14371450
const auto &InstrDesc = m_instr_info_up->get(mc_inst.getOpcode());

0 commit comments

Comments
 (0)