[DebugInfo] Improve dbg preservation in LSR.
authorMarkus Lavin <markus.lavin@ericsson.com>
Mon, 5 Oct 2020 07:27:30 +0000 (09:27 +0200)
committerMarkus Lavin <markus.lavin@ericsson.com>
Mon, 5 Oct 2020 07:55:16 +0000 (09:55 +0200)
commita3caf7f6102dc863425f9714b099af58397f0cd2
tree9b96e1cc4691da3904cc0793a097991e18e7e233
parentcf4aa68388025a731236bc6dbe113ffdfe14c6c2
[DebugInfo] Improve dbg preservation in LSR.

Use SCEV to salvage additional @llvm.dbg.value that have turned into
referencing undef after transformation (and traditional
salvageDebugInfo). Before transformation compute SCEV for each
@llvm.dbg.value in the loop body and store it (along side its current
DIExpression). After transformation update those @llvm.dbg.value now
referencing undef by comparing its stored SCEV to the SCEV of the
current loop-header PHI-nodes. Allow match with offset by inserting
compensation code in the DIExpression.

Fixes : PR38815

Differential Revision: https://reviews.llvm.org/D87494
llvm/include/llvm/Analysis/ScalarEvolution.h
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/test/DebugInfo/COFF/fpo-shrink-wrap.ll
llvm/test/Transforms/LoopStrengthReduce/dbg-preserve-0.ll [new file with mode: 0644]