1 # RUN: llc -run-pass=livedebugvalues -march=mips -o - %s | FileCheck %s
3 #"last-instr-bundled.c"
4 #extern void set_cond(int, int*);
5 #extern void do_something(char *,int);
7 #void foo (int argument)
12 # set_cond(argument,&condition);
15 # do_something(string,argument);
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
22 # Check that last bundled instruction of block gets recognized as end of basic block.
24 # CHECK-NEXT: DBG_VALUE $s0, $noreg, !12, !DIExpression(), debug-location !17
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"
32 define void @foo(i32 signext %argument) local_unnamed_addr !dbg !7 {
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
45 if.then: ; preds = %entry
46 call void @do_something(i8* undef, i32 signext %argument), !dbg !28
47 br label %if.end, !dbg !28
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
55 ; Function Attrs: argmemonly nounwind
56 declare void @llvm.lifetime.start.p0i8(i64, i8* nocapture) #0
58 declare void @set_cond(i32 signext, i32*) local_unnamed_addr
60 declare void @do_something(i8*, i32 signext) local_unnamed_addr
62 ; Function Attrs: argmemonly nounwind
63 declare void @llvm.lifetime.end.p0i8(i64, i8* nocapture) #0
65 ; Function Attrs: nounwind readnone speculatable
66 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
68 ; Function Attrs: nounwind
69 declare void @llvm.stackprotector(i8*, i8**) #2
71 attributes #0 = { argmemonly nounwind }
72 attributes #1 = { nounwind readnone speculatable }
73 attributes #2 = { nounwind }
76 !llvm.module.flags = !{!3, !4, !5}
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: "/")
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)
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)
114 exposesReturnsTwice: false
116 regBankSelected: false
118 tracksRegLiveness: false
121 - { reg: '$a0', virtual-reg: '' }
123 isFrameAddressTaken: false
124 isReturnAddressTaken: false
134 hasOpaqueSPAdjustment: false
136 hasMustTailInVarArgFunc: false
141 - { id: 0, name: condition, type: default, offset: -12, size: 4, alignment: 4,
142 stack-id: default, 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: default, 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: default, callee-saved-register: '$s0', callee-saved-restored: true,
151 debug-info-variable: '', debug-info-expression: '',
152 debug-info-location: '' }
156 successors: %bb.2(0x30000000), %bb.1(0x50000000)
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 $a0, $noreg, !12, !DIExpression(), debug-location !17
166 DBG_VALUE $s0, $noreg, !12, !DIExpression(), debug-location !17
167 DBG_VALUE $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
171 renamable $at = LW $sp, 20, debug-location !21 :: (dereferenceable load 4 from %ir.condition, !tbaa !23)
172 DBG_VALUE $at, $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
178 successors: %bb.2(0x80000000)
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
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 {