Verifier: Check that inlined-at locations agree
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 3 Apr 2015 16:54:30 +0000 (16:54 +0000)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 3 Apr 2015 16:54:30 +0000 (16:54 +0000)
commitb0d0a65e1d5635ae53a09bc6cd9691c817fefe61
treee5acf722f4c6a0ba5b1ea035731d0e880b488f7d
parentf58fa53c99ae4a7b5613f4d045dc1bc690381542
Verifier: Check that inlined-at locations agree

Check that the `MDLocalVariable::getInlinedAt()` in a debug info
intrinsic's variable always matches the `MDLocation::getInlinedAt()` of
its `!dbg` attachment.

The goal here is to get rid of `MDLocalVariable::getInlinedAt()`
entirely (PR22778), since it's expensive and unnecessary, but I'll let
this verifier check bake for a while (a week maybe?) first.  I've
updated the testcases that had the wrong value for `inlinedAt:`.

This checks that things are sane in the IR, but currently things go out
of whack in a few places in the backend.  I'll follow shortly with
assertions in the backend (with code fixes).

If you have out-of-tree testcases that just started failing, here's how
I updated these ones:

 1. The verifier check gives you the basic block, function, instruction,
    and relevant metadata arguments (metadata numbering doesn't
    necessarily match the source file, unfortunately).
 2. Look at the `@llvm.dbg.*()` instruction, and compare the
    `inlinedAt:` fields of the variable argument (second `metadata`
    argument) and the `!dbg` attachment.
 3. Figure out based on the variable `scope:` chain and the functions in
    the file whether the variable has been inlined (and into what), so
    you can determine which `inlinedAt:` is actually correct.  In all of
    the in-tree testcases, the `!MDLocation()` was correct and the
    `!MDLocalVariable()` was wrong, but YMMV.
 4. Duplicate the metadata that you're going to change, and add/drop the
    `inlinedAt:` field from one of them.  Be careful that the other
    references to the same metadata node point at the correct one.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234021 91177308-0d34-0410-b5e6-96231b3b80d8
15 files changed:
lib/IR/Verifier.cpp
test/CodeGen/ARM/debug-info-d16-reg.ll
test/CodeGen/ARM/debug-info-s16-reg.ll
test/DebugInfo/2010-05-03-OriginDIE.ll
test/DebugInfo/2010-06-29-InlinedFnLocalVar.ll
test/DebugInfo/Mips/InlinedFnLocalVar.ll
test/DebugInfo/PR20038.ll
test/DebugInfo/X86/InlinedFnLocalVar.ll
test/DebugInfo/X86/dbg-value-inlined-parameter.ll
test/DebugInfo/X86/inline-member-function.ll
test/DebugInfo/X86/inline-seldag-test.ll
test/DebugInfo/cross-cu-inlining.ll
test/DebugInfo/inline-scopes.ll
test/DebugInfo/namespace_inline_function_definition.ll
test/Transforms/Mem2Reg/ConvertDebugInfo2.ll