[llvm] [BPF] Remove 'may_goto 0' instructions (PR #123482)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 20 11:47:35 PST 2025
eddyz87 wrote:
Also, I'm not sure there is a good hook to attach to. When using gdb to break and see where assembler is called to parse the inline assembly, it looks like parsed instruction is written directly to the output stream:
```Breakpoint 1, (anonymous namespace)::BPFAsmParser::matchAndEmitInstruction (this=0x350df0, IDLoc=..., Opcode=<optimized out>, Operands=..., Out=..., ErrorInfo=@0x7fffffff1ca0: 0, MatchingInlineAsm=<optimized out>)
at /home/eddy/work/llvm-project/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp:309
309 MCInst Inst;
(gdb) bt
#0 (anonymous namespace)::BPFAsmParser::matchAndEmitInstruction (this=0x350df0, IDLoc=..., Opcode=<optimized out>, Operands=..., Out=..., ErrorInfo=@0x7fffffff1ca0: 0, MatchingInlineAsm=<optimized out>)
at /home/eddy/work/llvm-project/llvm/lib/Target/BPF/AsmParser/BPFAsmParser.cpp:309
#1 0x00007ffff71ba292 in (anonymous namespace)::AsmParser::parseAndMatchAndEmitTargetInstruction (this=this at entry=0x290af0, Info=..., IDVal=..., ID=..., IDLoc=...) at /home/eddy/work/llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:2390
#2 0x00007ffff71ade4c in (anonymous namespace)::AsmParser::parseStatement (this=0x290af0, Info=..., SI=0x0) at /home/eddy/work/llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:2323
#3 0x00007ffff71a78d1 in (anonymous namespace)::AsmParser::Run (this=0x290af0, NoInitialTextSection=<optimized out>, NoFinalize=true) at /home/eddy/work/llvm-project/llvm/lib/MC/MCParser/AsmParser.cpp:1005
#4 0x00007ffff4570327 in llvm::AsmPrinter::emitInlineAsm (this=this at entry=0x373770, Str=..., STI=..., MCOptions=..., LocMDNode=LocMDNode at entry=0x30cf58, Dialect=llvm::InlineAsm::AD_ATT)
at /home/eddy/work/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp:129
#5 0x00007ffff4571560 in llvm::AsmPrinter::emitInlineAsm (this=0x373770, MI=0x3847a8) at /home/eddy/work/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinterInlineAsm.cpp:418
#6 0x00007ffff45593a7 in llvm::AsmPrinter::emitFunctionBody (this=0x373770) at /home/eddy/work/llvm-project/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1879
#7 0x00007ffff7f6cc15 in llvm::AsmPrinter::runOnMachineFunction (this=0x373770, MF=...) at /home/eddy/work/llvm-project/llvm/include/llvm/CodeGen/AsmPrinter.h:389
```
The parsing is done late in the pipeline and it's result is written directly either to object stream or to text output. So the only place seem to be `BPFAsmParser::matchAndEmitInstruction()` where some post-processing could be done.
https://github.com/llvm/llvm-project/pull/123482
More information about the llvm-commits
mailing list