1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

docs: Document function-attached metadata and IR changes from r252219.

llvm-svn: 252268
This commit is contained in:
Peter Collingbourne 2015-11-06 02:41:02 +00:00
parent 3a93db45ff
commit a9e78321e1
2 changed files with 37 additions and 22 deletions

View File

@ -640,6 +640,7 @@ an optional :ref:`comdat <langref_comdats>`,
an optional :ref:`garbage collector name <gc>`, an optional :ref:`prefix <prefixdata>`,
an optional :ref:`prologue <prologuedata>`,
an optional :ref:`personality <personalityfn>`,
an optional list of attached :ref:`metadata <metadata>`,
an opening curly brace, a list of basic blocks, and a closing curly brace.
LLVM function declarations consist of the "``declare``" keyword, an
@ -688,7 +689,7 @@ Syntax::
<ResultType> @<FunctionName> ([argument list])
[unnamed_addr] [fn Attrs] [section "name"] [comdat [($name)]]
[align N] [gc] [prefix Constant] [prologue Constant]
[personality Constant] { ... }
[personality Constant] (!name !N)* { ... }
The argument list is a comma separated sequence of arguments where each
argument is of the following form:
@ -3624,13 +3625,22 @@ function is using two metadata arguments:
call void @llvm.dbg.value(metadata !24, i64 0, metadata !25)
Metadata can be attached with an instruction. Here metadata ``!21`` is
attached to the ``add`` instruction using the ``!dbg`` identifier:
Metadata can be attached to an instruction. Here metadata ``!21`` is attached
to the ``add`` instruction using the ``!dbg`` identifier:
.. code-block:: llvm
%indvar.next = add i64 %indvar, 1, !dbg !21
Metadata can also be attached to a function definition. Here metadata ``!22``
is attached to the ``foo`` function using the ``!dbg`` identifier:
.. code-block:: llvm
define void @foo() !dbg !22 {
ret void
}
More information about specific metadata nodes recognized by the
optimizers and code generator is found below.
@ -3901,20 +3911,26 @@ All global variables should be referenced by the `globals:` field of a
DISubprogram
""""""""""""
``DISubprogram`` nodes represent functions from the source language. The
``variables:`` field points at :ref:`variables <DILocalVariable>` that must be
retained, even if their IR counterparts are optimized out of the IR. The
``type:`` field must point at an :ref:`DISubroutineType`.
``DISubprogram`` nodes represent functions from the source language. A
``DISubprogram`` may be attached to a function definition using ``!dbg``
metadata. The ``variables:`` field points at :ref:`variables <DILocalVariable>`
that must be retained, even if their IR counterparts are optimized out of
the IR. The ``type:`` field must point at an :ref:`DISubroutineType`.
.. code-block:: llvm
!0 = !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
file: !2, line: 7, type: !3, isLocal: true,
isDefinition: false, scopeLine: 8, containingType: !4,
virtuality: DW_VIRTUALITY_pure_virtual, virtualIndex: 10,
flags: DIFlagPrototyped, isOptimized: true,
function: void ()* @_Z3foov,
templateParams: !5, declaration: !6, variables: !7)
define void @_Z3foov() !dbg !0 {
...
}
!0 = distinct !DISubprogram(name: "foo", linkageName: "_Zfoov", scope: !1,
file: !2, line: 7, type: !3, isLocal: true,
isDefinition: false, scopeLine: 8,
containingType: !4,
virtuality: DW_VIRTUALITY_pure_virtual,
virtualIndex: 10, flags: DIFlagPrototyped,
isOptimized: true, templateParams: !5,
declaration: !6, variables: !7)
.. _DILexicalBlock:

View File

@ -231,7 +231,7 @@ Compiled to LLVM, this function would be represented like this:
.. code-block:: llvm
; Function Attrs: nounwind ssp uwtable
define void @foo() #0 {
define void @foo() #0 !dbg !4 {
entry:
%X = alloca i32, align 4
%Y = alloca i32, align 4
@ -263,7 +263,7 @@ Compiled to LLVM, this function would be represented like this:
!1 = !DIFile(filename: "/dev/stdin", directory: "/Users/dexonsmith/data/llvm/debug-info")
!2 = !{}
!3 = !{!4}
!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, function: void ()* @foo, variables: !2)
!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, variables: !2)
!5 = !DISubroutineType(types: !6)
!6 = !{null}
!7 = !{i32 2, !"Dwarf Version", i32 2}
@ -304,10 +304,9 @@ scope information for the variable ``X``.
.. code-block:: llvm
!14 = !DILocation(line: 2, column: 9, scope: !4)
!4 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5,
isLocal: false, isDefinition: true, scopeLine: 1,
isOptimized: false, function: void ()* @foo,
variables: !2)
!4 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !5,
isLocal: false, isDefinition: true, scopeLine: 1,
isOptimized: false, variables: !2)
Here ``!14`` is metadata providing `location information
<LangRef.html#dilocation>`_. In this example, scope is encoded by ``!4``, a
@ -463,12 +462,12 @@ a C/C++ front-end would generate the following descriptors:
!4 = !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !5,
isLocal: false, isDefinition: true, scopeLine: 1,
flags: DIFlagPrototyped, isOptimized: false,
function: i32 (i32, i8**)* @main, variables: !2)
variables: !2)
;;
;; Define the subprogram itself.
;;
define i32 @main(i32 %argc, i8** %argv) {
define i32 @main(i32 %argc, i8** %argv) !dbg !4 {
...
}