OSDN Git Service

DI: Make Subprogram definitions 'distinct'
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 26 Aug 2015 22:50:16 +0000 (22:50 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Wed, 26 Aug 2015 22:50:16 +0000 (22:50 +0000)
commit9f0965e28b2fb66194283aa9fbf53466d303857f
treeb9777729cec290598e6abe777e551f3039ff7b7a
parent08bd0b92116468b52776a55e1fb9dcd479c4a42d
DI: Make Subprogram definitions 'distinct'

Change `DIBuilder` always to produce 'distinct' nodes when creating
`DISubprogram` definitions.  I measured a ~5% memory improvement in the
link step (of ld64) when using `-flto -g`.

`DISubprogram`s are used in two ways in the debug info graph.

Some are definitions, point at actual functions, and can't really be
shared between compile units.  With full debug info, these point down at
their variables, forming uniquing cycles.  These uniquing cycles are
expensive to link between modules, since all unique nodes that reference
them transitively need to be duplicated (see commit message for r244181
for more details).

Others are declarations, primarily used for member functions in the type
hierarchy.  Definitions never show up there; instead, a definition
points at its corresponding declaration node.

I started by making all subprograms 'distinct'.  However, that was too
big a hammer: memory usage *increased* ~5% (net increase vs. this patch
of ~10%) because the 'distinct' declarations undermine LTO type
uniquing.  This is a targeted fix for the definitions (where uniquing is
an observable problem).

A couple of notes:

  - There's an accompanying commit to update IRGen testcases in clang.
  - ^ That's what I'm using to test this commit.
  - In a follow-up, I'll change the verifier to require 'distinct' on
    definitions and add an upgrade to `BitcodeReader`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@246098 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/DIBuilder.cpp