HomePhabricator

[mem2reg] Remove dbg.values describing contents of dead allocas

Authored by Orlando on Oct 22 2020, 9:44 PM.

Description

[mem2reg] Remove dbg.values describing contents of dead allocas

This patch copies @vsk's fix to instcombine from D85555 over to mem2reg. The
motivation and rationale are exactly the same: When mem2reg removes an alloca,
it erases the dbg.{addr,declare} instructions which refer to the alloca. It
would be better to instead remove all debug intrinsics which describe the
contents of the dead alloca, namely all dbg.value(<dead alloca>, ...,
DW_OP_deref)'s.

As far as I can tell, prior to D80264 these dbg.value+derefs would have been
silently dropped instead of being made undef, so we're just returning to
previous behaviour with these patches.

Testing:
llvm-lit llvm/test and ninja check-clang gave no unexpected failures. Added
3 tests, each of which covers a dbg.value deletion path in mem2reg:

mem2reg-promote-alloca-1.ll
mem2reg-promote-alloca-2.ll
mem2reg-promote-alloca-3.ll

The first is based on the dexter test inlining.c from D89543. This patch also
improves the debugging experience for loop.c from D89543, which suffers
similarly after arg promotion instead of inlining.

Details

Committed
OrlandoOct 22 2020, 9:46 PM
Parents
rG342040bf0074: [lld][ELF][test] Add additional test coverage for LTO
Branches
Unknown
Tags
Unknown