brintos

brintos / llvm-project-archived public Read only

0
0
Text · 11.3 KiB · 347f001 Raw
219 lines · plain
1; RUN: llc %s -stop-before finalize-isel -o - \2; RUN:    -experimental-debug-variable-locations=false \3; RUN: | FileCheck %s --check-prefixes=CHECK,DBGVALUE4 5; RUN: llc %s -stop-before finalize-isel -o - \6; RUN:    -experimental-debug-variable-locations=true \7; RUN: | FileCheck %s --check-prefixes=CHECK,INSTRREF8 9;--------------------------------------------------------------------10; Adapted from sdag-dangling-dbgvalue.ll to test dbg.assign intrinsics. This11; ensures that dbg.assigns with no linked store are treated as dbg.values.  For12; ease of writing, all the dbg.assign intrinsics refer to the same DIAssignID13; !54. There is no linked store in any case.14;15; This test case is basically generated from the following C code.16; Compiled with "--target=x86_64-apple-darwin -S -g -O3" to get debug17; info for optimized code.18;19; struct SS {20;   int a;21;   int b;22; } S = { .a = 23, .b = -17 };23;24; int test1() {25;   struct SS* foo1 = &S;26;   return (int)foo1;27; }28;29; int test2() {30;   struct SS* foo2 = &S;31;   struct SS* bar2 = &S;32;   return (int)foo2 + (int)bar2;33; }34;35; int test3() {36;   struct SS* bar3 = &S;37;   struct SS* foo3 = &S;38;   return (int)foo3 + (int)bar3;39; }40;41; int test4() {42;   struct SS* foo4 = &S;43;   struct SS* bar4 = &S;44;   foo = 0;45;   return (int)foo4 + (int)bar4;46; }47;48; int test5() {49;   struct SS* bar5 = &S;50;   struct SS* foo5 = &S;51;   foo5 = 0;52;   return (int)foo5 + (int)bar5;53; }54;--------------------------------------------------------------------55 56; CHECK:  ![[FOO1:.*]] = !DILocalVariable(name: "foo1"57; CHECK:  ![[BAR1:.*]] = !DILocalVariable(name: "bar1"58; CHECK:  ![[FOO2:.*]] = !DILocalVariable(name: "foo2"59; CHECK:  ![[BAR2:.*]] = !DILocalVariable(name: "bar2"60; CHECK:  ![[FOO3:.*]] = !DILocalVariable(name: "bar3"61; CHECK:  ![[BAR3:.*]] = !DILocalVariable(name: "foo3"62; CHECK:  ![[FOO4:.*]] = !DILocalVariable(name: "foo4"63; CHECK:  ![[BAR4:.*]] = !DILocalVariable(name: "bar4"64; CHECK:  ![[BAR5:.*]] = !DILocalVariable(name: "bar5"65; CHECK:  ![[FOO5:.*]] = !DILocalVariable(name: "foo5"66 67source_filename = "sdag-dangling-dbgvalue.c"68target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"69target triple = "x86_64-apple-macosx10.4.0"70 71%struct.SS = type { i32, i32 }72 73@S = global %struct.SS { i32 23, i32 -17 }, align 4, !dbg !074 75; Verify that the def comes before the for foo1.76define i32 @test1() local_unnamed_addr #0 !dbg !17 {77; CHECK-LABEL: bb.0.entry178; CHECK-NEXT:    DBG_VALUE 0, $noreg, ![[BAR1]], !DIExpression()79; CHECK-NEXT:    [[REG1:%[0-9]+]]:gr64 = LEA64r80; INSTRREF-SAME:    debug-instr-number 181; INSTRREF-NEXT:  DBG_INSTR_REF ![[FOO1]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)82; DBGVALUE-NEXT:  DBG_VALUE [[REG1]], $noreg, ![[FOO1]], !DIExpression()83entry1:84  call void @llvm.dbg.assign(metadata ptr @S, metadata !20, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !2385  call void @llvm.dbg.assign(metadata ptr null, metadata !22, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !2486  ret i32 ptrtoint (ptr @S to i32), !dbg !2587}88 89; Verify that the def comes before the for foo2 and bar2.90define i32 @test2() local_unnamed_addr #0 !dbg !26 {91; CHECK-LABEL: bb.0.entry292; CHECK-NEXT:    [[REG2:%[0-9]+]]:gr64 = LEA64r93; INSTRREF-SAME:    debug-instr-number 194; INSTRREF-NEXT: DBG_INSTR_REF ![[FOO2]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)95; INSTRREF-NEXT: DBG_INSTR_REF ![[BAR2]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)96; DBGVALUE-NEXT: DBG_VALUE [[REG2]], $noreg, ![[FOO2]], !DIExpression97; DBGVALUE-NEXT: DBG_VALUE [[REG2]], $noreg, ![[BAR2]], !DIExpression98entry2:99  call void @llvm.dbg.assign(metadata ptr @S, metadata !28, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !30100  call void @llvm.dbg.assign(metadata ptr @S, metadata !29, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !31101  ret i32 add (i32 ptrtoint (ptr @S to i32), i32 ptrtoint (ptr @S to i32)), !dbg !32102}103 104; Verify that the def comes before the for foo3 and bar3.105define i32 @test3() local_unnamed_addr #0 !dbg !33 {106; CHECK-LABEL: bb.0.entry3107; CHECK-NEXT:    [[REG3:%[0-9]+]]:gr64 = LEA64r108; INSTRREF-SAME:    debug-instr-number 1109; INSTRREF-NEXT: DBG_INSTR_REF ![[BAR3]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)110; INSTRREF-NEXT: DBG_INSTR_REF ![[FOO3]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)111; DBGVALUE-NEXT: DBG_VALUE [[REG3]], $noreg, ![[BAR3]], !DIExpression()112; DBGVALUE-NEXT: DBG_VALUE [[REG3]], $noreg, ![[FOO3]], !DIExpression()113entry3:114  call void @llvm.dbg.assign(metadata ptr @S, metadata !36, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !38115  call void @llvm.dbg.assign(metadata ptr @S, metadata !35, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !37116  ret i32 add (i32 ptrtoint (ptr @S to i32), i32 ptrtoint (ptr @S to i32)), !dbg !39117}118 119; Verify that the def comes before the for bar4.120define i32 @test4() local_unnamed_addr #0 !dbg !40 {121; CHECK-LABEL: bb.0.entry4122;; NOTE: The check for `DBG_VALUE $noreg, $noreg, ![[FOO4]], !DIExpression()`123;; has been removed because AT lowering removes redundant debug intrinsics.124; CHECK-NEXT:    DBG_VALUE 0, $noreg, ![[FOO4]], !DIExpression()125; CHECK-NEXT:    [[REG4:%[0-9]+]]:gr64 = LEA64r126; INSTRREF-SAME:    debug-instr-number 1127; INSTRREF-NEXT: DBG_INSTR_REF ![[BAR4]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)128; DBGVALUE-NEXT: DBG_VALUE [[REG4]], $noreg, ![[BAR4]], !DIExpression()129entry4:130  call void @llvm.dbg.assign(metadata ptr @S, metadata !42, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !44131  call void @llvm.dbg.assign(metadata ptr @S, metadata !43, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !45132  call void @llvm.dbg.assign(metadata ptr null, metadata !42, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !44133  ret i32 ptrtoint (ptr @S to i32), !dbg !46134}135 136; Verify that we do not get a DBG_VALUE that maps foo5 to @S here.137define i32 @test5() local_unnamed_addr #0 !dbg !47 {138; CHECK-LABEL: bb.0.entry5:139; cHECK-NEXT:    DBG_VALUE $noreg, $noreg, ![[FOO5]], !DIExpression()140; CHECK-NEXT:    DBG_VALUE 0, $noreg, ![[FOO5]], !DIExpression()141; CHECK-NEXT:    [[REG5:%[0-9]+]]:gr64 = LEA64r142; INSTRREF-SAME:    debug-instr-number 1143; INSTRREF-NEXT: DBG_INSTR_REF ![[BAR5]], !DIExpression(DW_OP_LLVM_arg, 0), dbg-instr-ref(1, 0)144; DBGVALUE-NEXT: DBG_VALUE [[REG5]], $noreg, ![[BAR5]], !DIExpression()145; CHECK-NOT:     DBG_{{.*}} ![[FOO5]], !DIExpression()146; CHECK:         RET147entry5:148  call void @llvm.dbg.assign(metadata ptr @S, metadata !49, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !51149  call void @llvm.dbg.assign(metadata ptr @S, metadata !50, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !52150  call void @llvm.dbg.assign(metadata ptr null, metadata !50, metadata !DIExpression(), metadata !54, metadata ptr undef, metadata !DIExpression()), !dbg !52151  ret i32 ptrtoint (ptr @S to i32), !dbg !53152}153 154declare void @llvm.dbg.assign(metadata, metadata, metadata, metadata, metadata, metadata) #1155 156attributes #0 = { nounwind readnone uwtable }157attributes #1 = { nounwind readnone speculatable }158 159!llvm.dbg.cu = !{!2}160!llvm.module.flags = !{!12, !13, !14, !15, !1000}161!llvm.ident = !{!16}162 163!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())164!1 = distinct !DIGlobalVariable(name: "S", scope: !2, file: !3, line: 4, type: !8, isLocal: false, isDefinition: true)165!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 327229) (llvm/trunk 327239)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !7)166!3 = !DIFile(filename: "sdag-dangling-dbgvalue.c", directory: "/repo/uabbpet/llvm-master")167!4 = !{}168!5 = !{!6}169!6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)170!7 = !{!0}171!8 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "SS", file: !3, line: 1, size: 64, elements: !9)172!9 = !{!10, !11}173!10 = !DIDerivedType(tag: DW_TAG_member, name: "a", scope: !8, file: !3, line: 2, baseType: !6, size: 32)174!11 = !DIDerivedType(tag: DW_TAG_member, name: "b", scope: !8, file: !3, line: 3, baseType: !6, size: 32, offset: 32)175!12 = !{i32 2, !"Dwarf Version", i32 2}176!13 = !{i32 2, !"Debug Info Version", i32 3}177!14 = !{i32 1, !"wchar_size", i32 4}178!15 = !{i32 7, !"PIC Level", i32 2}179!16 = !{!"clang version 7.0.0 (trunk 327229) (llvm/trunk 327239)"}180!17 = distinct !DISubprogram(name: "test1", scope: !3, file: !3, line: 6, type: !18, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: true, unit: !2, retainedNodes: !19)181!18 = !DISubroutineType(types: !5)182!19 = !{!20, !22}183!20 = !DILocalVariable(name: "foo1", scope: !17, file: !3, line: 7, type: !21)184!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)185!22 = !DILocalVariable(name: "bar1", scope: !17, file: !3, line: 8, type: !21)186!23 = !DILocation(line: 7, column: 14, scope: !17)187!24 = !DILocation(line: 8, column: 14, scope: !17)188!25 = !DILocation(line: 9, column: 3, scope: !17)189!26 = distinct !DISubprogram(name: "test2", scope: !3, file: !3, line: 12, type: !18, isLocal: false, isDefinition: true, scopeLine: 12, isOptimized: true, unit: !2, retainedNodes: !27)190!27 = !{!28, !29}191!28 = !DILocalVariable(name: "foo2", scope: !26, file: !3, line: 13, type: !21)192!29 = !DILocalVariable(name: "bar2", scope: !26, file: !3, line: 14, type: !21)193!30 = !DILocation(line: 13, column: 14, scope: !26)194!31 = !DILocation(line: 14, column: 14, scope: !26)195!32 = !DILocation(line: 15, column: 3, scope: !26)196!33 = distinct !DISubprogram(name: "test3", scope: !3, file: !3, line: 18, type: !18, isLocal: false, isDefinition: true, scopeLine: 18, isOptimized: true, unit: !2, retainedNodes: !34)197!34 = !{!35, !36}198!35 = !DILocalVariable(name: "bar3", scope: !33, file: !3, line: 19, type: !21)199!36 = !DILocalVariable(name: "foo3", scope: !33, file: !3, line: 20, type: !21)200!37 = !DILocation(line: 19, column: 14, scope: !33)201!38 = !DILocation(line: 20, column: 14, scope: !33)202!39 = !DILocation(line: 21, column: 3, scope: !33)203!40 = distinct !DISubprogram(name: "test4", scope: !3, file: !3, line: 24, type: !18, isLocal: false, isDefinition: true, scopeLine: 24, isOptimized: true, unit: !2, retainedNodes: !41)204!41 = !{!42, !43}205!42 = !DILocalVariable(name: "foo4", scope: !40, file: !3, line: 25, type: !21)206!43 = !DILocalVariable(name: "bar4", scope: !40, file: !3, line: 26, type: !21)207!44 = !DILocation(line: 25, column: 14, scope: !40)208!45 = !DILocation(line: 26, column: 14, scope: !40)209!46 = !DILocation(line: 28, column: 3, scope: !40)210!47 = distinct !DISubprogram(name: "test5", scope: !3, file: !3, line: 31, type: !18, isLocal: false, isDefinition: true, scopeLine: 31, isOptimized: true, unit: !2, retainedNodes: !48)211!48 = !{!49, !50}212!49 = !DILocalVariable(name: "bar5", scope: !47, file: !3, line: 32, type: !21)213!50 = !DILocalVariable(name: "foo5", scope: !47, file: !3, line: 33, type: !21)214!51 = !DILocation(line: 32, column: 14, scope: !47)215!52 = !DILocation(line: 33, column: 14, scope: !47)216!53 = !DILocation(line: 35, column: 3, scope: !47)217!54 = distinct !DIAssignID()218!1000 = !{i32 7, !"debug-info-assignment-tracking", i1 true}219