diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5790,22 +5790,25 @@ Scalar type descriptors are represented as an ``MDNode`` s with two operands. The first operand is an ``MDString`` denoting the name of the -struct type. LLVM does not assign meaning to the value of this operand, it -only cares about it being an ``MDString``. The second operand is an -``MDNode`` which points to the parent for said scalar type descriptor, -which is either another scalar type descriptor or the TBAA root. Scalar -type descriptors can have an optional third argument, but that must be the -constant integer zero. +scalar type. The second operand is an ``MDNode`` which points to the parent +for said scalar type descriptor, which is either another scalar type +descriptor or the TBAA root. Scalar type descriptors can have an optional +third argument, but that must be the constant integer zero. Struct type descriptors are represented as ``MDNode`` s with an odd number of operands greater than 1. The first operand is an ``MDString`` denoting -the name of the struct type. Like in scalar type descriptors the actual -value of this name operand is irrelevant to LLVM. After the name operand, -the struct type descriptors have a sequence of alternating ``MDNode`` and -``ConstantInt`` operands. With N starting from 1, the 2N - 1 th operand, -an ``MDNode``, denotes a contained field, and the 2N th operand, a -``ConstantInt``, is the offset of the said contained field. The offsets -must be in non-decreasing order. +the name of the struct type. After the name operand, the struct type +descriptors have a sequence of alternating ``MDNode`` and ``ConstantInt`` +operands. With N starting from 1, the 2N - 1 th operand, an ``MDNode``, +denotes a contained field, and the 2N th operand, a ``ConstantInt``, is the +offset of the said contained field. The offsets must be in non-decreasing +order. + +The names in the first operand of a scalar or struct type description can be +chosen freely by the frontend. However, optimizations might use them as a +heuristics for better performance without affecting correctness. As an +example, ``"any pointer"`` and ``"vtable pointer"`` might be recognized and +used to select a different, but equivalent, code generation. Access tags are represented as ``MDNode`` s with either 3 or 4 operands. The first operand is an ``MDNode`` pointing to the node representing the