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 in 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. My proposed fix is to just undef 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 D14186
- 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 types (c.f. D14275)
- fpstack-debuginstr-kill.ll required changing double to long double
- most others were just a question of adding OP_deref
verifyDIExpression for consistency?