1; RUN: llc < %s -experimental-debug-variable-locations=true | FileCheck %s 2; RUN: llc -filetype=obj < %s -experimental-debug-variable-locations=true | llvm-dwarfdump -debug-loc - | FileCheck %s --check-prefix=DWARF 3; RUN: llc --try-experimental-debuginfo-iterators < %s -experimental-debug-variable-locations=true | FileCheck %s 4; RUN: llc --try-experimental-debuginfo-iterators -filetype=obj < %s -experimental-debug-variable-locations=true | llvm-dwarfdump -debug-loc - | FileCheck %s --check-prefix=DWARF 5 6; Compile the following with -O1: 7 8; struct IntPair { int x, y; }; 9; int g(void); 10; int bitpiece_spill() { 11; struct IntPair o = {g(), 0}; 12; // Force o.x to spill 13; asm volatile("" : : : "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", 14; "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15"); 15; return o.x; 16; } 17 18; CHECK-LABEL: bitpiece_spill: # @bitpiece_spill 19; CHECK: callq g 20; CHECK: movl %eax, [[offs:[0-9]+]](%rsp) # 4-byte Spill 21; CHECK: #DEBUG_VALUE: bitpiece_spill:o <- [DW_OP_plus_uconst [[offs]], DW_OP_deref, DW_OP_LLVM_fragment 0 32] $rsp 22; CHECK: #DEBUG_VALUE: bitpiece_spill:o <- [DW_OP_LLVM_fragment 32 32] 0 23; CHECK: #APP 24; CHECK: #NO_APP 25; CHECK: movl [[offs]](%rsp), %eax # 4-byte Reload 26; CHECK: retq 27 28; DWARF: .debug_loc contents: 29; DWARF-NEXT: 0x00000000: 30; DWARF-NEXT: {{.*}}: DW_OP_breg7 RSP+{{[0-9]+}}, DW_OP_piece 0x4, DW_OP_lit0, DW_OP_stack_value, DW_OP_piece 0x4 31 32; ModuleID = 't.c' 33source_filename = "t.c" 34target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" 35target triple = "x86_64-pc-windows-msvc19.0.24210" 36 37%struct.IntPair = type { i32, i32 } 38 39; Function Attrs: nounwind uwtable 40define i32 @bitpiece_spill() local_unnamed_addr #0 !dbg !7 { 41entry: 42 tail call void @llvm.dbg.declare(metadata ptr undef, metadata !12, metadata !17), !dbg !18 43 %call = tail call i32 @g() #3, !dbg !19 44 tail call void @llvm.dbg.value(metadata i32 %call, metadata !12, metadata !20), !dbg !18 45 tail call void @llvm.dbg.value(metadata i32 0, metadata !12, metadata !21), !dbg !18 46 tail call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{rbp},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{dirflag},~{fpsr},~{flags}"() #3, !dbg !22, !srcloc !23 47 ret i32 %call, !dbg !24 48} 49 50; Function Attrs: nounwind readnone 51declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 52 53declare i32 @g() local_unnamed_addr #2 54 55; Function Attrs: nounwind readnone 56declare void @llvm.dbg.value(metadata, metadata, metadata) #1 57 58attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 59attributes #1 = { nounwind readnone } 60attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "frame-pointer"="none" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } 61attributes #3 = { nounwind } 62 63!llvm.dbg.cu = !{!0} 64!llvm.module.flags = !{!3, !4, !5} 65!llvm.ident = !{!6} 66 67!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2) 68!1 = !DIFile(filename: "t.c", directory: "C:\5Csrc\5Cllvm\5Cbuild") 69!2 = !{} 70!3 = !{i32 2, !"Dwarf Version", i32 4} 71!4 = !{i32 2, !"Debug Info Version", i32 3} 72!5 = !{i32 1, !"PIC Level", i32 2} 73!6 = !{!"clang version 4.0.0 "} 74!7 = distinct !DISubprogram(name: "bitpiece_spill", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, retainedNodes: !11) 75!8 = !DISubroutineType(types: !9) 76!9 = !{!10} 77!10 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 78!11 = !{!12} 79!12 = !DILocalVariable(name: "o", scope: !7, file: !1, line: 4, type: !13) 80!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "IntPair", file: !1, line: 1, size: 64, align: 32, elements: !14) 81!14 = !{!15, !16} 82!15 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !13, file: !1, line: 1, baseType: !10, size: 32, align: 32) 83!16 = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: !13, file: !1, line: 1, baseType: !10, size: 32, align: 32, offset: 32) 84!17 = !DIExpression() 85!18 = !DILocation(line: 4, column: 18, scope: !7) 86!19 = !DILocation(line: 4, column: 23, scope: !7) 87!20 = !DIExpression(DW_OP_LLVM_fragment, 0, 32) 88!21 = !DIExpression(DW_OP_LLVM_fragment, 32, 32) 89!22 = !DILocation(line: 6, column: 3, scope: !7) 90!23 = !{i32 138} 91!24 = !DILocation(line: 8, column: 3, scope: !7) 92