[LLVMbugs] [Bug 23340] New: Support metadata attachments on functions

bugzilla-daemon at llvm.org bugzilla-daemon at llvm.org
Fri Apr 24 13:10:28 PDT 2015


https://llvm.org/bugs/show_bug.cgi?id=23340

            Bug ID: 23340
           Summary: Support metadata attachments on functions
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: All
            Status: ASSIGNED
          Severity: normal
          Priority: P
         Component: Core LLVM classes
          Assignee: unassignedbugs at nondot.org
          Reporter: dexonsmith at apple.com
                CC: dblaikie at gmail.com, dnovillo at google.com,
                    llvmbugs at cs.uiuc.edu
    Classification: Unclassified

`Function` definitions should support `MDNode` attachments, with a
similar syntax to instructions:

    define void @foo() nounwind !attach !0 {
      unreachable
    }
    !0 = !{}

Attachments wouldn't be allowed on declarations, just definitions.

There are two open problems this can help with:

 1. For PGO, we need somewhere to attach the function entry count.
    Attaching to the function definition is a simple solution.

        define void @foo() !prof !0 {
          unreachable
        }
        !0 = !{i32 987}

 2. In debug info, we repeatedly build up a map from `Function` to the
    canonical `MDSubrogram` for it.  Keeping this mapping accurate takes
    subtle logic in `lib/Linker` (see PR21910/PR22792) and it's
    expensive to compute and maintain.  Attaching it directly to the
    `Function` designs away the problem.

        define void @foo() !dbg !0 {
          unreachable
        }
        !0 = !MDSubprogram(name: "foo", function: void ()* @foo)

(For clarity, the scope of this PR is adding the IR infrastructure, not solving
either of those two problems.)

Discussion on the list was here:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-April/084483.html
http://lists.cs.uiuc.edu/pipermail/llvmdev/2015-April/084485.html

For now, I'm just going to put everything in the `LLVMContext`: same approach
as `Instruction`, but without the optimization for `!dbg`.  If a heap profile
tells us we should special-case `!dbg` we can add that logic later.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20150424/bb87eeb4/attachment.html>


More information about the llvm-bugs mailing list