1 ; RUN: llc %s -o - | FileCheck %s
3 ; This test case was generated by running
5 ; clang++ -O2 -g PR37234.cpp -S -save-temps
6 ; opt -O2 -S PR37234.bc -o PR37234.ll
8 ; using the following PR37234.cpp program
11 ; const char* buffer = "aaa";
13 ; while (char c = *buffer++) {
15 ; ++aa; // DexWatch('aa')
21 ; CHECK-LABEL: # %bb.{{.*}}:
22 ; CHECK: #DEBUG_VALUE: main:aa <- 0
23 ; CHECK: #DEBUG_VALUE: main:aa <- $[[REG:[0-9a-z]+]]
25 ; CHECK: #DEBUG_VALUE: main:aa <- $[[REG]]
27 ; CHECK: # %bb.{{.*}}:
28 ; CHECK: #DEBUG_VALUE: main:aa <- $[[REG]]
30 ; CHECK: # %bb.{{.*}}:
31 ; CHECK: #DEBUG_VALUE: main:aa <- $[[REG]]
32 ; CHECK: incl %[[REG]]
33 ; CHECK: #DEBUG_VALUE: main:aa <- $[[REG]]
36 ; CHECK: #DEBUG_VALUE: main:aa <- $[[REG]]
39 source_filename = "PR37234.cpp"
40 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
41 target triple = "x86_64-unknown-linux-gnu"
43 @.str = private unnamed_addr constant [4 x i8] c"aaa\00", align 1
45 ; Function Attrs: norecurse nounwind readonly uwtable
46 define dso_local i32 @main() local_unnamed_addr #0 !dbg !7 {
48 call void @llvm.dbg.value(metadata i32 0, metadata !16, metadata !DIExpression()), !dbg !19
49 br label %while.cond.outer, !dbg !20
51 while.cond.outer: ; preds = %if.then, %entry
52 %buffer.0.ph = phi i8* [ %incdec.ptr, %if.then ], [ getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), %entry ]
53 %aa.0.ph = phi i32 [ %inc, %if.then ], [ 0, %entry ]
54 br label %while.cond, !dbg !21
56 while.cond: ; preds = %while.cond.outer, %while.cond
57 %buffer.0 = phi i8* [ %incdec.ptr, %while.cond ], [ %buffer.0.ph, %while.cond.outer ], !dbg !22
58 call void @llvm.dbg.value(metadata i32 %aa.0.ph, metadata !16, metadata !DIExpression()), !dbg !19
59 call void @llvm.dbg.value(metadata i8* %buffer.0, metadata !12, metadata !DIExpression()), !dbg !23
60 %incdec.ptr = getelementptr inbounds i8, i8* %buffer.0, i64 1, !dbg !21
61 call void @llvm.dbg.value(metadata i8* %incdec.ptr, metadata !12, metadata !DIExpression()), !dbg !23
62 %0 = load i8, i8* %buffer.0, align 1, !dbg !24, !tbaa !25
63 call void @llvm.dbg.value(metadata i8 %0, metadata !18, metadata !DIExpression()), !dbg !28
64 switch i8 %0, label %while.cond [
65 i8 0, label %while.end
69 if.then: ; preds = %while.cond
70 %inc = add i32 %aa.0.ph, 1, !dbg !29
71 call void @llvm.dbg.value(metadata i32 %inc, metadata !16, metadata !DIExpression()), !dbg !19
72 br label %while.cond.outer, !dbg !29
74 while.end: ; preds = %while.cond
75 call void @llvm.dbg.value(metadata i32 %aa.0.ph, metadata !16, metadata !DIExpression()), !dbg !19
76 call void @llvm.dbg.value(metadata i32 %aa.0.ph, metadata !16, metadata !DIExpression()), !dbg !19
77 call void @llvm.dbg.value(metadata i32 %aa.0.ph, metadata !16, metadata !DIExpression()), !dbg !19
78 call void @llvm.dbg.value(metadata i32 %aa.0.ph, metadata !16, metadata !DIExpression()), !dbg !19
79 ret i32 %aa.0.ph, !dbg !32
82 ; Function Attrs: nounwind readnone speculatable
83 declare void @llvm.dbg.value(metadata, metadata, metadata) #1
85 attributes #0 = { norecurse nounwind readonly uwtable }
86 attributes #1 = { nounwind readnone speculatable }
89 !llvm.module.flags = !{!3, !4, !5}
92 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 7.0.0 (trunk 330946) (llvm/trunk 330952)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
93 !1 = !DIFile(filename: "PR37234.cpp", directory: "")
95 !3 = !{i32 2, !"Dwarf Version", i32 4}
96 !4 = !{i32 2, !"Debug Info Version", i32 3}
97 !5 = !{i32 1, !"wchar_size", i32 4}
98 !6 = !{!"clang version 7.0.0 (trunk 330946) (llvm/trunk 330952)"}
99 !7 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
100 !8 = !DISubroutineType(types: !9)
102 !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
103 !11 = !{!12, !16, !18}
104 !12 = !DILocalVariable(name: "buffer", scope: !7, file: !1, line: 2, type: !13)
105 !13 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !14, size: 64)
106 !14 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !15)
107 !15 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
108 !16 = !DILocalVariable(name: "aa", scope: !7, file: !1, line: 3, type: !17)
109 !17 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
110 !18 = !DILocalVariable(name: "c", scope: !7, file: !1, line: 4, type: !15)
111 !19 = !DILocation(line: 3, column: 18, scope: !7)
112 !20 = !DILocation(line: 4, column: 9, scope: !7)
113 !21 = !DILocation(line: 4, column: 32, scope: !7)
114 !22 = !DILocation(line: 0, scope: !7)
115 !23 = !DILocation(line: 2, column: 21, scope: !7)
116 !24 = !DILocation(line: 4, column: 25, scope: !7)
117 !25 = !{!26, !26, i64 0}
118 !26 = !{!"omnipotent char", !27, i64 0}
119 !27 = !{!"Simple C++ TBAA"}
120 !28 = !DILocation(line: 4, column: 21, scope: !7)
121 !29 = !DILocation(line: 6, column: 25, scope: !30)
122 !30 = distinct !DILexicalBlock(scope: !31, file: !1, line: 5, column: 21)
123 !31 = distinct !DILexicalBlock(scope: !7, file: !1, line: 4, column: 36)
124 !32 = !DILocation(line: 9, column: 1, scope: !7)