llvm.org GIT mirror llvm / c9c6914
[DeadStoreElimination] Salvage debug info from dead insts According to `llvm-dwarfdump --statistics` this salvages 43 additional unique source variables in a stage2 build of clang. It increases the size of the .debug_loc section by 0.002% (or 2864 bytes). Differential Revision: https://reviews.llvm.org/D43220 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@325035 91177308-0d34-0410-b5e6-96231b3b80d8 Vedant Kumar 1 year, 7 months ago
2 changed file(s) with 43 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
114114 Instruction *DeadInst = NowDeadInsts.pop_back_val();
115115 ++NumFastOther;
116116
117 // Try to preserve debug information attached to the dead instruction.
118 salvageDebugInfo(*DeadInst);
119
117120 // This instruction is dead, zap it, in stages. Start by removing it from
118121 // MemDep, which needs to know the operands and needs it to be in the
119122 // function.
0 ; RUN: opt < %s -debugify -basicaa -dse -S | FileCheck %s
1
2 target datalayout = "E-p:64:64:64-a0:0:8-f32:32:32-f64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-v64:64:64-v128:128:128"
3
4 declare noalias i8* @malloc(i32)
5
6 declare void @test_f()
7
8 define i32* @test_salvage() {
9 ; CHECK-LABEL: @test_salvage()
10 ; CHECK-NEXT: malloc
11 ; CHECK-NEXT: bitcast
12 ; CHECK-NEXT: call void @test_f()
13 ; CHECK-NEXT: store i32 0, i32* %P
14
15 ; Check that all four original local variables have their values preserved.
16 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i8* %p, metadata !8, metadata !DIExpression()), !dbg !14
17 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !10, metadata !DIExpression()), !dbg !15
18 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !11, metadata !DIExpression(DW_OP_deref)), !dbg !18
19 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32* %P, metadata !13, metadata !DIExpression(DW_OP_deref, DW_OP_plus_uconst, 1, DW_OP_stack_value)), !dbg !19
20 %p = tail call i8* @malloc(i32 4)
21 %P = bitcast i8* %p to i32*
22 %DEAD = load i32, i32* %P
23 %DEAD2 = add i32 %DEAD, 1
24 store i32 %DEAD2, i32* %P
25 call void @test_f()
26 store i32 0, i32* %P
27 ret i32* %P
28 }
29
30 ; CHECK: !8 = !DILocalVariable(name: "1", scope: !5, file: !1, line: 1, type: !9)
31 ; CHECK: !10 = !DILocalVariable(name: "2", scope: !5, file: !1, line: 2, type: !9)
32 ; CHECK: !11 = !DILocalVariable(name: "3", scope: !5, file: !1, line: 3, type: !12)
33 ; CHECK: !13 = !DILocalVariable(name: "4", scope: !5, file: !1, line: 4, type: !12)
34 ; CHECK-DAG: !14 = !DILocation(line: 1, column: 1, scope: !5)
35 ; CHECK-DAG: !15 = !DILocation(line: 2, column: 1, scope: !5)
36 ; CHECK-DAG: !18 = !DILocation(line: 3, column: 1, scope: !5)
37 ; CHECK-DAG: !19 = !DILocation(line: 4, column: 1, scope: !5)
38 ; CHECK-DAG: !16 = !DILocation(line: 6, column: 1, scope: !5)
39 ; CHECK-DAG: !17 = !DILocation(line: 7, column: 1, scope: !5)