• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# RUN: llc -run-pass=livedebugvalues -march=mips -o - %s | FileCheck %s
2#
3#"last-instr-bundled.c"
4#extern void set_cond(int, int*);
5#extern void do_something(char *,int);
6#
7#void foo (int argument)
8#{
9#  int condition;
10#  char *string;
11#
12#  set_cond(argument,&condition);
13#
14#  if (condition)
15#    do_something(string,argument);
16#}
17#
18# reproduce:
19# clang --target=mips-linux-gnu -g -O1 -S -emit-llvm last-instr-bundled
20# llc -stop-before=livedebugvalues < last-instr-bundled.ll > last-instr-bundled.mir
21#
22# Check that last bundled instruction of block gets recognized as end of basic block.
23# CHECK: bb.2.if.end
24# CHECK-NEXT: DBG_VALUE debug-use $s0, debug-use $noreg, !12, !DIExpression(), debug-location !17
25
26--- |
27  ; ModuleID = '<stdin>'
28  source_filename = "last-inst-bundled.c"
29  target datalayout = "E-m:m-p:32:32-i8:8:32-i16:16:32-i64:64-n32-S64"
30  target triple = "mips--linux-gnu"
31
32  define void @foo(i32 signext %argument) local_unnamed_addr !dbg !7 {
33  entry:
34    %condition = alloca i32, align 4
35    call void @llvm.dbg.value(metadata i32 %argument, metadata !12, metadata !DIExpression()), !dbg !17
36    %0 = bitcast i32* %condition to i8*, !dbg !18
37    call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %0), !dbg !18
38    call void @llvm.dbg.value(metadata i32* %condition, metadata !13, metadata !DIExpression()), !dbg !19
39    call void @set_cond(i32 signext %argument, i32* nonnull %condition), !dbg !20
40    %1 = load i32, i32* %condition, align 4, !dbg !21, !tbaa !23
41    call void @llvm.dbg.value(metadata i32 %1, metadata !13, metadata !DIExpression()), !dbg !19
42    %tobool = icmp eq i32 %1, 0, !dbg !21
43    br i1 %tobool, label %if.end, label %if.then, !dbg !27
44
45  if.then:                                          ; preds = %entry
46    call void @do_something(i8* undef, i32 signext %argument), !dbg !28
47    br label %if.end, !dbg !28
48
49  if.end:                                           ; preds = %if.then, %entry
50    %2 = bitcast i32* %condition to i8*
51    call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %2), !dbg !29
52    ret void, !dbg !29
53  }
54
55  ; Function Attrs: argmemonly nounwind
56  declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #0
57
58  declare void @set_cond(i32 signext, i32*) local_unnamed_addr
59
60  declare void @do_something(i8*, i32 signext) local_unnamed_addr
61
62  ; Function Attrs: argmemonly nounwind
63  declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #0
64
65  ; Function Attrs: nounwind readnone speculatable
66  declare void @llvm.dbg.value(metadata, metadata, metadata) #1
67
68  ; Function Attrs: nounwind
69  declare void @llvm.stackprotector(i8*, i8**) #2
70
71  attributes #0 = { argmemonly nounwind }
72  attributes #1 = { nounwind readnone speculatable }
73  attributes #2 = { nounwind }
74
75  !llvm.dbg.cu = !{!0}
76  !llvm.module.flags = !{!3, !4, !5}
77  !llvm.ident = !{!6}
78
79  !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
80  !1 = !DIFile(filename: "last-inst-bundled.c", directory: "/")
81  !2 = !{}
82  !3 = !{i32 2, !"Dwarf Version", i32 4}
83  !4 = !{i32 2, !"Debug Info Version", i32 3}
84  !5 = !{i32 1, !"wchar_size", i32 4}
85  !6 = !{!"clang version 6.0.0 "}
86  !7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 4, type: !8, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
87  !8 = !DISubroutineType(types: !9)
88  !9 = !{null, !10}
89  !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
90  !11 = !{!12, !13, !14}
91  !12 = !DILocalVariable(name: "argument", arg: 1, scope: !7, file: !1, line: 4, type: !10)
92  !13 = !DILocalVariable(name: "condition", scope: !7, file: !1, line: 6, type: !10)
93  !14 = !DILocalVariable(name: "string", scope: !7, file: !1, line: 7, type: !15)
94  !15 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !16, size: 32)
95  !16 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
96  !17 = !DILocation(line: 4, column: 15, scope: !7)
97  !18 = !DILocation(line: 6, column: 3, scope: !7)
98  !19 = !DILocation(line: 6, column: 7, scope: !7)
99  !20 = !DILocation(line: 9, column: 3, scope: !7)
100  !21 = !DILocation(line: 11, column: 7, scope: !22)
101  !22 = distinct !DILexicalBlock(scope: !7, file: !1, line: 11, column: 7)
102  !23 = !{!24, !24, i64 0}
103  !24 = !{!"int", !25, i64 0}
104  !25 = !{!"omnipotent char", !26, i64 0}
105  !26 = !{!"Simple C/C++ TBAA"}
106  !27 = !DILocation(line: 11, column: 7, scope: !7)
107  !28 = !DILocation(line: 12, column: 5, scope: !22)
108  !29 = !DILocation(line: 13, column: 1, scope: !7)
109
110...
111---
112name:            foo
113alignment:       2
114exposesReturnsTwice: false
115legalized:       false
116regBankSelected: false
117selected:        false
118tracksRegLiveness: false
119registers:
120liveins:
121  - { reg: '$a0', virtual-reg: '' }
122frameInfo:
123  isFrameAddressTaken: false
124  isReturnAddressTaken: false
125  hasStackMap:     false
126  hasPatchPoint:   false
127  stackSize:       32
128  offsetAdjustment: 0
129  maxAlignment:    4
130  adjustsStack:    true
131  hasCalls:        true
132  stackProtector:  ''
133  maxCallFrameSize: 16
134  hasOpaqueSPAdjustment: false
135  hasVAStart:      false
136  hasMustTailInVarArgFunc: false
137  savePoint:       ''
138  restorePoint:    ''
139fixedStack:
140stack:
141  - { id: 0, name: condition, type: default, offset: -12, size: 4, alignment: 4,
142      stack-id: 0, callee-saved-register: '', callee-saved-restored: true,
143      debug-info-variable: '', debug-info-expression: '',
144      debug-info-location: '' }
145  - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4,
146      stack-id: 0, callee-saved-register: '$ra', callee-saved-restored: true,
147      debug-info-variable: '', debug-info-expression: '',
148      debug-info-location: '' }
149  - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4,
150      stack-id: 0, callee-saved-register: '$s0', callee-saved-restored: true,
151      debug-info-variable: '', debug-info-expression: '',
152      debug-info-location: '' }
153constants:
154body:             |
155  bb.0.entry:
156    successors: %bb.2(0x30000000), %bb.1(0x50000000)
157
158    $sp = ADDiu $sp, -32
159    CFI_INSTRUCTION def_cfa_offset 32
160    SW killed $ra, $sp, 28 :: (store 4 into %stack.1)
161    SW killed $s0, $sp, 24 :: (store 4 into %stack.2)
162    CFI_INSTRUCTION offset $ra_64, -4
163    CFI_INSTRUCTION offset $s0_64, -8
164    DBG_VALUE debug-use $a0, debug-use $noreg, !12, !DIExpression(), debug-location !17
165    $s0 = OR $a0, $zero
166    DBG_VALUE debug-use $s0, debug-use $noreg, !12, !DIExpression(), debug-location !17
167    DBG_VALUE debug-use $sp, 0, !13, !DIExpression(DW_OP_plus_uconst, 20), debug-location !19
168    JAL @set_cond, csr_o32, implicit-def dead $ra, implicit $a0, implicit $a1, implicit-def $sp, debug-location !20 {
169      renamable $a1 = LEA_ADDiu $sp, 20
170    }
171    renamable $at = LW $sp, 20, debug-location !21 :: (dereferenceable load 4 from %ir.condition, !tbaa !23)
172    DBG_VALUE debug-use $at, debug-use $noreg, !13, !DIExpression(), debug-location !19
173    BEQ killed renamable $at, $zero, %bb.2, implicit-def $at, debug-location !27 {
174      NOP debug-location !27
175    }
176
177  bb.1.if.then:
178    successors: %bb.2(0x80000000)
179
180    JAL @do_something, csr_o32, implicit-def dead $ra, implicit undef $a0, implicit $a1, implicit-def $sp, debug-location !28 {
181      $a1 = OR killed $s0, $zero, debug-location !28
182    }
183
184  bb.2.if.end:
185    $s0 = LW $sp, 24, debug-location !29 :: (load 4 from %stack.2)
186    $ra = LW $sp, 28, debug-location !29 :: (load 4 from %stack.1)
187    PseudoReturn undef $ra, debug-location !29 {
188      $sp = ADDiu $sp, 32
189    }
190
191...
192