brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · b6879e3 Raw
114 lines · plain
1; RUN: opt < %s -S -passes=mem2reg,instcombine | FileCheck %s2 3; The '%bar' alloca will be promoted to an SSA register by mem2reg: test that4; zero line number are assigned to the dbg.value intrinsics that are inserted5; to represent changes in variable value. No machine instructions are6; generated from these dbg.values so their lines are irrelevant, only the7; scope and inlining information must be correct.8 9; In the second function here, LowerDbgDeclare will promote various variable10; accesses of a dbg.declare'd alloca into dbg.values. Check that their line11; numbers are sane too. (IR copied from DebugInfo/X86/formal_parameter.ll).12 13; CHECK-LABEL: define i32 @foo14 15; CHECK-LABEL: bb1:16; CHECK-NEXT:  %bar.0 = phi i3217; CHECK-NEXT:  #dbg_value(i32 %bar.0,{{.*}},  ![[UNKNOWN:[0-9]+]]18; CHECK-NEXT:  %totest = load19; CHECK-NEXT:  %add = add i32 %bar.020; CHECK-NEXT:  #dbg_value(i32 %add, {{.*}},  ![[UNKNOWN]]21; CHECK-NEXT:  %cond = icmp ult22; CHECK-NEXT:  br i1 %cond, label %bb1, label %bb223;24; CHECK-LABEL: bb2:25; CHECK-NEXT:  %toret = add i32 %bar.0, 326; CHECK-NEXT:  #dbg_value(i32 %toret, {{.*}},  ![[UNKNOWN]]27; CHECK-NEXT:  ret i32 %toret28 29define i32 @foo(ptr %bees, ptr %output) {30entry:31  %bar = alloca i3232  call void @llvm.dbg.declare(metadata ptr %bar, metadata !7, metadata !DIExpression()), !dbg !633  store i32 0, ptr %bar34  br label %bb1, !dbg !635 36bb1:37  %totest = load i32, ptr %bees, !dbg !838  %load1 = load i32, ptr %bar, !dbg !939  %add = add i32 %load1, 1, !dbg !1040  store i32 %add, ptr %bar, !dbg !1141  %toret = add i32 %add, 2, !dbg !1242  %cond = icmp ult i32 %totest, %load1, !dbg !1343  br i1 %cond, label %bb1, label %bb2, !dbg !1444 45bb2:46  store i32 %toret, ptr %bar, !dbg !1647  ret i32 %toret48}49 50; In the following, the dbg.value created for the store should get the stores51; line number, the other dbg.values should be unknown.52; CHECK-LABEL: define void @bar53;54; CHECK:      #dbg_value(i32 %map, ![[MAPVAR:[0-9]+]],{{.*}}),55; CHECK-SAME:           ![[UNKNOWN2:[0-9]+]]56; CHECK-NEXT: store57; CHECK-NEXT: #dbg_value(ptr %map.addr, ![[MAPVAR]],58; CHECK-SAME:           !DIExpression(DW_OP_deref),59; CHECK-SAME:           ![[UNKNOWN2]]60; CHECK-NEXT: call61; CHECK-NEXT: load62; CHECK-NEXT: #dbg_value(i32 %{{[0-9]+}}, ![[MAPVAR]],63; CHECK-SAME:           ![[UNKNOWN2]]64 65define void @bar(i32 %map) !dbg !20 {66entry:67  %map.addr = alloca i32, align 468  store i32 %map, ptr %map.addr, align 4, !dbg !2769  call void @llvm.dbg.declare(metadata ptr %map.addr, metadata !21, metadata !DIExpression()), !dbg !2270  %call = call i32 (ptr, ...) @lookup(ptr %map.addr), !dbg !2371%0 = load i32, ptr %map.addr, align 4, !dbg !2472  %call1 = call i32 (i32, ...) @verify(i32 %0), !dbg !2573  ret void, !dbg !2674}75 76declare void @llvm.dbg.value(metadata, metadata, metadata)77declare void @llvm.dbg.declare(metadata, metadata, metadata)78declare i32 @verify(...)79declare i32 @lookup(...)80 81; CHECK: ![[SUBPROG:[0-9]+]] = distinct !DISubprogram(name: "nope",82; CHECK: ![[UNKNOWN]] = !DILocation(line: 0, scope: ![[SUBPROG]])83 84; CHECK: ![[SUBPROG2:[0-9]+]] = distinct !DISubprogram(name: "thin",85; CHECK: ![[MAPVAR]] = !DILocalVariable(name: "floogie",86; CHECK: ![[UNKNOWN2]] = !DILocation(line: 087 88!llvm.module.flags = !{!4}89!llvm.dbg.cu = !{!2}90!1 = !DILocalVariable(name: "bees", scope: !5, type: null)91!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "beards", isOptimized: true, runtimeVersion: 4, emissionKind: FullDebug)92!3 = !DIFile(filename: "bees.cpp", directory: "")93!4 = !{i32 2, !"Debug Info Version", i32 3}94!5 = distinct !DISubprogram(name: "nope", scope: !3, file: !3, line: 1, unit: !2)95!6 = !DILocation(line: 1, scope: !5)96!7 = !DILocalVariable(name: "flannel", scope: !5, type: null)97!8 = !DILocation(line: 2, scope: !5)98!9 = !DILocation(line: 3, scope: !5)99!10 = !DILocation(line: 4, scope: !5)100!11 = !DILocation(line: 5, scope: !5)101!12 = !DILocation(line: 6, scope: !5)102!13 = !DILocation(line: 7, scope: !5)103!14 = !DILocation(line: 8, scope: !5)104!15 = distinct !DISubprogram(name: "wat", scope: !2, file: !3, line: 10, unit: !2)105!16 = !DILocation(line: 9, scope: !15, inlinedAt: !14)106!20 = distinct !DISubprogram(name: "thin", scope: !3, file: !3, line: 20, unit: !2)107!21 = !DILocalVariable(name: "floogie", scope: !20, type: null)108!22 = !DILocation(line: 21, scope: !20)109!23 = !DILocation(line: 22, scope: !20)110!24 = !DILocation(line: 23, scope: !20)111!25 = !DILocation(line: 24, scope: !20)112!26 = !DILocation(line: 25, scope: !20)113!27 = !DILocation(line: 20, scope: !20)114