1# RUN: llc -start-after=prologepilog -filetype=obj -O0 %s -o - | llvm-readobj --codeview - | FileCheck %s 2 3# Offsets are now CFA, or VFRAME, relative. Both the NRVO sret pointer and the 4# string* parameter are on the stack, NRVO at offset 4 (after RA), and Str at 5# offset 8 (next slot). The stack size is 4, so the DW_OP_plus_uconst math 6# works out. 7 8# (DW_OP_plus_uconst 12) 9# CHECK: LocalSym { 10# CHECK-NEXT: Kind: S_LOCAL (0x113E) 11# CHECK-NEXT: Type: string* (0x 12# CHECK-NEXT: Flags [ (0x0) 13# CHECK-NEXT: ] 14# CHECK-NEXT: VarName: Str 15# CHECK-NEXT: } 16# CHECK-NEXT: DefRangeFramePointerRelSym { 17# CHECK-NEXT: Kind: S_DEFRANGE_FRAMEPOINTER_REL (0x1142) 18# CHECK-NEXT: Offset: 12 19# CHECK-NEXT: LocalVariableAddrRange { 20# CHECK-NEXT: OffsetStart: 21# CHECK-NEXT: ISectStart: 22# CHECK-NEXT: Range: 23# CHECK-NEXT: } 24# CHECK-NEXT: } 25# (DW_OP_plus_uconst, 8, DW_OP_deref) 26# CHECK: LocalSym { 27# CHECK-NEXT: Kind: S_LOCAL (0x113E) 28# CHECK-NEXT: Type: string& (0x 29# CHECK-NEXT: Flags [ (0x0) 30# CHECK-NEXT: ] 31# CHECK-NEXT: VarName: Result 32# CHECK-NEXT: } 33# CHECK-NEXT: DefRangeFramePointerRelSym { 34# CHECK-NEXT: Kind: S_DEFRANGE_FRAMEPOINTER_REL (0x1142) 35# CHECK-NEXT: Offset: 8 36# CHECK-NEXT: LocalVariableAddrRange { 37# CHECK-NEXT: OffsetStart: .text+0x5 38# CHECK-NEXT: ISectStart: 0x0 39# CHECK-NEXT: Range: 0x18 40# CHECK-NEXT: } 41# CHECK-NEXT: } 42# (DW_OP_constu, 4, DW_OP_minus) 43# CHECK: LocalSym { 44# CHECK-NEXT: Kind: S_LOCAL (0x113E) 45# CHECK-NEXT: Type: long (0x12) 46# CHECK-NEXT: Flags [ (0x0) 47# CHECK-NEXT: ] 48# CHECK-NEXT: VarName: Bytes 49# CHECK-NEXT: } 50# CHECK-NEXT: DefRangeRegisterRelSym { 51# CHECK-NEXT: Kind: S_DEFRANGE_REGISTER_REL (0x1145) 52# CHECK-NEXT: BaseRegister: 53# CHECK-NEXT: HasSpilledUDTMember: No 54# CHECK-NEXT: OffsetInParent: 0 55# CHECK-NEXT: BasePointerOffset: -4 56# CHECK-NEXT: LocalVariableAddrRange { 57# CHECK-NEXT: OffsetStart: 58# CHECK-NEXT: ISectStart: 59# CHECK-NEXT: Range: 60# CHECK-NEXT: } 61# CHECK-NEXT: } 62--- | 63 ; ModuleID = '<stdin>' 64 source_filename = "<stdin>" 65 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" 66 target triple = "i386-pc-windows-msvc19.0.24215" 67 68 %struct.string = type { i32, i32, i8* } 69 70 define void @fun(%struct.string* noalias sret(%struct.string) %agg.result, %struct.string* noalias %str) !dbg !12 { 71 entry: 72 call void @llvm.dbg.value(metadata %struct.string* %agg.result, metadata !23, metadata !24), !dbg !25 73 call void @llvm.dbg.value(metadata %struct.string* %str, metadata !26, metadata !28), !dbg !25 74 %call = call dereferenceable(12) %struct.string* @getString(), !dbg !29 75 %0 = bitcast %struct.string* %agg.result to i8*, !dbg !29 76 %1 = bitcast %struct.string* %call to i8*, !dbg !29 77 call void @llvm.memcpy.p0i8.p0i8.i32(i8* %0, i8* %1, i32 12, i32 4, i1 false), !dbg !29 78 ret void, !dbg !30 79 } 80 81 define i32 @len(%struct.string* %s, i32 %acc) !dbg !31 { 82 entry: 83 %0 = bitcast %struct.string* %s to i32* 84 %bytes = load i32, i32* %0, !dbg !34 85 call void @llvm.dbg.declare(metadata i32 %bytes, metadata !35, metadata !28), !dbg !34 86 %1 = add i32 %bytes, %acc, !dbg !36 87 ret i32 %1, !dbg !36 88 } 89 90 ; Function Attrs: nounwind readnone speculatable 91 declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 92 93 ; Function Attrs: nounwind readnone speculatable 94 declare void @llvm.dbg.value(metadata, metadata, metadata) #0 95 96 declare dereferenceable(12) %struct.string* @getString() 97 98 ; Function Attrs: argmemonly nounwind 99 declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture writeonly, i8* nocapture readonly, i32, i32, i1) #1 100 101 ; Function Attrs: nounwind 102 declare void @llvm.stackprotector(i8*, i8**) #2 103 104 attributes #0 = { nounwind readnone speculatable } 105 attributes #1 = { argmemonly nounwind } 106 attributes #2 = { nounwind } 107 108 !llvm.dbg.cu = !{!0} 109 !llvm.linker.options = !{!3, !4} 110 !llvm.module.flags = !{!5, !6, !7, !8} 111 !llvm.ident = !{!9} 112 113 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 6.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 114 !1 = !DIFile(filename: "diexpr.ll", directory: "C:\5Csrc", checksumkind: CSK_MD5, checksum: "c547c362c610fa79e7abaddc76e1efe7") 115 !2 = !{} 116 !3 = !{!"/DEFAULTLIB:libcmt.lib"} 117 !4 = !{!"/DEFAULTLIB:oldnames.lib"} 118 !5 = !{i32 1, !"NumRegisterParameters", i32 0} 119 !6 = !{i32 2, !"CodeView", i32 1} 120 !7 = !{i32 2, !"Debug Info Version", i32 3} 121 !8 = !{i32 1, !"wchar_size", i32 2} 122 !9 = !{!"clang version 6.0.0 "} 123 !10 = !DIExpression(DW_OP_plus_uconst, 12) 124 !11 = !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref) 125 !12 = distinct !DISubprogram(name: "fun", linkageName: "fun", scope: !1, file: !1, line: 9, type: !13, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 126 !13 = !DISubroutineType(types: !14) 127 !14 = !{!15} 128 !15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "string", file: !1, line: 1, size: 96, elements: !16, identifier: ".?AUstring@@") 129 !16 = !{!17, !19, !20} 130 !17 = !DIDerivedType(tag: DW_TAG_member, name: "length", scope: !15, file: !1, line: 2, baseType: !18, size: 32) 131 !18 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) 132 !19 = !DIDerivedType(tag: DW_TAG_member, name: "size", scope: !15, file: !1, line: 3, baseType: !18, size: 32, offset: 32) 133 !20 = !DIDerivedType(tag: DW_TAG_member, name: "data", scope: !15, file: !1, line: 4, baseType: !21, size: 32, offset: 64) 134 !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 32) 135 !22 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) 136 !23 = !DILocalVariable(name: "Result", scope: !12, file: !1, line: 10, type: !15) 137 !24 = !DIExpression(DW_OP_deref) 138 !25 = !DILocation(line: 10, scope: !12) 139 !26 = !DILocalVariable(name: "Str", scope: !12, file: !1, line: 10, type: !27) 140 !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !15, size: 32) 141 !28 = !DIExpression(DW_OP_constu, 4, DW_OP_minus) 142 !29 = !DILocation(line: 11, scope: !12) 143 !30 = !DILocation(line: 12, scope: !12) 144 !31 = distinct !DISubprogram(name: "len", linkageName: "len", scope: !1, file: !1, line: 14, type: !32, isLocal: false, isDefinition: true, scopeLine: 14, flags: DIFlagPrototyped, isOptimized: false, unit: !0, retainedNodes: !2) 145 !32 = !DISubroutineType(types: !33) 146 !33 = !{!18} 147 !34 = !DILocation(line: 15, scope: !31) 148 !35 = !DILocalVariable(name: "Bytes", scope: !31, file: !1, line: 15, type: !18) 149 !36 = !DILocation(line: 16, scope: !31) 150 151... 152--- 153name: fun 154alignment: 16 155exposesReturnsTwice: false 156legalized: false 157regBankSelected: false 158selected: false 159tracksRegLiveness: true 160registers: 161liveins: 162frameInfo: 163 isFrameAddressTaken: false 164 isReturnAddressTaken: false 165 hasStackMap: false 166 hasPatchPoint: false 167 stackSize: 4 168 offsetAdjustment: 0 169 maxAlignment: 4 170 adjustsStack: true 171 hasCalls: true 172 stackProtector: '' 173 maxCallFrameSize: 0 174 hasOpaqueSPAdjustment: false 175 hasVAStart: false 176 hasMustTailInVarArgFunc: false 177 savePoint: '' 178 restorePoint: '' 179fixedStack: 180 - { id: 0, type: spill-slot, offset: -8, size: 4, alignment: 4, stack-id: default, 181 callee-saved-register: '$esi' } 182 - { id: 1, type: default, offset: 4, size: 4, alignment: 4, stack-id: default, 183 isImmutable: true, isAliased: false, callee-saved-register: '' } 184 - { id: 2, type: default, offset: 0, size: 4, alignment: 4, stack-id: default, 185 isImmutable: true, isAliased: false, callee-saved-register: '' } 186stack: 187constants: 188body: | 189 bb.0.entry: 190 liveins: $esi 191 192 frame-setup PUSH32r killed $esi, implicit-def $esp, implicit $esp 193 CFI_INSTRUCTION def_cfa_offset 8 194 CFI_INSTRUCTION offset $esi, -8 195 $esi = MOV32rm $esp, 1, _, 8, _ :: (load 4 from %fixed-stack.2) 196 DBG_VALUE $esp, 0, !26, !10, debug-location !25 197 DBG_VALUE $esp, 0, !23, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !25 198 CALLpcrel32 @getString, csr_32, implicit $esp, implicit-def $esp, implicit-def $eax, debug-location !29 199 $ecx = MOV32rm $eax, 1, _, 0, _, debug-location !29 :: (dereferenceable load 4 from %ir.1) 200 $edx = MOV32rm $eax, 1, _, 4, _, debug-location !29 :: (dereferenceable load 4 from %ir.1 + 4) 201 MOV32mr $esi, 1, _, 0, _, killed $ecx, debug-location !29 :: (store 4 into %ir.0) 202 MOV32mr $esi, 1, _, 4, _, killed $edx, debug-location !29 :: (store 4 into %ir.0 + 4) 203 $eax = MOV32rm killed $eax, 1, _, 8, _, debug-location !29 :: (dereferenceable load 4 from %ir.1 + 8) 204 MOV32mr $esi, 1, _, 8, _, killed $eax, debug-location !29 :: (store 4 into %ir.0 + 8) 205 $eax = COPY killed $esi, debug-location !30 206 $esi = POP32r implicit-def $esp, implicit $esp, debug-location !30 207 RET 0, $eax, debug-location !30 208 209... 210--- 211name: len 212alignment: 16 213exposesReturnsTwice: false 214legalized: false 215regBankSelected: false 216selected: false 217tracksRegLiveness: true 218registers: 219liveins: 220frameInfo: 221 isFrameAddressTaken: false 222 isReturnAddressTaken: false 223 hasStackMap: false 224 hasPatchPoint: false 225 stackSize: 0 226 offsetAdjustment: 0 227 maxAlignment: 4 228 adjustsStack: false 229 hasCalls: false 230 stackProtector: '' 231 maxCallFrameSize: 0 232 hasOpaqueSPAdjustment: false 233 hasVAStart: false 234 hasMustTailInVarArgFunc: false 235 savePoint: '' 236 restorePoint: '' 237fixedStack: 238 - { id: 0, type: default, offset: 4, size: 4, alignment: 4, stack-id: default, 239 isImmutable: true, isAliased: false, callee-saved-register: '' } 240 - { id: 1, type: default, offset: 0, size: 4, alignment: 4, stack-id: default, 241 isImmutable: true, isAliased: false, callee-saved-register: '' } 242stack: 243constants: 244body: | 245 bb.0.entry: 246 $eax = MOV32rm $esp, 1, _, 4, _ :: (load 4 from %fixed-stack.1) 247 $eax = MOV32rm killed $eax, 1, _, 0, _, debug-location !34 :: (load 4 from %ir.0) 248 DBG_VALUE $eax, 0, !35, !DIExpression(DW_OP_constu, 4, DW_OP_minus), debug-location !34 249 $eax = ADD32rm killed $eax, $esp, 1, _, 8, _, implicit-def dead $eflags, debug-location !36 :: (load 4 from %fixed-stack.0) 250 RET 0, $eax, debug-location !36 251 252... 253