brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.1 KiB · 5e06b09 Raw
78 lines · plain
1; RUN: opt < %s -passes=asan -asan-use-after-return=never -S | \2; RUN:   llc -O0 -filetype=obj - -o - | \3; RUN:   llvm-dwarfdump - | FileCheck %s4 5; For this test case, ASan used to produce IR which resulted in the following6; DWARF (at -O0):7;8;   DW_TAG_subprogram9;     DW_AT_low_pc    (0x0000000000000000)10;     DW_AT_high_pc   (0x00000000000000f1)11;12;     DW_TAG_variable13;       DW_AT_location        (0x0000000014;         [0x0000000000000014,  0x000000000000006d): DW_OP_breg0 RAX+3215;         [0x000000000000006d,  0x00000000000000a4): DW_OP_breg7 RSP+16, DW_OP_deref, DW_OP_plus_uconst 0x2016;         [0x00000000000000a6,  0x00000000000000ef): DW_OP_breg7 RSP+16, DW_OP_deref, DW_OP_plus_uconst 0x20)17;18; The DWARF produced for the original ObjC code that motivated this test case19; was actually not as nice! In that example, the location list ranges didn't20; intersect with the ranges of the parent lexical scope. But recreating that21; exactly requires playing tricks to get LiveDebugValue's lexical dominance22; check to kill a variable range early, and it isn't strictly necessary to show23; the problem here.24;25; The problem is that we shouldn't get a location list at all. The instruction26; selector should recognize that we have an "alloca" in the entry block, and27; just make the fixed location available in the whole function. We now produce28; the correct DWARF, namely:29 30; CHECK: DW_TAG_variable31; CHECK-NEXT:  DW_AT_location (DW_OP_breg7 RSP+32, DW_OP_plus_uconst 0x20)32 33target triple = "x86_64-apple-macosx10.10.0"34 35declare void @escape(ptr)36 37; Function Attrs: sanitize_address38define ptr @foo(i1 %cond) #0 !dbg !6 {39entry:40  %a1 = alloca ptr, !dbg !1241  call void @escape(ptr %a1), !dbg !1342  br i1 %cond, label %l1, label %l2, !dbg !1443 44l1:                                               ; preds = %entry45  ret ptr null, !dbg !1546 47l2:                                               ; preds = %entry48  call void @llvm.dbg.declare(metadata ptr %a1, metadata !11, metadata !DIExpression()), !dbg !1649  %p = load ptr, ptr %a1, !dbg !1650  ret ptr %p, !dbg !1751}52 53declare void @llvm.dbg.declare(metadata, metadata, metadata)54 55attributes #0 = { sanitize_address }56 57!llvm.dbg.cu = !{!0}58!llvm.debugify = !{!3, !4}59!llvm.module.flags = !{!5}60 61!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)62!1 = !DIFile(filename: "redu.ll", directory: "/")63!2 = !{}64!3 = !{i32 6}65!4 = !{i32 2}66!5 = !{i32 2, !"Debug Info Version", i32 3}67!6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)68!7 = !DISubroutineType(types: !2)69!8 = !{!11}70!10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)71!11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 5, type: !10)72!12 = !DILocation(line: 1, column: 1, scope: !6)73!13 = !DILocation(line: 2, column: 1, scope: !6)74!14 = !DILocation(line: 3, column: 1, scope: !6)75!15 = !DILocation(line: 4, column: 1, scope: !6)76!16 = !DILocation(line: 5, column: 1, scope: !6)77!17 = !DILocation(line: 6, column: 1, scope: !6)78