[llvm] [DebugInfo] Keep validating after register and entry-value ops (PR #214057)

Adrian Prantl via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 08:07:57 PDT 2026


================
@@ -4274,10 +4274,13 @@ TEST_F(DIExpressionTest, isValid) {
   EXPECT_VALID(dwarf::DW_OP_LLVM_fragment, 3, 7);
   EXPECT_VALID(dwarf::DW_OP_plus_uconst, 6, dwarf::DW_OP_deref);
   EXPECT_VALID(dwarf::DW_OP_deref, dwarf::DW_OP_plus_uconst, 6);
+  EXPECT_VALID(dwarf::DW_OP_reg0, dwarf::DW_OP_deref);
----------------
adrian-prantl wrote:

In LLVM metadata we're using DWARF operations out of convenience, so we don't need to go through the effort of defining the semantics for yet another representation. We could potentially simplify code in AsmPrinter by canonicalizing DW_OP_reg0 to DW_OP_breg0 0 or DW_OP_reg0 4 to DW_OP_reg 0 DW_OP_plus_uconst 4 DW_OP_deref in DIExpression::foldConstantMath(), or keep both for a smaller encoding.

Using the more expressive DWARF 6 semantics in DIExpression and lowering it to the appropriate DWARF 2-5 location descriptions in AsmPrinter when needed is certainly the right direction for the future.

https://github.com/llvm/llvm-project/pull/214057


More information about the llvm-commits mailing list