Skip to content

Commit 54c8902

Browse files
committed
[LangRef] Clarify support for multiple metadata attachments with same id
As discussed on D105251, currently the compiler does not support multiple metadata attachments on instructions having the same identifier, whereas it does for global objects. Note this in the Language Reference manual for clarity. See D105251 for discussions of history behind this divergence, and the complexities and possible approaches of adding this support to instructions in the future. Differential Revision: https://reviews.llvm.org/D106304
1 parent 51e62e5 commit 54c8902

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

llvm/docs/LangRef.rst

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5035,8 +5035,8 @@ occurs on.
50355035
Metadata
50365036
========
50375037

5038-
LLVM IR allows metadata to be attached to instructions in the program
5039-
that can convey extra information about the code to the optimizers and
5038+
LLVM IR allows metadata to be attached to instructions and global objects in the
5039+
program that can convey extra information about the code to the optimizers and
50405040
code generator. One example application of metadata is source-level
50415041
debug information. There are two metadata primitives: strings and nodes.
50425042

@@ -5096,6 +5096,9 @@ to the ``add`` instruction using the ``!dbg`` identifier:
50965096

50975097
%indvar.next = add i64 %indvar, 1, !dbg !21
50985098

5099+
Instructions may not have multiple metadata attachments with the same
5100+
identifier.
5101+
50995102
Metadata can also be attached to a function or a global variable. Here metadata
51005103
``!22`` is attached to the ``f1`` and ``f2`` functions, and the globals ``g1``
51015104
and ``g2`` using the ``!dbg`` identifier:
@@ -5110,6 +5113,9 @@ and ``g2`` using the ``!dbg`` identifier:
51105113
@g1 = global i32 0, !dbg !22
51115114
@g2 = external global i32, !dbg !22
51125115

5116+
Unlike instructions, global objects (functions and global variables) may have
5117+
multiple metadata attachments with the same identifier.
5118+
51135119
A transformation is required to drop any metadata attachment that it does not
51145120
know or know it can't preserve. Currently there is an exception for metadata
51155121
attachment to globals for ``!type`` and ``!absolute_symbol`` which can't be

0 commit comments

Comments
 (0)