1# RUN: llc -o - %s -start-after=patchable-function -O0 | FileCheck %s 2 3# Generated from the source file pr19307.cc: 4# #include <string> 5# void parse_range(unsigned long long &offset, unsigned long long &limit, 6# std::string range) { 7# if (range.compare(0, 6, "items=") != 0 || range[6] == '-') 8# offset = 1; 9# range.erase(0, 6); 10# limit = 2; 11# } 12# with "clang++ -S -emit-llvm -O0 -g pr19307.cc" 13# 14# Location of "range" string is spilled from %rdx to stack and is 15# addressed via %rbp. 16# CHECK: movq %rdx, {{[-0-9]+}}(%rbp) 17# CHECK-NEXT: [[START_LABEL:.Ltmp[0-9]+]]: 18# This location should be valid until the end of the function. 19# 20# Verify that we have proper range in debug_loc section: 21# CHECK: .Ldebug_loc{{[0-9]+}}: 22# CHECK: DW_OP_breg1 23# CHECK: .quad [[START_LABEL]]-.Lfunc_begin0 24# CHECK-NEXT: .quad .Lfunc_end0-.Lfunc_begin0 25# CHECK: DW_OP_breg6 26# CHECK: DW_OP_deref 27--- | 28 target triple = "x86_64-unknown-linux-gnu" 29 30 %"class.std::basic_string" = type { %"struct.std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider" } 31 %"struct.std::basic_string<char, std::char_traits<char>, std::allocator<char> >::_Alloc_hider" = type { ptr } 32 33 @.str = private unnamed_addr constant [7 x i8] c"items=\00", align 1 34 35 ; Function Attrs: uwtable 36 define void @_Z11parse_rangeRyS_Ss(ptr %offset, ptr %limit, ptr %range) #0 !dbg !34 { 37 entry: 38 %offset.addr = alloca ptr, align 8 39 %limit.addr = alloca ptr, align 8 40 store ptr %offset, ptr %offset.addr, align 8 41 call void @llvm.dbg.declare(metadata ptr %offset.addr, metadata !41, metadata !DIExpression()), !dbg !42 42 store ptr %limit, ptr %limit.addr, align 8 43 call void @llvm.dbg.declare(metadata ptr %limit.addr, metadata !43, metadata !DIExpression()), !dbg !42 44 call void @llvm.dbg.declare(metadata ptr %range, metadata !44, metadata !DIExpression(DW_OP_deref)), !dbg !45 45 %call = call i32 @_ZNKSs7compareEmmPKc(ptr %range, i64 0, i64 6, ptr @.str), !dbg !46 46 %cmp = icmp ne i32 %call, 0, !dbg !46 47 br i1 %cmp, label %if.then, label %lor.lhs.false, !dbg !46 48 49 lor.lhs.false: ; preds = %entry 50 %call1 = call ptr @_ZNSsixEm(ptr %range, i64 6), !dbg !48 51 %0 = load i8, ptr %call1, !dbg !48 52 %conv = sext i8 %0 to i32, !dbg !48 53 %cmp2 = icmp eq i32 %conv, 45, !dbg !48 54 br i1 %cmp2, label %if.then, label %if.end, !dbg !48 55 56 if.then: ; preds = %lor.lhs.false, %entry 57 %1 = load ptr, ptr %offset.addr, align 8, !dbg !50 58 store i64 1, ptr %1, align 8, !dbg !50 59 br label %if.end, !dbg !50 60 61 if.end: ; preds = %if.then, %lor.lhs.false 62 %call3 = call ptr @_ZNSs5eraseEmm(ptr %range, i64 0, i64 6), !dbg !51 63 %2 = load ptr, ptr %limit.addr, align 8, !dbg !52 64 store i64 2, ptr %2, align 8, !dbg !52 65 ret void, !dbg !53 66 } 67 68 ; Function Attrs: nounwind readnone speculatable 69 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 70 71 declare i32 @_ZNKSs7compareEmmPKc(ptr, i64, i64, ptr) #2 72 73 declare ptr @_ZNSsixEm(ptr, i64) #2 74 75 declare ptr @_ZNSs5eraseEmm(ptr, i64, i64) #2 76 77 ; Function Attrs: nounwind 78 declare void @llvm.stackprotector(ptr, ptr) #3 79 80 attributes #0 = { uwtable "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 81 attributes #1 = { nounwind readnone speculatable } 82 attributes #2 = { "less-precise-fpmad"="false" "frame-pointer"="all" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" } 83 attributes #3 = { nounwind } 84 85 !llvm.dbg.cu = !{!0} 86 !llvm.module.flags = !{!31, !32} 87 !llvm.ident = !{!33} 88 89 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.5.0 (209308)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, globals: !2, imports: !11) 90 !1 = !DIFile(filename: "pr19307.cc", directory: "/llvm_cmake_gcc") 91 !2 = !{} 92 !3 = !{!4, !6, !8} 93 !4 = !DICompositeType(tag: DW_TAG_structure_type, file: !5, line: 83, flags: DIFlagFwdDecl, identifier: "_ZTS11__mbstate_t") 94 !5 = !DIFile(filename: "/usr/include/wchar.h", directory: "/llvm_cmake_gcc") 95 !6 = !DICompositeType(tag: DW_TAG_structure_type, name: "lconv", file: !7, line: 54, flags: DIFlagFwdDecl, identifier: "_ZTS5lconv") 96 !7 = !DIFile(filename: "/usr/include/locale.h", directory: "/llvm_cmake_gcc") 97 !8 = !DICompositeType(tag: DW_TAG_class_type, name: "basic_string<char, std::char_traits<char>, std::allocator<char> >", scope: !10, file: !9, line: 1134, flags: DIFlagFwdDecl, identifier: "_ZTSSs") 98 !9 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/basic_string.tcc", directory: "/llvm_cmake_gcc") 99 !10 = !DINamespace(name: "std", scope: null) 100 !11 = !{!12, !15, !18, !22, !27, !30} 101 !12 = !DIImportedEntity(tag: DW_TAG_imported_module, scope: !13, entity: !14, file: !1, line: 57) 102 !13 = !DINamespace(name: "__gnu_debug", scope: null) 103 !14 = !DINamespace(name: "__debug", scope: !10) 104 !15 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !10, entity: !16, file: !1, line: 66) 105 !16 = !DIDerivedType(tag: DW_TAG_typedef, name: "mbstate_t", file: !5, line: 106, baseType: !17) 106 !17 = !DIDerivedType(tag: DW_TAG_typedef, name: "__mbstate_t", file: !5, line: 95, baseType: !4) 107 !18 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !10, entity: !19, file: !1, line: 141) 108 !19 = !DIDerivedType(tag: DW_TAG_typedef, name: "wint_t", file: !20, line: 141, baseType: !21) 109 !20 = !DIFile(filename: "/llvm_cmake_gcc/bin/../lib/clang/3.5.0/include/stddef.h", directory: "/llvm_cmake_gcc") 110 !21 = !DIBasicType(name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned) 111 !22 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !23, entity: !24, file: !1, line: 42) 112 !23 = !DINamespace(name: "__gnu_cxx", scope: null) 113 !24 = !DIDerivedType(tag: DW_TAG_typedef, name: "size_t", scope: !10, file: !25, line: 155, baseType: !26) 114 !25 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/x86_64-linux-gnu/bits/c++config.h", directory: "/llvm_cmake_gcc") 115 !26 = !DIBasicType(name: "long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned) 116 !27 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !23, entity: !28, file: !1, line: 43) 117 !28 = !DIDerivedType(tag: DW_TAG_typedef, name: "ptrdiff_t", scope: !10, file: !25, line: 156, baseType: !29) 118 !29 = !DIBasicType(name: "long int", size: 64, align: 64, encoding: DW_ATE_signed) 119 !30 = !DIImportedEntity(tag: DW_TAG_imported_declaration, scope: !10, entity: !6, file: !1, line: 55) 120 !31 = !{i32 2, !"Dwarf Version", i32 4} 121 !32 = !{i32 2, !"Debug Info Version", i32 3} 122 !33 = !{!"clang version 3.5.0 (209308)"} 123 !34 = distinct !DISubprogram(name: "parse_range", linkageName: "_Z11parse_rangeRyS_Ss", scope: !1, file: !1, line: 3, type: !35, isLocal: false, isDefinition: true, scopeLine: 4, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 124 !35 = !DISubroutineType(types: !36) 125 !36 = !{null, !37, !37, !39} 126 !37 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !38) 127 !38 = !DIBasicType(name: "long long unsigned int", size: 64, align: 64, encoding: DW_ATE_unsigned) 128 !39 = !DIDerivedType(tag: DW_TAG_typedef, name: "string", scope: !10, file: !40, line: 65, baseType: !8) 129 !40 = !DIFile(filename: "/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../../include/c++/4.6/bits/stringfwd.h", directory: "/llvm_cmake_gcc") 130 !41 = !DILocalVariable(name: "offset", arg: 1, scope: !34, file: !1, line: 3, type: !37) 131 !42 = !DILocation(line: 3, scope: !34) 132 !43 = !DILocalVariable(name: "limit", arg: 2, scope: !34, file: !1, line: 3, type: !37) 133 !44 = !DILocalVariable(name: "range", arg: 3, scope: !34, file: !1, line: 4, type: !39) 134 !45 = !DILocation(line: 4, scope: !34) 135 !46 = !DILocation(line: 5, scope: !47) 136 !47 = distinct !DILexicalBlock(scope: !34, file: !1, line: 5) 137 !48 = !DILocation(line: 5, scope: !49) 138 !49 = distinct !DILexicalBlock(scope: !47, file: !1, line: 5) 139 !50 = !DILocation(line: 6, scope: !47) 140 !51 = !DILocation(line: 7, scope: !34) 141 !52 = !DILocation(line: 8, scope: !34) 142 !53 = !DILocation(line: 9, scope: !34) 143 144... 145--- 146name: _Z11parse_rangeRyS_Ss 147alignment: 16 148tracksRegLiveness: true 149liveins: 150 - { reg: '$rdi' } 151 - { reg: '$rsi' } 152 - { reg: '$rdx' } 153frameInfo: 154 stackSize: 40 155 offsetAdjustment: -32 156 maxAlignment: 8 157 adjustsStack: true 158 hasCalls: true 159 maxCallFrameSize: 0 160fixedStack: 161 - { id: 0, type: spill-slot, offset: -16, size: 8, alignment: 16, stack-id: default } 162stack: 163 - { id: 0, name: offset.addr, offset: -24, size: 8, alignment: 8, stack-id: default, 164 debug-info-variable: '!41', debug-info-expression: '!DIExpression()', 165 debug-info-location: '!42' } 166 - { id: 1, name: limit.addr, offset: -32, size: 8, alignment: 8, stack-id: default, 167 debug-info-variable: '!43', debug-info-expression: '!DIExpression()', 168 debug-info-location: '!42' } 169 - { id: 2, type: spill-slot, offset: -40, size: 8, alignment: 8, stack-id: default } 170 - { id: 3, type: spill-slot, offset: -48, size: 8, alignment: 8, stack-id: default } 171body: | 172 bb.0.entry: 173 liveins: $rdi, $rsi, $rdx 174 175 frame-setup PUSH64r killed $rbp, implicit-def $rsp, implicit $rsp 176 CFI_INSTRUCTION def_cfa_offset 16 177 CFI_INSTRUCTION offset $rbp, -16 178 $rbp = frame-setup MOV64rr $rsp 179 CFI_INSTRUCTION def_cfa_register $rbp 180 $rsp = frame-setup SUB64ri8 $rsp, 32, implicit-def dead $eflags 181 $eax = XOR32rr undef $eax, undef $eax, implicit-def $eflags, implicit-def $rax 182 MOV64mr $rbp, 1, $noreg, -8, $noreg, killed renamable $rdi :: (store (s64) into %ir.offset.addr) 183 MOV64mr $rbp, 1, $noreg, -16, $noreg, killed renamable $rsi :: (store (s64) into %ir.limit.addr) 184 DBG_VALUE renamable $rdx, 0, !44, !DIExpression(DW_OP_deref), debug-location !45 185 $rdi = MOV64rr $rdx, debug-location !46 186 $rsi = MOV64rr killed $rax, debug-location !46 187 $eax = MOV32ri 6, implicit-def $rax, debug-location !46 188 MOV64mr $rbp, 1, $noreg, -24, $noreg, killed $rdx :: (store (s64) into %stack.2) 189 DBG_VALUE $rbp, 0, !44, !DIExpression(DW_OP_constu, 24, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !45 190 $rdx = MOV64rr killed $rax, debug-location !46 191 renamable $rcx = MOV64ri @.str, debug-location !46 192 CALL64pcrel32 @_ZNKSs7compareEmmPKc, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit killed $rsi, implicit killed $rdx, implicit killed $rcx, implicit-def $eax, debug-location !46 193 CMP32ri8 killed renamable $eax, 0, implicit-def $eflags, debug-location !46 194 JCC_1 %bb.2, 5, implicit $eflags, debug-location !46 195 196 bb.1.lor.lhs.false: 197 DBG_VALUE $rbp, 0, !44, !DIExpression(DW_OP_constu, 24, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !45 198 $rdi = MOV64rm $rbp, 1, $noreg, -24, $noreg :: (load (s64) from %stack.2) 199 $esi = MOV32ri 6, implicit-def $rsi, debug-location !48 200 CALL64pcrel32 @_ZNSsixEm, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit killed $rsi, implicit-def $rax, debug-location !48 201 renamable $ecx = MOVSX32rm8 killed renamable $rax, 1, $noreg, 0, $noreg, debug-location !48 :: (load (s8) from %ir.call1) 202 CMP32ri8 killed renamable $ecx, 45, implicit-def $eflags, debug-location !48 203 JCC_1 %bb.3, 5, implicit $eflags, debug-location !48 204 205 bb.2.if.then: 206 DBG_VALUE $rbp, 0, !44, !DIExpression(DW_OP_constu, 24, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !45 207 renamable $rax = MOV64rm $rbp, 1, $noreg, -8, $noreg, debug-location !50 :: (load (s64) from %ir.offset.addr) 208 MOV64mi32 killed renamable $rax, 1, $noreg, 0, $noreg, 1, debug-location !50 :: (store (s64) into %ir.1) 209 210 bb.3.if.end: 211 DBG_VALUE $rbp, 0, !44, !DIExpression(DW_OP_constu, 24, DW_OP_minus, DW_OP_deref, DW_OP_deref), debug-location !45 212 $esi = XOR32rr undef $esi, undef $esi, implicit-def $eflags, implicit-def $rsi 213 $rdi = MOV64rm $rbp, 1, $noreg, -24, $noreg :: (load (s64) from %stack.2) 214 $edx = MOV32ri 6, implicit-def $rdx, debug-location !51 215 CALL64pcrel32 @_ZNSs5eraseEmm, csr_64, implicit $rsp, implicit $ssp, implicit killed $rdi, implicit killed $rsi, implicit killed $rdx, implicit-def $rax, debug-location !51 216 renamable $rdx = MOV64rm $rbp, 1, $noreg, -16, $noreg, debug-location !52 :: (load (s64) from %ir.limit.addr) 217 MOV64mi32 killed renamable $rdx, 1, $noreg, 0, $noreg, 2, debug-location !52 :: (store (s64) into %ir.2) 218 MOV64mr $rbp, 1, $noreg, -32, $noreg, killed $rax :: (store (s64) into %stack.3) 219 $rsp = frame-destroy ADD64ri8 $rsp, 32, implicit-def dead $eflags, debug-location !53 220 $rbp = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !53 221 CFI_INSTRUCTION def_cfa $rsp, 8, debug-location !53 222 RET64 debug-location !53 223 224... 225