1 ; RUN: opt < %s -asan -asan-module -asan-use-after-return=never -S -enable-new-pm=0 | \
2 ; RUN: llc -O0 -filetype=obj - -o - | \
3 ; RUN: llvm-dwarfdump - | FileCheck %s
4 ; RUN: opt < %s -passes=asan-pipeline -asan-use-after-return=never -S | \
5 ; RUN: llc -O0 -filetype=obj - -o - | \
6 ; RUN: llvm-dwarfdump - | FileCheck %s
8 ; For this test case, ASan used to produce IR which resulted in the following
12 ; DW_AT_low_pc (0x0000000000000000)
13 ; DW_AT_high_pc (0x00000000000000f1)
16 ; DW_AT_location (0x00000000
17 ; [0x0000000000000014, 0x000000000000006d): DW_OP_breg0 RAX+32
18 ; [0x000000000000006d, 0x00000000000000a4): DW_OP_breg7 RSP+16, DW_OP_deref, DW_OP_plus_uconst 0x20
19 ; [0x00000000000000a6, 0x00000000000000ef): DW_OP_breg7 RSP+16, DW_OP_deref, DW_OP_plus_uconst 0x20)
21 ; The DWARF produced for the original ObjC code that motivated this test case
22 ; was actually not as nice! In that example, the location list ranges didn't
23 ; intersect with the ranges of the parent lexical scope. But recreating that
24 ; exactly requires playing tricks to get LiveDebugValue's lexical dominance
25 ; check to kill a variable range early, and it isn't strictly necessary to show
28 ; The problem is that we shouldn't get a location list at all. The instruction
29 ; selector should recognize that we have an "alloca" in the entry block, and
30 ; just make the fixed location available in the whole function. We now produce
31 ; the correct DWARF, namely:
33 ; CHECK: DW_TAG_variable
34 ; CHECK-NEXT: DW_AT_location (DW_OP_breg7 RSP+32, DW_OP_plus_uconst 0x20)
36 target triple = "x86_64-apple-macosx10.10.0"
38 declare void @escape(i8**)
40 ; Function Attrs: sanitize_address
41 define i8* @foo(i1 %cond) #0 !dbg !6 {
43 %a1 = alloca i8*, !dbg !12
44 call void @escape(i8** %a1), !dbg !13
45 br i1 %cond, label %l1, label %l2, !dbg !14
48 ret i8* null, !dbg !15
51 call void @llvm.dbg.declare(metadata i8** %a1, metadata !11, metadata !DIExpression()), !dbg !16
52 %p = load i8*, i8** %a1, !dbg !16
56 declare void @llvm.dbg.declare(metadata, metadata, metadata)
58 attributes #0 = { sanitize_address }
61 !llvm.debugify = !{!3, !4}
62 !llvm.module.flags = !{!5}
64 !0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
65 !1 = !DIFile(filename: "redu.ll", directory: "/")
69 !5 = !{i32 2, !"Debug Info Version", i32 3}
70 !6 = distinct !DISubprogram(name: "foo", linkageName: "foo", scope: null, file: !1, line: 1, type: !7, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !8)
71 !7 = !DISubroutineType(types: !2)
73 !10 = !DIBasicType(name: "ty64", size: 64, encoding: DW_ATE_unsigned)
74 !11 = !DILocalVariable(name: "2", scope: !6, file: !1, line: 5, type: !10)
75 !12 = !DILocation(line: 1, column: 1, scope: !6)
76 !13 = !DILocation(line: 2, column: 1, scope: !6)
77 !14 = !DILocation(line: 3, column: 1, scope: !6)
78 !15 = !DILocation(line: 4, column: 1, scope: !6)
79 !16 = !DILocation(line: 5, column: 1, scope: !6)
80 !17 = !DILocation(line: 6, column: 1, scope: !6)