llvm.org GIT mirror llvm / 74ae23a
Do not count debug instructions when counting number of uses to reorder frame objects. Summary: The code generation should be independent of the debug info. Reviewers: zansari, davidxl, mkuper, majnemer Subscribers: majnemer, llvm-commits Differential Revision: http://reviews.llvm.org/D21911 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274357 91177308-0d34-0410-b5e6-96231b3b80d8 Dehao Chen 3 years ago
3 changed file(s) with 138 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
28692869 // Count the number of uses for each object.
28702870 for (auto &MBB : MF) {
28712871 for (auto &MI : MBB) {
2872 if (MI.isDebugValue())
2873 continue;
28722874 for (const MachineOperand &MO : MI.operands()) {
28732875 // Check to see if it's a local stack symbol.
28742876 if (!MO.isFI())
0 ; RUN: llc -march=x86 -disable-debug-info-print < %s | FileCheck %s
1 ; RUN: opt -strip -S < %s | llc -march=x86 -disable-debug-info-print | FileCheck %s
2
3 ; This test checks if the code is generated correctly with and without debug info.
4
5 ; This LL file was generated by running 'clang -g -gcodeview' on the
6 ; following code:
7 ; 1: extern "C" volatile int x;
8 ; 2: extern "C" void capture(int *p);
9 ; 3: static __forceinline inline void will_be_inlined() {
10 ; 4: int v = 3;
11 ; 5: capture(&v);
12 ; 6: }
13 ; 7: extern "C" void f(int param) {
14 ; 8: if (param) {
15 ; 9: int a = 42;
16 ; 10: will_be_inlined();
17 ; 11: capture(&a);
18 ; 12: } else {
19 ; 13: int b = 42;
20 ; 14: will_be_inlined();
21 ; 15: capture(&b);
22 ; 16: }
23 ; 17: }
24
25 ; ModuleID = 't.cpp'
26
27 ; Function Attrs: nounwind uwtable
28 define void @f(i32 %param) #0 !dbg !4 {
29 entry:
30 %v.i1 = alloca i32, align 4
31 call void @llvm.dbg.declare(metadata i32* %v.i1, metadata !15, metadata !16), !dbg !17
32 %v.i = alloca i32, align 4
33 call void @llvm.dbg.declare(metadata i32* %v.i, metadata !15, metadata !16), !dbg !21
34 %param.addr = alloca i32, align 4
35 %a = alloca i32, align 4
36 %b = alloca i32, align 4
37 store i32 %param, i32* %param.addr, align 4
38 call void @llvm.dbg.declare(metadata i32* %param.addr, metadata !24, metadata !16), !dbg !25
39 %0 = load i32, i32* %param.addr, align 4, !dbg !26
40 %tobool = icmp ne i32 %0, 0, !dbg !26
41 br i1 %tobool, label %if.then, label %if.else, !dbg !27
42
43 ;CHECK: movl [[REG:.*]], 24(%esp)
44 ;CHECK: je [[LABEL:.*]]
45
46 if.then: ; preds = %entry
47 call void @llvm.dbg.declare(metadata i32* %a, metadata !28, metadata !16), !dbg !29
48 store i32 42, i32* %a, align 4, !dbg !29
49 store i32 3, i32* %v.i, align 4, !dbg !21
50 call void @capture(i32* %v.i) #3, !dbg !30
51 call void @capture(i32* %a), !dbg !31
52 br label %if.end, !dbg !32
53
54 ;CHECK: movl $3, 16(%esp)
55
56 if.else: ; preds = %entry
57 call void @llvm.dbg.declare(metadata i32* %b, metadata !33, metadata !16), !dbg !34
58 store i32 42, i32* %b, align 4, !dbg !34
59 store i32 3, i32* %v.i1, align 4, !dbg !17
60 call void @capture(i32* %v.i1) #3, !dbg !35
61 call void @capture(i32* %b), !dbg !36
62 br label %if.end
63
64 ;CHECK: [[LABEL]]:
65 ;CHECK: movl $3, 20(%esp)
66
67 if.end: ; preds = %if.else, %if.then
68 ret void, !dbg !37
69 }
70
71 ; Function Attrs: nounwind readnone
72 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
73
74 declare void @capture(i32*) #2
75
76 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
77 attributes #1 = { nounwind readnone }
78 attributes #2 = { "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
79 attributes #3 = { nounwind }
80
81 !llvm.dbg.cu = !{!0}
82 !llvm.module.flags = !{!11, !12, !13}
83 !llvm.ident = !{!14}
84
85 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.9.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
86 !1 = !DIFile(filename: "t.cpp", directory: "D:\5Csrc\5Cllvm\5Cbuild")
87 !2 = !{}
88 !4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 7, type: !5, isLocal: false, isDefinition: true, scopeLine: 7, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
89 !5 = !DISubroutineType(types: !6)
90 !6 = !{null, !7}
91 !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
92 !8 = distinct !DISubprogram(name: "will_be_inlined", linkageName: "\01?will_be_inlined@@YAXXZ", scope: !1, file: !1, line: 3, type: !9, isLocal: true, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
93 !9 = !DISubroutineType(types: !10)
94 !10 = !{null}
95 !11 = !{i32 2, !"CodeView", i32 1}
96 !12 = !{i32 2, !"Debug Info Version", i32 3}
97 !13 = !{i32 1, !"PIC Level", i32 2}
98 !14 = !{!"clang version 3.9.0 "}
99 !15 = !DILocalVariable(name: "v", scope: !8, file: !1, line: 4, type: !7)
100 !16 = !DIExpression()
101 !17 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !18)
102 !18 = distinct !DILocation(line: 14, column: 5, scope: !19)
103 !19 = distinct !DILexicalBlock(scope: !20, file: !1, line: 12, column: 10)
104 !20 = distinct !DILexicalBlock(scope: !4, file: !1, line: 8, column: 7)
105 !21 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !22)
106 !22 = distinct !DILocation(line: 10, column: 5, scope: !23)
107 !23 = distinct !DILexicalBlock(scope: !20, file: !1, line: 8, column: 14)
108 !24 = !DILocalVariable(name: "param", arg: 1, scope: !4, file: !1, line: 7, type: !7)
109 !25 = !DILocation(line: 7, column: 23, scope: !4)
110 !26 = !DILocation(line: 8, column: 7, scope: !20)
111 !27 = !DILocation(line: 8, column: 7, scope: !4)
112 !28 = !DILocalVariable(name: "a", scope: !23, file: !1, line: 9, type: !7)
113 !29 = !DILocation(line: 9, column: 9, scope: !23)
114 !30 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !22)
115 !31 = !DILocation(line: 11, column: 5, scope: !23)
116 !32 = !DILocation(line: 12, column: 3, scope: !23)
117 !33 = !DILocalVariable(name: "b", scope: !19, file: !1, line: 13, type: !7)
118 !34 = !DILocation(line: 13, column: 9, scope: !19)
119 !35 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !18)
120 !36 = !DILocation(line: 15, column: 5, scope: !19)
121 !37 = !DILocation(line: 17, column: 1, scope: !4)
2626 ; ASM: .seh_proc f
2727 ; ASM: # BB#0: # %entry
2828 ; ASM: subq $56, %rsp
29 ; ASM: #DEBUG_VALUE: f:param <- [%RSP+44]
30 ; ASM: movl %ecx, 44(%rsp)
29 ; ASM: #DEBUG_VALUE: f:param <- [%RSP+52]
30 ; ASM: movl %ecx, 52(%rsp)
3131 ; ASM: [[prologue_end:\.Ltmp.*]]:
3232 ; ASM: .cv_loc 0 1 8 7 # t.cpp:8:7
3333 ; ASM: testl %ecx, %ecx
3434 ; ASM: je .LBB0_2
3535 ; ASM: [[if_start:\.Ltmp.*]]:
3636 ; ASM: # BB#1: # %if.then
37 ; ASM: #DEBUG_VALUE: f:param <- [%RSP+44]
37 ; ASM: #DEBUG_VALUE: f:param <- [%RSP+52]
3838 ; ASM: #DEBUG_VALUE: a <- [%RSP+40]
3939 ; ASM: .cv_loc 0 1 9 9 # t.cpp:9:9
4040 ; ASM: movl $42, 40(%rsp)
4141 ; ASM: [[inline_site1:\.Ltmp.*]]:
4242 ; ASM: .cv_loc 1 1 4 7 # t.cpp:4:7
43 ; ASM: movl $3, 48(%rsp)
44 ; ASM: leaq 48(%rsp), %rcx
43 ; ASM: movl $3, 44(%rsp)
44 ; ASM: leaq 44(%rsp), %rcx
4545 ; ASM: .cv_loc 1 1 5 3 # t.cpp:5:3
4646 ; ASM: callq capture
4747 ; ASM: leaq 40(%rsp), %rcx
4848 ; ASM: jmp .LBB0_3
4949 ; ASM: [[else_start:\.Ltmp.*]]:
5050 ; ASM: .LBB0_2: # %if.else
51 ; ASM: #DEBUG_VALUE: f:param <- [%RSP+44]
51 ; ASM: #DEBUG_VALUE: f:param <- [%RSP+52]
5252 ; ASM: #DEBUG_VALUE: b <- [%RSP+36]
5353 ; ASM: .cv_loc 0 1 13 9 # t.cpp:13:9
5454 ; ASM: movl $42, 36(%rsp)
5555 ; ASM: [[inline_site2:\.Ltmp.*]]:
5656 ; ASM: .cv_loc 2 1 4 7 # t.cpp:4:7
57 ; ASM: movl $3, 52(%rsp)
58 ; ASM: leaq 52(%rsp), %rcx
57 ; ASM: movl $3, 48(%rsp)
58 ; ASM: leaq 48(%rsp), %rcx
5959 ; ASM: .cv_loc 2 1 5 3 # t.cpp:5:3
6060 ; ASM: callq capture
6161 ; ASM: leaq 36(%rsp), %rcx
7474 ; ASM: .long 116 # TypeIndex
7575 ; ASM: .short 1 # Flags
7676 ; ASM: .asciz "param"
77 ; ASM: .cv_def_range [[prologue_end]] [[param_end]], "E\021O\001\000\000,\000\000\000"
77 ; ASM: .cv_def_range [[prologue_end]] [[param_end]], "E\021O\001\000\0004\000\000\000"
7878 ; ASM: .short 4414 # Record kind: S_LOCAL
7979 ; ASM: .long 116 # TypeIndex
8080 ; ASM: .short 0 # Flags
9090 ; ASM: .long 116 # TypeIndex
9191 ; ASM: .short 0 # Flags
9292 ; ASM: .asciz "v"
93 ; ASM: .cv_def_range [[inline_site1]] [[else_start]], "E\021O\001\000\0000\000\000\000"
93 ; ASM: .cv_def_range [[inline_site1]] [[else_start]], "E\021O\001\000\000,\000\000\000"
9494 ; ASM: .short 4430 # Record kind: S_INLINESITE_END
9595 ; ASM: .short 4429 # Record kind: S_INLINESITE
9696 ; ASM: .short 4414 # Record kind: S_LOCAL
9797 ; ASM: .long 116 # TypeIndex
9898 ; ASM: .short 0 # Flags
9999 ; ASM: .asciz "v"
100 ; ASM: .cv_def_range [[inline_site2]] [[inline_site2_end]], "E\021O\001\000\0004\000\000\000"
100 ; ASM: .cv_def_range [[inline_site2]] [[inline_site2_end]], "E\021O\001\000\0000\000\000\000"
101101 ; ASM: .short 4430 # Record kind: S_INLINESITE_END
102102
103103 ; OBJ: Subsection [
117117 ; OBJ: BaseRegister: 335
118118 ; OBJ: HasSpilledUDTMember: No
119119 ; OBJ: OffsetInParent: 0
120 ; OBJ: BasePointerOffset: 44
120 ; OBJ: BasePointerOffset: 52
121121 ; OBJ: LocalVariableAddrRange {
122122 ; OBJ: OffsetStart: .text+0x8
123123 ; OBJ: ISectStart: 0x0
179179 ; OBJ: BaseRegister: 335
180180 ; OBJ: HasSpilledUDTMember: No
181181 ; OBJ: OffsetInParent: 0
182 ; OBJ: BasePointerOffset: 48
182 ; OBJ: BasePointerOffset: 44
183183 ; OBJ: LocalVariableAddrRange {
184184 ; OBJ: OffsetStart: .text+0x14
185185 ; OBJ: ISectStart: 0x0
209209 ; OBJ: BaseRegister: 335
210210 ; OBJ: HasSpilledUDTMember: No
211211 ; OBJ: OffsetInParent: 0
212 ; OBJ: BasePointerOffset: 52
212 ; OBJ: BasePointerOffset: 48
213213 ; OBJ: LocalVariableAddrRange {
214214 ; OBJ: OffsetStart: .text+0x35
215215 ; OBJ: ISectStart: 0x0