[DebugInfo][SROA] Correct debug info for global variables in case of SROA
authorAlok Kumar Sharma <AlokKumar.Sharma@amd.com>
Wed, 9 Mar 2022 19:11:30 +0000 (00:41 +0530)
committerAlok Kumar Sharma <AlokKumar.Sharma@amd.com>
Wed, 9 Mar 2022 19:11:30 +0000 (00:41 +0530)
commit94823500a7288a61c6d68becf2cc82e853a80e52
tree46e83db73030ffb80e127467359813b9d3fc702d
parentc3a7627cacc6cbe2301a253daeb3e6953e5e0d1d
[DebugInfo][SROA] Correct debug info for global variables in case of SROA

The existing handling produced crash for test case (attached with patch).
Now the function transferSRADebugInfo is modified to
  - Ignore the current variable if it starts after the current Fragment.
  - Ignore the current variable if it ends before the current Fragment.
  - Generate (!DIExpression()) if current variable completely fits the
    current Fragment.
  - Otherwise (as earlier), generate the DW_OP_LLVM_fragment in IR if current
    Fragment partially defines current variable.

Reviewed By: aprantl

Differential Revision: https://reviews.llvm.org/D121107
llvm/lib/Transforms/IPO/GlobalOpt.cpp
llvm/test/DebugInfo/X86/global-sra-struct-fit-segment.ll [new file with mode: 0644]