[Mlir-commits] [llvm] [mlir] [DebugInfo] Add symbolic branches to DIExpression (PR #210850)
Aman LaChapelle
llvmlistbot at llvm.org
Mon Jul 20 22:03:14 PDT 2026
================
@@ -470,6 +469,50 @@ Some opcodes do not influence the final DWARF expression directly, instead
encoding information logically belonging to the debug records which use
them.
```
+
+(symbolic-control-flow)=
+
+##### Symbolic Control Flow
+
+DWARF `DW_OP_bra` and `DW_OP_skip` have a two-byte offset in
+`[-32768, 32767]`, but we don't know that offset until we emit the expression,
+so we use three pseudo-ops with label IDs that CodeGen resolves during
+emission:
+
+- `DW_OP_LLVM_label, ID` marks a destination and emits no bytes.
+- `DW_OP_LLVM_bra, ID` branches to label `ID` when the value on top of the
+ expression stack is non-zero.
+- `DW_OP_LLVM_skip, ID` always branches to label `ID`.
+
+Label IDs are local to an expression:
+
+- Each ID can have at most one label, and every branch needs a matching label
+ in the same expression.
+- Labels don't need branches, and consecutive labels have the same byte
+ offset.
+- Branches can go forward, backward, to themselves, or form cycles.
+
+There are a few other restrictions:
----------------
bzcheeseman wrote:
could you clarify whose responsibility each of these restrictions are? It's not clear from the text as written.
https://github.com/llvm/llvm-project/pull/210850
More information about the Mlir-commits
mailing list