192 lines · plain
1# RUN: llc -run-pass=livedebugvalues -mtriple=mips -o - %s | FileCheck %s2#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-bundled20# llc -stop-before=livedebugvalues < last-instr-bundled.ll > last-instr-bundled.mir21#22# Check that last bundled instruction of block gets recognized as end of basic block.23# CHECK: bb.2.if.end24# CHECK-NEXT: DBG_VALUE $s0, $noreg, !12, !DIExpression()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 435 call void @llvm.dbg.value(metadata i32 %argument, metadata !12, metadata !DIExpression()), !dbg !1736 %0 = bitcast ptr %condition to ptr, !dbg !1837 call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %0), !dbg !1838 call void @llvm.dbg.value(metadata ptr %condition, metadata !13, metadata !DIExpression()), !dbg !1939 call void @set_cond(i32 signext %argument, ptr nonnull %condition), !dbg !2040 %1 = load i32, ptr %condition, align 4, !dbg !21, !tbaa !2341 call void @llvm.dbg.value(metadata i32 %1, metadata !13, metadata !DIExpression()), !dbg !1942 %tobool = icmp eq i32 %1, 0, !dbg !2143 br i1 %tobool, label %if.end, label %if.then, !dbg !2744 45 if.then: ; preds = %entry46 call void @do_something(ptr undef, i32 signext %argument), !dbg !2847 br label %if.end, !dbg !2848 49 if.end: ; preds = %if.then, %entry50 %2 = bitcast ptr %condition to ptr51 call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %2), !dbg !2952 ret void, !dbg !2953 }54 55 ; Function Attrs: argmemonly nounwind56 declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #057 58 declare void @set_cond(i32 signext, ptr) local_unnamed_addr59 60 declare void @do_something(ptr, i32 signext) local_unnamed_addr61 62 ; Function Attrs: argmemonly nounwind63 declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #064 65 ; Function Attrs: nounwind readnone speculatable66 declare void @llvm.dbg.value(metadata, metadata, metadata) #167 68 ; Function Attrs: nounwind69 declare void @llvm.stackprotector(ptr, ptr) #270 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: foo113alignment: 4114exposesReturnsTwice: false115legalized: false116regBankSelected: false117selected: false118tracksRegLiveness: false119registers:120liveins:121 - { reg: '$a0', virtual-reg: '' }122frameInfo:123 isFrameAddressTaken: false124 isReturnAddressTaken: false125 hasStackMap: false126 hasPatchPoint: false127 stackSize: 32128 offsetAdjustment: 0129 maxAlignment: 4130 adjustsStack: true131 hasCalls: true132 stackProtector: ''133 maxCallFrameSize: 16134 hasOpaqueSPAdjustment: false135 hasVAStart: false136 hasMustTailInVarArgFunc: false137 savePoint: []138 restorePoint: []139fixedStack:140stack: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: '' }153constants:154body: |155 bb.0.entry:156 successors: %bb.2(0x30000000), %bb.1(0x50000000)157 158 $sp = ADDiu $sp, -32159 CFI_INSTRUCTION def_cfa_offset 32160 SW killed $ra, $sp, 28 :: (store (s32) into %stack.1)161 SW killed $s0, $sp, 24 :: (store (s32) into %stack.2)162 CFI_INSTRUCTION offset $ra_64, -4163 CFI_INSTRUCTION offset $s0_64, -8164 DBG_VALUE $a0, $noreg, !12, !DIExpression(), debug-location !17165 $s0 = OR $a0, $zero166 DBG_VALUE $s0, $noreg, !12, !DIExpression(), debug-location !17167 DBG_VALUE $sp, 0, !13, !DIExpression(DW_OP_plus_uconst, 20), debug-location !19168 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, 20170 }171 renamable $at = LW $sp, 20, debug-location !21 :: (dereferenceable load (s32) from %ir.condition, !tbaa !23)172 DBG_VALUE $at, $noreg, !13, !DIExpression(), debug-location !19173 BEQ killed renamable $at, $zero, %bb.2, implicit-def $at, debug-location !27 {174 NOP debug-location !27175 }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 !28182 }183 184 bb.2.if.end:185 $s0 = LW $sp, 24, debug-location !29 :: (load (s32) from %stack.2)186 $ra = LW $sp, 28, debug-location !29 :: (load (s32) from %stack.1)187 PseudoReturn undef $ra, debug-location !29 {188 $sp = ADDiu $sp, 32189 }190 191...192