brintos

brintos / llvm-project-archived public Read only

0
0
Text · 7.3 KiB · 304e581 Raw
153 lines · plain
1; RUN: opt -passes='cgscc(inline)' -S %s -o - -S | FileCheck %s --implicit-check-not=dbg_value2 3;; Test that dbg.value intrinsics are inlined, remapped, and have their4;; dilocation updated just like normal instructions. This becomes5;; important when debug-info records case to be instructions.6;;7;; test should be inlined into test28 9; CHECK: define i32 @test210; CHECK-NEXT: entry:11; CHECK:      %k.addr.i = alloca i32, align 412; CHECK:      %k2.i = alloca i32, align 413; CHECK:      %0 = load i32, ptr @global_var, align 4, !dbg !914; CHECK:      store i32 %0, ptr %k.addr.i, align 415; CHECK-NEXT: #dbg_value(ptr %k.addr.i, ![[KVAR:[0-9]+]], !DIExpression(), ![[KLINE:[0-9]+]]16; CHECK-NEXT: #dbg_value(ptr %k2.i, ![[K2VAR:[0-9]+]], !DIExpression(), ![[GLINE:[0-9]+]]17; CHECK-NEXT: %1 = load i32, ptr %k.addr.i, align 4,18;;19;; dbg.values in this block should be remapped to the local load, but also20;; the Argument to the calling test2 function.21;;22; CHECK: if.then.i:23; CHECK-NEXT: %3 = load i32, ptr %k2.i,24; CHECK-NEXT: #dbg_value(i32 %3, ![[KVAR]], !DIExpression(), ![[KLINE]]25; CHECK-NEXT: #dbg_value(i32 %foo, ![[K2VAR]], !DIExpression(), ![[GLINE]]26;27;; Similarly, the end block should retain remapped dbg.values, with the second28;; referring to the @global_var load in the entry block. Check that we clone29;; from the terminator correctly.30;31; CHECK: if.end.i:32; CHECK-NEXT:  store i32 0, ptr %retval.i, align 4,33; CHECK-NEXT:  #dbg_value(i32 0, ![[KVAR]], !DIExpression(), ![[KLINE]]34; CHECK-NEXT:  #dbg_value(i32 %0, ![[K2VAR]], !DIExpression(), ![[GLINE]]35; CHECK-NEXT:  br label %test.exit,36;37;; More or less the same checks again in the exit block, this time at the head38;; of the block, and on a terminator that gets elided.39;40; CHECK: test.exit:41; CHECK-NEXT: #dbg_value(i32 %0, ![[KVAR]], !DIExpression(), ![[KLINE]]42; CHECK-NEXT: #dbg_value(i32 %bar, ![[K2VAR]], !DIExpression(), ![[GLINE]]43; CHECK-NEXT: %4 = load i32, ptr %retval.i, align 4,44; CHECK-NEXT: #dbg_value(i32 1, ![[KVAR]], !DIExpression(), ![[KLINE]]45; CHECK-NEXT: #dbg_value(i32 1, ![[K2VAR]], !DIExpression(), ![[GLINE]]46;47;48;; Test that the metadata maps onto the correct things, and that the DILocations49;; attached to the intrinsics have been inlined.50;51; CHECK-DAG: ![[TEST2SP:[0-9]+]] = distinct !DISubprogram(name: "test2",52; CHECK-DAG: ![[INLINESITEBLOCK:[0-9]+]] = distinct !DILexicalBlock(scope: ![[TEST2SP]],53; CHECK-DAG: ![[TESTSP:[0-9]+]] = distinct !DISubprogram(name: "test",54; CHECK-DAG: ![[KVAR]] = !DILocalVariable(name: "k",55; CHECK-DAG: ![[K2VAR]] = !DILocalVariable(name: "k2",56; CHECK-DAG: ![[KLINE]] = !DILocation(line: 4, scope: ![[TESTSP]], inlinedAt: ![[INLINESITE:[0-9]+]])57; CHECK-DAG: ![[INLINESITE]] = distinct !DILocation(line: 14, scope: ![[INLINESITEBLOCK]])58; CHECK-DAG: ![[GLINE]] = !DILocation(line: 5, scope: ![[TESTSP]], inlinedAt: ![[INLINESITE:[0-9]+]])59 60target triple = "x86_64--"61 62@global_var = external global i3263 64define internal i32 @test(i32 %k, i32 %foo, i32 %bar)  !dbg !4 {65entry:66  %retval = alloca i32, align 467  %k.addr = alloca i32, align 468  %k2 = alloca i32, align 469  store i32 %k, ptr %k.addr, align 470  call void @llvm.dbg.value(metadata ptr %k.addr, metadata !13, metadata !DIExpression()), !dbg !1471  call void @llvm.dbg.value(metadata ptr %k2, metadata !15, metadata !DIExpression()), !dbg !1672  %0 = load i32, ptr %k.addr, align 4, !dbg !1673  %call = call i32 @_Z8test_exti(i32 %0), !dbg !1674  store i32 %call, ptr %k2, align 4, !dbg !1675  %1 = load i32, ptr %k2, align 4, !dbg !1776  %cmp = icmp sgt i32 %1, 100, !dbg !1777  br i1 %cmp, label %if.then, label %if.end, !dbg !1778 79if.then:                                          ; preds = %entry80  %2 = load i32, ptr %k2, align 4, !dbg !1881  call void @llvm.dbg.value(metadata i32 %2, metadata !13, metadata !DIExpression()), !dbg !1482  call void @llvm.dbg.value(metadata i32 %foo, metadata !15, metadata !DIExpression()), !dbg !1683  store i32 %2, ptr %retval, !dbg !1884  br label %return, !dbg !1885 86if.end:                                           ; preds = %entry87  store i32 0, ptr %retval, !dbg !1988  call void @llvm.dbg.value(metadata i32 0, metadata !13, metadata !DIExpression()), !dbg !1489  call void @llvm.dbg.value(metadata i32 %k, metadata !15, metadata !DIExpression()), !dbg !1690  br label %return, !dbg !1991 92return:                                           ; preds = %if.end, %if.then93  call void @llvm.dbg.value(metadata i32 %k, metadata !13, metadata !DIExpression()), !dbg !1494  call void @llvm.dbg.value(metadata i32 %bar, metadata !15, metadata !DIExpression()), !dbg !1695  %3 = load i32, ptr %retval, !dbg !2096  call void @llvm.dbg.value(metadata i32 1, metadata !13, metadata !DIExpression()), !dbg !1497  call void @llvm.dbg.value(metadata i32 1, metadata !15, metadata !DIExpression()), !dbg !1698  ret i32 %3, !dbg !2099}100 101declare i32 @_Z8test_exti(i32)102 103define i32 @test2(i32 %foo, i32 %bar) !dbg !10 {104entry:105  %exn.slot = alloca ptr106  %ehselector.slot = alloca i32107  %e = alloca i32, align 4108  %0 = load i32, ptr @global_var, align 4, !dbg !21109  %call = call i32 @test(i32 %0, i32 %foo, i32 %bar), !dbg !21110  br label %try.cont, !dbg !23111 112try.cont:                                         ; preds = %catch, %invoke.cont113  store i32 1, ptr @global_var, align 4, !dbg !29114  ret i32 0, !dbg !30115}116 117declare void @llvm.dbg.value(metadata, metadata, metadata) #1118 119!llvm.dbg.cu = !{!0}120!llvm.module.flags = !{!31}121 122!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !2, globals: !2, imports: !2)123!1 = !DIFile(filename: "<unknown>", directory: "")124!2 = !{}125!4 = distinct !DISubprogram(name: "test", linkageName: "_Z4testi", line: 4, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 4, file: !5, scope: !6, type: !7, retainedNodes: !2)126!5 = !DIFile(filename: "test.cpp", directory: "")127!6 = !DIFile(filename: "test.cpp", directory: "")128!7 = !DISubroutineType(types: !8)129!8 = !{!9, !9}130!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)131!10 = distinct !DISubprogram(name: "test2", linkageName: "_Z5test2v", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 11, file: !5, scope: !6, type: !11, retainedNodes: !2)132!11 = !DISubroutineType(types: !12)133!12 = !{!9}134!13 = !DILocalVariable(name: "k", line: 4, arg: 1, scope: !4, file: !6, type: !9)135!14 = !DILocation(line: 4, scope: !4)136!15 = !DILocalVariable(name: "k2", line: 5, scope: !4, file: !6, type: !9)137!16 = !DILocation(line: 5, scope: !4)138!17 = !DILocation(line: 6, scope: !4)139!18 = !DILocation(line: 7, scope: !4)140!19 = !DILocation(line: 8, scope: !4)141!20 = !DILocation(line: 9, scope: !4)142!21 = !DILocation(line: 14, scope: !22)143!22 = distinct !DILexicalBlock(line: 13, column: 0, file: !5, scope: !10)144!23 = !DILocation(line: 15, scope: !22)145!24 = !DILocalVariable(name: "e", line: 16, scope: !10, file: !6, type: !9)146!25 = !DILocation(line: 16, scope: !10)147!26 = !DILocation(line: 17, scope: !27)148!27 = distinct !DILexicalBlock(line: 16, column: 0, file: !5, scope: !10)149!28 = !DILocation(line: 18, scope: !27)150!29 = !DILocation(line: 19, scope: !10)151!30 = !DILocation(line: 20, scope: !10)152!31 = !{i32 1, !"Debug Info Version", i32 3}153