[Assignment Tracking] Fix mem2reg misidentifying unlinked stores
authorOCHyams <orlando.hyams@sony.com>
Wed, 22 Mar 2023 13:29:46 +0000 (13:29 +0000)
committerOCHyams <orlando.hyams@sony.com>
Wed, 22 Mar 2023 14:18:41 +0000 (14:18 +0000)
commitf2252726c40a77d83982932cfc647f459a4c5c69
tree8f3745ed894847248a58699eca51eb15a0c274f6
parenta17b71d17f853350dcd6c72ab141b196d7caec2a
[Assignment Tracking] Fix mem2reg misidentifying unlinked stores

updateForDeletedStore updates the assignment tracking debug info for a store
that is about to be deleted by mem2reg. For each variable backed by the target
alloca, if a dbg.assign exists it is kept (well - it's downgraded to a
dbg.value). A dbg.value is inserted if there's not a linked dbg.assign for a
variable which is backed by the target alloca. This patch fixes a bug whereby a
store with a linked dbg.assign that describes a fragment different to the one
linked to the alloca was not counted for the variable, leading to both keeping
the dbg.assign (downgrading it) and inserting a new dbg.value.

Reviewed By: StephenTozer

Differential Revision: https://reviews.llvm.org/D146299
llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp
llvm/test/DebugInfo/Generic/assignment-tracking/mem2reg/store-to-part-of-alloca.ll [new file with mode: 0644]
llvm/test/DebugInfo/Generic/assignment-tracking/sroa/vec-2.ll