Home | History | Annotate | Download | only in X86
      1 ; RUN: llc < %s | FileCheck %s
      2 ; RUN: llc < %s -filetype=obj | llvm-dwarfdump - | FileCheck %s --check-prefix=DWARF
      3 
      4 ; This test creates two UserValues in LiveDebugVariables with one location
      5 ; each. x must be spilled, but y will be allocated to a CSR. x's location
      6 ; should be indirect, but y's should be direct.
      7 
      8 ; C source:
      9 ; #define FORCE_SPILL() \
     10 ;   __asm volatile("" : : : \
     11 ;                    "rax", "rbx", "rcx", "rdx", "rsi", "rdi", "rbp", "r8", \
     12 ;                    "r9", "r10", "r11", "r12", "r13", "r14", "r15")
     13 ; int g(int);
     14 ; int f() {
     15 ;   int x = g(0);
     16 ;   FORCE_SPILL();
     17 ;   int y = g(0);
     18 ;   g(y);
     19 ;   g(y);
     20 ;   g(y);
     21 ;   return x + y;
     22 ; }
     23 
     24 ; CHECK-LABEL: f: # @f
     25 ; CHECK: callq   g
     26 ; CHECK: movl    %eax, [[X_OFFS:[0-9]+]](%rsp)          # 4-byte Spill
     27 ; CHECK: #DEBUG_VALUE: f:x <- [DW_OP_plus_uconst [[X_OFFS]]] [$rsp+0]
     28 ; CHECK: #APP
     29 ; CHECK: #NO_APP
     30 ; CHECK: callq   g
     31 ; CHECK: movl    %eax, %[[CSR:[^ ]*]]
     32 ; CHECK: #DEBUG_VALUE: f:y <- $esi
     33 ; CHECK: movl    %eax, %ecx
     34 ; CHECK: callq   g
     35 ; CHECK: movl    %[[CSR]], %ecx
     36 ; CHECK: callq   g
     37 ; CHECK: movl    %[[CSR]], %ecx
     38 ; CHECK: callq   g
     39 ; CHECK: movl    [[X_OFFS]](%rsp), %eax          # 4-byte Reload
     40 ; CHECK: #DEBUG_VALUE: f:x <- $eax
     41 ; CHECK: addl    %[[CSR]], %eax
     42 
     43 ; DWARF:      DW_TAG_variable
     44 ; DWARF-NEXT:   DW_AT_location        (
     45 ; DWARF-NEXT:      [{{.*}}, {{.*}}): DW_OP_breg7 RSP+36
     46 ; DWARF-NEXT:      [{{.*}}, {{.*}}): DW_OP_reg0 RAX)
     47 ; DWARF-NEXT:   DW_AT_name    ("x")
     48 
     49 ; DWARF:      DW_TAG_variable
     50 ; DWARF-NEXT:   DW_AT_location        (
     51 ; DWARF-NEXT:      [{{.*}},  {{.*}}): DW_OP_reg4 RSI)
     52 ; DWARF-NEXT:   DW_AT_name    ("y")
     53 
     54 ; ModuleID = 'spill-nospill.c'
     55 source_filename = "spill-nospill.c"
     56 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
     57 target triple = "x86_64-pc-windows-msvc19.0.24215"
     58 
     59 ; Function Attrs: nounwind uwtable
     60 define i32 @f() local_unnamed_addr #0 !dbg !8 {
     61 entry:
     62   %call = tail call i32 @g(i32 0) #3, !dbg !15
     63   tail call void @llvm.dbg.value(metadata i32 %call, metadata !13, metadata !DIExpression()), !dbg !16
     64   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 !17, !srcloc !18
     65   %call1 = tail call i32 @g(i32 0) #3, !dbg !19
     66   tail call void @llvm.dbg.value(metadata i32 %call1, metadata !14, metadata !DIExpression()), !dbg !20
     67   %call2 = tail call i32 @g(i32 %call1) #3, !dbg !21
     68   %call3 = tail call i32 @g(i32 %call1) #3, !dbg !22
     69   %call4 = tail call i32 @g(i32 %call1) #3, !dbg !23
     70   %add = add nsw i32 %call1, %call, !dbg !24
     71   ret i32 %add, !dbg !25
     72 }
     73 
     74 declare i32 @g(i32) local_unnamed_addr #1
     75 
     76 ; Function Attrs: nounwind readnone speculatable
     77 declare void @llvm.dbg.value(metadata, metadata, metadata) #2
     78 
     79 attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
     80 attributes #1 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "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" }
     81 attributes #2 = { nounwind readnone speculatable }
     82 attributes #3 = { nounwind }
     83 
     84 !llvm.dbg.cu = !{!0}
     85 !llvm.module.flags = !{!3, !4, !5, !6}
     86 !llvm.ident = !{!7}
     87 
     88 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 6.0.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
     89 !1 = !DIFile(filename: "spill-nospill.c", directory: "C:\5Csrc\5Cllvm-project\5Cbuild")
     90 !2 = !{}
     91 !3 = !{i32 2, !"Dwarf Version", i32 4}
     92 !4 = !{i32 2, !"Debug Info Version", i32 3}
     93 !5 = !{i32 1, !"wchar_size", i32 2}
     94 !6 = !{i32 7, !"PIC Level", i32 2}
     95 !7 = !{!"clang version 6.0.0 "}
     96 !8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 8, type: !9, isLocal: false, isDefinition: true, scopeLine: 8, isOptimized: true, unit: !0, retainedNodes: !12)
     97 !9 = !DISubroutineType(types: !10)
     98 !10 = !{!11}
     99 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
    100 !12 = !{!13, !14}
    101 !13 = !DILocalVariable(name: "x", scope: !8, file: !1, line: 9, type: !11)
    102 !14 = !DILocalVariable(name: "y", scope: !8, file: !1, line: 11, type: !11)
    103 !15 = !DILocation(line: 9, column: 11, scope: !8)
    104 !16 = !DILocation(line: 9, column: 7, scope: !8)
    105 !17 = !DILocation(line: 10, column: 3, scope: !8)
    106 !18 = !{i32 -2147472112}
    107 !19 = !DILocation(line: 11, column: 11, scope: !8)
    108 !20 = !DILocation(line: 11, column: 7, scope: !8)
    109 !21 = !DILocation(line: 12, column: 3, scope: !8)
    110 !22 = !DILocation(line: 13, column: 3, scope: !8)
    111 !23 = !DILocation(line: 14, column: 3, scope: !8)
    112 !24 = !DILocation(line: 15, column: 12, scope: !8)
    113 !25 = !DILocation(line: 15, column: 3, scope: !8)
    114