xref: /aosp_15_r20/external/llvm/test/CodeGen/X86/2011-01-24-DbgValue-Before-Use.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -filetype=obj | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker; RUN: llc < %s -filetype=obj -regalloc=basic | llvm-dwarfdump -debug-dump=info -  | FileCheck %s
3*9880d681SAndroid Build Coastguard Workertarget datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
4*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-apple-darwin10.0.0"
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Worker; Check debug info for variable z_s
7*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
8*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_subprogram
9*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_variable
10*9880d681SAndroid Build Coastguard Worker; CHECK: DW_TAG_variable
11*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   DW_AT_location
12*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   DW_AT_name {{.*}} "z_s"
13*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   DW_AT_decl_file
14*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   DW_AT_decl_line
15*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT:   DW_AT_type{{.*}}{[[TYPE:.*]]}
16*9880d681SAndroid Build Coastguard Worker; CHECK: [[TYPE]]:
17*9880d681SAndroid Build Coastguard Worker; CHECK-NEXT: DW_AT_name {{.*}} "int"
18*9880d681SAndroid Build Coastguard Worker
19*9880d681SAndroid Build Coastguard Worker
20*9880d681SAndroid Build Coastguard Worker@.str1 = private unnamed_addr constant [14 x i8] c"m=%u, z_s=%d\0A\00"
21*9880d681SAndroid Build Coastguard Worker@str = internal constant [21 x i8] c"Failing test vector:\00"
22*9880d681SAndroid Build Coastguard Worker
23*9880d681SAndroid Build Coastguard Workerdefine i64 @gcd(i64 %a, i64 %b) nounwind readnone optsize noinline ssp !dbg !0 {
24*9880d681SAndroid Build Coastguard Workerentry:
25*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i64 %a, i64 0, metadata !10, metadata !DIExpression()), !dbg !18
26*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i64 %b, i64 0, metadata !11, metadata !DIExpression()), !dbg !19
27*9880d681SAndroid Build Coastguard Worker  br label %while.body, !dbg !20
28*9880d681SAndroid Build Coastguard Worker
29*9880d681SAndroid Build Coastguard Workerwhile.body:                                       ; preds = %while.body, %entry
30*9880d681SAndroid Build Coastguard Worker  %b.addr.0 = phi i64 [ %b, %entry ], [ %rem, %while.body ]
31*9880d681SAndroid Build Coastguard Worker  %a.addr.0 = phi i64 [ %a, %entry ], [ %b.addr.0, %while.body ]
32*9880d681SAndroid Build Coastguard Worker  %rem = srem i64 %a.addr.0, %b.addr.0, !dbg !21
33*9880d681SAndroid Build Coastguard Worker  %cmp = icmp eq i64 %rem, 0, !dbg !23
34*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %if.then, label %while.body, !dbg !23
35*9880d681SAndroid Build Coastguard Worker
36*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %while.body
37*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i64 %rem, i64 0, metadata !12, metadata !DIExpression()), !dbg !21
38*9880d681SAndroid Build Coastguard Worker  ret i64 %b.addr.0, !dbg !23
39*9880d681SAndroid Build Coastguard Worker}
40*9880d681SAndroid Build Coastguard Worker
41*9880d681SAndroid Build Coastguard Workerdefine i32 @main() nounwind optsize ssp !dbg !6 {
42*9880d681SAndroid Build Coastguard Workerentry:
43*9880d681SAndroid Build Coastguard Worker  %call = tail call i32 @rand() nounwind optsize, !dbg !24
44*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i32 %call, i64 0, metadata !14, metadata !DIExpression()), !dbg !24
45*9880d681SAndroid Build Coastguard Worker  %cmp = icmp ugt i32 %call, 21, !dbg !25
46*9880d681SAndroid Build Coastguard Worker  br i1 %cmp, label %cond.true, label %cond.end, !dbg !25
47*9880d681SAndroid Build Coastguard Worker
48*9880d681SAndroid Build Coastguard Workercond.true:                                        ; preds = %entry
49*9880d681SAndroid Build Coastguard Worker  %call1 = tail call i32 @rand() nounwind optsize, !dbg !25
50*9880d681SAndroid Build Coastguard Worker  br label %cond.end, !dbg !25
51*9880d681SAndroid Build Coastguard Worker
52*9880d681SAndroid Build Coastguard Workercond.end:                                         ; preds = %entry, %cond.true
53*9880d681SAndroid Build Coastguard Worker  %cond = phi i32 [ %call1, %cond.true ], [ %call, %entry ], !dbg !25
54*9880d681SAndroid Build Coastguard Worker  tail call void @llvm.dbg.value(metadata i32 %cond, i64 0, metadata !17, metadata !DIExpression()), !dbg !25
55*9880d681SAndroid Build Coastguard Worker  %conv = sext i32 %cond to i64, !dbg !26
56*9880d681SAndroid Build Coastguard Worker  %conv5 = zext i32 %call to i64, !dbg !26
57*9880d681SAndroid Build Coastguard Worker  %call6 = tail call i64 @gcd(i64 %conv, i64 %conv5) optsize, !dbg !26
58*9880d681SAndroid Build Coastguard Worker  %cmp7 = icmp eq i64 %call6, 0
59*9880d681SAndroid Build Coastguard Worker  br i1 %cmp7, label %return, label %if.then, !dbg !26
60*9880d681SAndroid Build Coastguard Worker
61*9880d681SAndroid Build Coastguard Workerif.then:                                          ; preds = %cond.end
62*9880d681SAndroid Build Coastguard Worker  %puts = tail call i32 @puts(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @str, i64 0, i64 0))
63*9880d681SAndroid Build Coastguard Worker  %call12 = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str1, i64 0, i64 0), i32 %call, i32 %cond) nounwind optsize, !dbg !26
64*9880d681SAndroid Build Coastguard Worker  ret i32 1, !dbg !27
65*9880d681SAndroid Build Coastguard Worker
66*9880d681SAndroid Build Coastguard Workerreturn:                                           ; preds = %cond.end
67*9880d681SAndroid Build Coastguard Worker  ret i32 0, !dbg !27
68*9880d681SAndroid Build Coastguard Worker}
69*9880d681SAndroid Build Coastguard Worker
70*9880d681SAndroid Build Coastguard Workerdeclare i32 @rand() optsize
71*9880d681SAndroid Build Coastguard Worker
72*9880d681SAndroid Build Coastguard Workerdeclare i32 @printf(i8* nocapture, ...) nounwind optsize
73*9880d681SAndroid Build Coastguard Worker
74*9880d681SAndroid Build Coastguard Workerdeclare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
75*9880d681SAndroid Build Coastguard Worker
76*9880d681SAndroid Build Coastguard Workerdeclare i32 @puts(i8* nocapture) nounwind
77*9880d681SAndroid Build Coastguard Worker
78*9880d681SAndroid Build Coastguard Worker!llvm.dbg.cu = !{!2}
79*9880d681SAndroid Build Coastguard Worker!llvm.module.flags = !{!33}
80*9880d681SAndroid Build Coastguard Worker
81*9880d681SAndroid Build Coastguard Worker!0 = distinct !DISubprogram(name: "gcd", line: 5, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, unit: !2, file: !31, scope: !1, type: !3, variables: !29)
82*9880d681SAndroid Build Coastguard Worker!1 = !DIFile(filename: "rem_small.c", directory: "/private/tmp")
83*9880d681SAndroid Build Coastguard Worker!2 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "clang version 2.9 (trunk 124117)", isOptimized: true, emissionKind: FullDebug, file: !31, enums: !32, retainedTypes: !32, imports:  null)
84*9880d681SAndroid Build Coastguard Worker!3 = !DISubroutineType(types: !4)
85*9880d681SAndroid Build Coastguard Worker!4 = !{!5}
86*9880d681SAndroid Build Coastguard Worker!5 = !DIBasicType(tag: DW_TAG_base_type, name: "long int", size: 64, align: 64, encoding: DW_ATE_signed)
87*9880d681SAndroid Build Coastguard Worker!6 = distinct !DISubprogram(name: "main", line: 25, isLocal: false, isDefinition: true, virtualIndex: 6, isOptimized: true, unit: !2, file: !31, scope: !1, type: !7, variables: !30)
88*9880d681SAndroid Build Coastguard Worker!7 = !DISubroutineType(types: !8)
89*9880d681SAndroid Build Coastguard Worker!8 = !{!9}
90*9880d681SAndroid Build Coastguard Worker!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
91*9880d681SAndroid Build Coastguard Worker!10 = !DILocalVariable(name: "a", line: 5, arg: 1, scope: !0, file: !1, type: !5)
92*9880d681SAndroid Build Coastguard Worker!11 = !DILocalVariable(name: "b", line: 5, arg: 2, scope: !0, file: !1, type: !5)
93*9880d681SAndroid Build Coastguard Worker!12 = !DILocalVariable(name: "c", line: 6, scope: !13, file: !1, type: !5)
94*9880d681SAndroid Build Coastguard Worker!13 = distinct !DILexicalBlock(line: 5, column: 52, file: !31, scope: !0)
95*9880d681SAndroid Build Coastguard Worker!14 = !DILocalVariable(name: "m", line: 26, scope: !15, file: !1, type: !16)
96*9880d681SAndroid Build Coastguard Worker!15 = distinct !DILexicalBlock(line: 25, column: 12, file: !31, scope: !6)
97*9880d681SAndroid Build Coastguard Worker!16 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
98*9880d681SAndroid Build Coastguard Worker!17 = !DILocalVariable(name: "z_s", line: 27, scope: !15, file: !1, type: !9)
99*9880d681SAndroid Build Coastguard Worker!18 = !DILocation(line: 5, column: 41, scope: !0)
100*9880d681SAndroid Build Coastguard Worker!19 = !DILocation(line: 5, column: 49, scope: !0)
101*9880d681SAndroid Build Coastguard Worker!20 = !DILocation(line: 7, column: 5, scope: !13)
102*9880d681SAndroid Build Coastguard Worker!21 = !DILocation(line: 8, column: 9, scope: !22)
103*9880d681SAndroid Build Coastguard Worker!22 = distinct !DILexicalBlock(line: 7, column: 14, file: !31, scope: !13)
104*9880d681SAndroid Build Coastguard Worker!23 = !DILocation(line: 9, column: 9, scope: !22)
105*9880d681SAndroid Build Coastguard Worker!24 = !DILocation(line: 26, column: 38, scope: !15)
106*9880d681SAndroid Build Coastguard Worker!25 = !DILocation(line: 27, column: 38, scope: !15)
107*9880d681SAndroid Build Coastguard Worker!26 = !DILocation(line: 28, column: 9, scope: !15)
108*9880d681SAndroid Build Coastguard Worker!27 = !DILocation(line: 30, column: 1, scope: !15)
109*9880d681SAndroid Build Coastguard Worker!29 = !{!10, !11, !12}
110*9880d681SAndroid Build Coastguard Worker!30 = !{!14, !17}
111*9880d681SAndroid Build Coastguard Worker!31 = !DIFile(filename: "rem_small.c", directory: "/private/tmp")
112*9880d681SAndroid Build Coastguard Worker!32 = !{}
113*9880d681SAndroid Build Coastguard Worker!33 = !{i32 1, !"Debug Info Version", i32 3}
114