[Assignment Tracking][SROA] Fix fragment when slice size equals variable size
authorOCHyams <orlando.hyams@sony.com>
Thu, 6 Apr 2023 13:23:19 +0000 (14:23 +0100)
committerOCHyams <orlando.hyams@sony.com>
Thu, 6 Apr 2023 14:29:18 +0000 (15:29 +0100)
commit086635d6b9f74ec5f4b7cedb2aee94f07c3b8fde
tree5fafe6fac1d61bdb87466a69947061013dc55f6e
parent0c049ea60a9f214911eef7901b94bd6343c04409
[Assignment Tracking][SROA] Fix fragment when slice size equals variable size

Correctly handle the case of splitting an alloca which backs contiguous
distinct variables, where a slice's size equals the size of a backed variable.

We need to ensure that we don't generate fragments expressions with fragments
of the same size as the variable as this is a verifier error.

Prior to this patch a fragment expression would be created in this
situation. e.g. splitting an alloca i64 with two adjacent 32-bit variables into
two 32-bit allocas, the new dbg.assign expressions would contain
(DW_OP_LLVM_fragment, 0, 32) and (DW_OP_LLVM_fragment, 32, 32) even though
those fragments cover each variable entirely.

Reviewed By: jmorse

Differential Revision: https://reviews.llvm.org/D147696
llvm/lib/Transforms/Scalar/SROA.cpp
llvm/test/DebugInfo/Generic/assignment-tracking/sroa/var-sized-fragment.ll [new file with mode: 0644]