Reapply r257105 "[Verifier] Check that debug values have proper size"
authorKeno Fischer <kfischer@college.harvard.edu>
Wed, 13 Jan 2016 00:31:44 +0000 (00:31 +0000)
committerKeno Fischer <kfischer@college.harvard.edu>
Wed, 13 Jan 2016 00:31:44 +0000 (00:31 +0000)
commit99220ce3fcf5ba196b6e9838c5717bcc9caa741d
treee08862670914e1f30c3199bc6b6df098a2110e74
parent913815ec023daa5a912c2685a76e155ed6c888e7
Reapply r257105 "[Verifier] Check that debug values have proper size"

The follow extra changes were made to test cases:

Manually making the variable be the actual type instead of a pointer
to avoid pointer-size differences in generic code:

    LLVM :: DebugInfo/Generic/2010-03-24-MemberFn.ll
    LLVM :: DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll
    LLVM :: DebugInfo/Generic/2010-05-03-DisableFramePtr.ll
    LLVM :: DebugInfo/Generic/varargs.ll

Delete sizing information from debug info for the same reason
(but the presence of the pointer was important to the test case):

    LLVM :: DebugInfo/Generic/restrict.ll
    LLVM :: DebugInfo/Generic/tu-composite.ll
    LLVM :: Linker/type-unique-type-array-a.ll
    LLVM :: Linker/type-unique-simple2.ll

Fixing an incorrect DW_OP_deref

    LLVM :: DebugInfo/Generic/2010-05-03-OriginDIE.ll

Fixing a missing DW_OP_deref

    LLVM :: DebugInfo/Generic/incorrect-variable-debugloc.ll

Additionally, clang should no longer complain during bootstrap should no
longer happen after r257534.

The original commit message was:
```
Summary:
Teach the Verifier to make sure that the storage size given to llvm.dbg.declare
or the value size given to llvm.dbg.value agree with what is declared in
DebugInfo. This is implicitly assumed in a number of passes (e.g. in SROA).
Additionally this catches a number of common mistakes, such as passing a
pointer when a value was intended or vice versa.

One complication comes from stack coloring which modifies the original IR when
it merges allocas in order to make sure that if AA falls back to the IR it gets
the correct result. However, given this new invariant, indiscriminately
replacing one alloca by a different (differently sized one) is no longer valid.
Fix this by just undefing out any use of the alloca in a dbg.declare in this
case.

Additionally, I had to fix a number of test cases. Of particular note:
- I regenerated dbg-changes-codegen-branch-folding.ll from the given source as
  it was affected by the bug fixed in r256077
- two-cus-from-same-file.ll was changed to avoid having a variable-typed debug
  variable as that would depend on the target, even though this test is
  supposed to be generic
- I had to manually declared size/align for reference type. See also the
  discussion for D14275/r253186.
- fpstack-debuginstr-kill.ll required changing `double` to `long double`
- most others were just a question of adding OP_deref
```

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257550 91177308-0d34-0410-b5e6-96231b3b80d8
38 files changed:
lib/CodeGen/StackColoring.cpp
lib/IR/Verifier.cpp
test/CodeGen/ARM/2010-08-04-StackVariable.ll
test/CodeGen/MIR/X86/invalid-metadata-node-type.mir
test/CodeGen/MIR/X86/stack-object-debug-info.mir
test/CodeGen/X86/2012-11-30-regpres-dbg.ll
test/CodeGen/X86/MachineSink-DbgValue.ll
test/CodeGen/X86/dbg-changes-codegen-branch-folding.ll
test/CodeGen/X86/fpstack-debuginstr-kill.ll
test/CodeGen/X86/misched-code-difference-with-debug.ll
test/DebugInfo/AArch64/frameindices.ll
test/DebugInfo/Generic/2010-03-24-MemberFn.ll
test/DebugInfo/Generic/2010-04-06-NestedFnDbgInfo.ll
test/DebugInfo/Generic/2010-05-03-DisableFramePtr.ll
test/DebugInfo/Generic/2010-05-03-OriginDIE.ll
test/DebugInfo/Generic/incorrect-variable-debugloc.ll
test/DebugInfo/Generic/incorrect-variable-debugloc1.ll
test/DebugInfo/Generic/restrict.ll
test/DebugInfo/Generic/tu-composite.ll
test/DebugInfo/Generic/two-cus-from-same-file.ll
test/DebugInfo/Generic/varargs.ll
test/DebugInfo/Mips/dsr-non-fixed-objects.ll
test/DebugInfo/X86/bbjoin.ll
test/DebugInfo/X86/dbg-value-dag-combine.ll
test/DebugInfo/X86/dbg-value-isel.ll
test/DebugInfo/X86/dbg-value-terminator.ll
test/DebugInfo/X86/elf-names.ll
test/DebugInfo/X86/nodebug_with_debug_loc.ll
test/DebugInfo/X86/nophysreg.ll
test/DebugInfo/X86/rvalue-ref.ll
test/DebugInfo/X86/sret.ll
test/Linker/Inputs/type-unique-simple2-a.ll
test/Linker/Inputs/type-unique-simple2-b.ll
test/Linker/type-unique-type-array-a.ll
test/Linker/type-unique-type-array-b.ll
test/Transforms/CodeGenPrepare/X86/catchpad-phi-cast.ll
test/Transforms/DeadStoreElimination/inst-limits.ll
test/Transforms/SLPVectorizer/X86/debug_info.ll