[Verifier] Check that debug values have proper size
authorKeno Fischer <kfischer@college.harvard.edu>
Thu, 7 Jan 2016 22:18:37 +0000 (22:18 +0000)
committerKeno Fischer <kfischer@college.harvard.edu>
Thu, 7 Jan 2016 22:18:37 +0000 (22:18 +0000)
commit97515eb97bc5a3b075fc4d452c330ac7405cf815
tree2ba299cde4a0faae4dabd65e4a1be482e08d5b34
parentb60a342483e1ec9f1da9419f252f23aae8571843
[Verifier] Check that debug values have proper size

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

Reviewers: aprantl
Differential Revision: http://reviews.llvm.org/D14276

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257105 91177308-0d34-0410-b5e6-96231b3b80d8
27 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-05-03-OriginDIE.ll
test/DebugInfo/Generic/incorrect-variable-debugloc1.ll
test/DebugInfo/Generic/two-cus-from-same-file.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/Transforms/CodeGenPrepare/X86/catchpad-phi-cast.ll
test/Transforms/DeadStoreElimination/inst-limits.ll
test/Transforms/SLPVectorizer/X86/debug_info.ll