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