From 54c8902f02361114f9485f6de907d71623d6a50c Mon Sep 17 00:00:00 2001 From: Teresa Johnson Date: Mon, 19 Jul 2021 12:35:45 -0700 Subject: [PATCH] [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 --- llvm/docs/LangRef.rst | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst index 7dd60be..d5303b5 100644 --- a/llvm/docs/LangRef.rst +++ b/llvm/docs/LangRef.rst @@ -5035,8 +5035,8 @@ occurs on. Metadata ======== -LLVM IR allows metadata to be attached to instructions in the program -that can convey extra information about the code to the optimizers and +LLVM IR allows metadata to be attached to instructions and global objects in the +program that can convey extra information about the code to the optimizers and code generator. One example application of metadata is source-level debug information. There are two metadata primitives: strings and nodes. @@ -5096,6 +5096,9 @@ to the ``add`` instruction using the ``!dbg`` identifier: %indvar.next = add i64 %indvar, 1, !dbg !21 +Instructions may not have multiple metadata attachments with the same +identifier. + Metadata can also be attached to a function or a global variable. Here metadata ``!22`` is attached to the ``f1`` and ``f2`` functions, and the globals ``g1`` and ``g2`` using the ``!dbg`` identifier: @@ -5110,6 +5113,9 @@ and ``g2`` using the ``!dbg`` identifier: @g1 = global i32 0, !dbg !22 @g2 = external global i32, !dbg !22 +Unlike instructions, global objects (functions and global variables) may have +multiple metadata attachments with the same identifier. + A transformation is required to drop any metadata attachment that it does not know or know it can't preserve. Currently there is an exception for metadata attachment to globals for ``!type`` and ``!absolute_symbol`` which can't be -- 2.7.4