]> granicus.if.org Git - llvm/commit
[SROA] Really remove associated dbg.declare when removing dead alloca
authorMikael Holmen <mikael.holmen@ericsson.com>
Thu, 21 Sep 2017 11:14:27 +0000 (11:14 +0000)
committerMikael Holmen <mikael.holmen@ericsson.com>
Thu, 21 Sep 2017 11:14:27 +0000 (11:14 +0000)
commit4d4149da555cbb29f6fafb150caaf18ecea3a356
treefec5b8c635180876c3fd6d35b503e46ece84e476
parent119c880fd8c3e4c9b5bb088fe75aaf4e2a060257
[SROA] Really remove associated dbg.declare when removing dead alloca

Summary:
There already was code that tried to remove the dbg.declare, but that code
was placed after we had called
 I->replaceAllUsesWith(UndefValue::get(I->getType()));
on the alloca, so when we searched for the relevant dbg.declare, we
couldn't find it.

Now we do the search before we call RAUW so there is a chance to find it.

An existing testcase needed update due to this. Two dbg.declare with undef
were removed and then suddenly one of the two CHECKS failed.

Before this patch we got

  call void @llvm.dbg.declare(metadata i24* undef, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 24)), !dbg !15
  call void @llvm.dbg.declare(metadata %struct.prog_src_register* undef, metadata !14, metadata !DIExpression()), !dbg !15
  call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !15
  call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 24)), !dbg !15

and with it we get

  call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 0, 32)), !dbg !15
  call void @llvm.dbg.value(metadata i32 0, metadata !14, metadata !DIExpression(DW_OP_LLVM_fragment, 32, 24)), !dbg !15

However, the CHECKs in the testcase checked things in a silly order, so
they only passed since they found things in the first dbg.declare. Now
we changed the order of the checks and the test passes.

Reviewers: rnk

Reviewed By: rnk

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D37900

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@313875 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/Scalar/SROA.cpp
test/DebugInfo/X86/sroasplit-5.ll
test/DebugInfo/X86/sroasplit-dbg-declare.ll [new file with mode: 0644]