• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test ensuring debug intrinsics do not affect generated function prologue.
2;
3; RUN: llc -O1 -mtriple=x86_64-unknown-unknown -o - %s | FileCheck %s
4
5define i64 @fn1NoDebug(i64 %a) {
6  %call = call i64 @fn(i64 %a, i64 0)
7  ret i64 %call
8}
9
10; CHECK-LABEL: fn1NoDebug
11; CHECK: popq %rcx
12; CHECK-NEXT: .cfi_def_cfa_offset 8
13; CHECK-NEXT: ret
14
15define i64 @fn1WithDebug(i64 %a) !dbg !4 {
16  %call = call i64 @fn(i64 %a, i64 0)
17  tail call void @llvm.dbg.value(metadata i64 %call, i64 0, metadata !5, metadata !6), !dbg !7
18  ret i64 %call
19}
20
21; CHECK-LABEL: fn1WithDebug
22; CHECK: popq %rcx
23; CHECK-NEXT: .cfi_def_cfa_offset 8
24; CHECK-NEXT: ret
25
26%struct.Buffer = type { i8, [63 x i8] }
27
28define void @fn2NoDebug(%struct.Buffer* byval align 64 %p1) {
29  ret void
30}
31
32; CHECK-LABEL: fn2NoDebug
33; CHECK: and
34; CHECK-NOT: add
35; CHECK-NOT: sub
36; CHECK: mov
37; CHECK-NEXT: pop
38; CHECK-NEXT: .cfi_def_cfa %rsp, 8
39; CHECK-NEXT: ret
40
41define void @fn2WithDebug(%struct.Buffer* byval align 64 %p1) !dbg !8 {
42  call void @llvm.dbg.declare(metadata %struct.Buffer* %p1, metadata !9, metadata !6), !dbg !10
43  ret void
44}
45
46; CHECK-LABEL: fn2WithDebug
47; CHECK: and
48; CHECK-NOT: add
49; CHECK-NOT: sub
50; CHECK: mov
51; CHECK-NEXT: pop
52; CHECK-NEXT: .cfi_def_cfa %rsp, 8
53; CHECK-NEXT: ret
54
55declare i64 @fn(i64, i64)
56
57declare void @llvm.dbg.value(metadata, i64, metadata, metadata)
58declare void @llvm.dbg.declare(metadata, metadata, metadata)
59
60!llvm.dbg.cu = !{!0}
61!llvm.module.flags = !{!2,!3}
62
63!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0")
64!1 = !DIFile(filename: "test.c", directory: "/")
65!2 = !{i32 2, !"Dwarf Version", i32 4}
66!3 = !{i32 2, !"Debug Info Version", i32 3}
67!4 = distinct !DISubprogram(name: "withDebug", unit: !0)
68!5 = !DILocalVariable(name: "w", scope: !4)
69!6 = !DIExpression()
70!7 = !DILocation(line: 210, column: 12, scope: !4)
71!8 = distinct !DISubprogram(name: "withDebug", unit: !0)
72!9 = !DILocalVariable(name: "w", scope: !8)
73!10 = !DILocation(line: 210, column: 12, scope: !8)
74