Index: llvm/docs/SourceLevelDebugging.rst =================================================================== --- llvm/docs/SourceLevelDebugging.rst +++ llvm/docs/SourceLevelDebugging.rst @@ -456,7 +456,7 @@ Sometimes perfectly preserving variable locations is not possible, often when a redundant calculation is optimized out. In such cases, a ``llvm.dbg.value`` -with operand ``undef`` should be used, to terminate earlier variable locations +with operand ``poison`` should be used, to terminate earlier variable locations and let the debugger present ``optimized out`` to the developer. Withholding these potentially stale variable values from the developer diminishes the amount of available debug information, but increases the reliability of the @@ -546,9 +546,26 @@ ret i32 %toret } +There are a few other dbg.value configurations that mean it terminates +dominating location definitions without adding a new location. The complete +list is: + +* Any location operand is ``poison`` (or ``undef``). +* Any location operand is an empty metadata tuple (``!{}``) - in practice this + will not occur in ``!DIArgList``s. +* There are no location operands (empty ``DIArgList``) and the ``DIExpression`` + is empty. + +This class of dbg.value that kills variable locations is called a "kill +dbg.value" or "kill location", and for legacy reasons the term "undef +dbg.value" may be used in existing code. The ``DbgVariableIntrinsic`` methods +``isKillLocation`` and ``setKillLocation`` should be used where possible rather +than inspecting location operands directly to check or set whether a dbg.value +is a kill location. + In general, if any dbg.value has its operand optimized out and cannot be -recovered, then an undef dbg.value is necessary to terminate earlier variable -locations. Additional undef dbg.values may be necessary when the debugger can +recovered, then a kill dbg.value is necessary to terminate earlier variable +locations. Additional kill dbg.values may be necessary when the debugger can observe re-ordering of assignments. How variable location metadata is transformed during CodeGen