From: Adrian Prantl Date: Wed, 22 Mar 2017 18:01:01 +0000 (+0000) Subject: Document the status quo of DIExpression semantics in LangRef.rst X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fbf2dadfa544489652c4a993cc48d8910f017ecd;p=llvm Document the status quo of DIExpression semantics in LangRef.rst git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298528 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/LangRef.rst b/docs/LangRef.rst index 039ad2214a9..e7a6f6bd5de 100644 --- a/docs/LangRef.rst +++ b/docs/LangRef.rst @@ -4366,29 +4366,42 @@ parameter, and it will be included in the ``variables:`` field of its DIExpression """""""""""" -``DIExpression`` nodes represent DWARF expression sequences. They are used in -:ref:`debug intrinsics` (such as ``llvm.dbg.declare``) to -describe how the referenced LLVM variable relates to the source language -variable. +``DIExpression`` nodes represent expressions that are inspired by the DWARF +expression language. They are used in :ref:`debug intrinsics` +(such as ``llvm.dbg.declare`` and ``llvm.dbg.value``) to describe how the +referenced LLVM variable relates to the source language variable. The current supported vocabulary is limited: - ``DW_OP_deref`` dereferences the working expression. - ``DW_OP_plus, 93`` adds ``93`` to the working expression. -- ``DW_OP_bit_piece, 16, 8`` specifies the offset and size (``16`` and ``8`` - here, respectively) of the variable piece from the working expression. +- ``DW_OP_LLVM_fragment, 16, 8`` specifies the offset and size (``16`` and ``8`` + here, respectively) of the variable fragment from the working expression. Note + that contrary to DW_OP_bit_piece, the offset is describing the the location + within the described source variable. - ``DW_OP_swap`` swaps top two stack entries. - ``DW_OP_xderef`` provides extended dereference mechanism. The entry at the top of the stack is treated as an address. The second stack entry is treated as an address space identifier. +- ``DW_OP_stack_value`` marks a constant value. + +DIExpression nodes that contain a ``DW_OP_stack_value`` operator are standalone +location descriptions that describe constant values. This form is used to +describe global constants that have been optimized away. All other expressions +are modifiers to another location: A debug intrinsic ties a location and a +DIExpression together. Contrary to DWARF expressions, a DIExpression always +describes the *value* of a source variable and never its *address*. In DWARF +terminology, a DIExpression can always be considered an implicit location +description regardless whether it contains a ``DW_OP_stack_value`` or not. .. code-block:: text !0 = !DIExpression(DW_OP_deref) !1 = !DIExpression(DW_OP_plus, 3) !2 = !DIExpression(DW_OP_bit_piece, 3, 7) - !3 = !DIExpression(DW_OP_deref, DW_OP_plus, 3, DW_OP_bit_piece, 3, 7) + !3 = !DIExpression(DW_OP_deref, DW_OP_plus, 3, DW_OP_LLVM_fragment, 3, 7) !4 = !DIExpression(DW_OP_constu, 2, DW_OP_swap, DW_OP_xderef) + !5 = !DIExpression(DW_OP_constu, 42, DW_OP_stack_value) DIObjCProperty """"""""""""""