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