1; RUN: opt < %s -passes=asan -asan-use-after-return=never -asan-use-stack-safety=0 -S | FileCheck %s 2 3; Checks that llvm.dbg.declare instructions are updated 4; accordingly as we merge allocas. 5 6target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128" 7target triple = "x86_64-unknown-linux-gnu" 8 9@G = global [32 x i8] zeroinitializer, align 32, !dbg !0, !type !6 10; CHECK: @G = global { [32 x i8], [32 x i8] } zeroinitializer{{(, comdat)?}}, align 32, !dbg !0, !type [[TYPE:![0-9]+]] 11 12define i32 @_Z3zzzi(i32 %p) nounwind uwtable sanitize_address !dbg !12 { 13entry: 14 %p.addr = alloca i32, align 4 15 %r = alloca i32, align 4 16 store volatile i32 %p, ptr %p.addr, align 4 17 call void @llvm.dbg.declare(metadata ptr %p.addr, metadata !17, metadata !DIExpression()), !dbg !18 18 call void @llvm.dbg.declare(metadata ptr %r, metadata !19, metadata !DIExpression()), !dbg !21 19 %0 = load i32, ptr %p.addr, align 4, !dbg !21 20 %add = add nsw i32 %0, 1, !dbg !21 21 store volatile i32 %add, ptr %r, align 4, !dbg !21 22 %1 = load i32, ptr %r, align 4, !dbg !22 23 ret i32 %1, !dbg !22 24} 25 26; CHECK: define i32 @_Z3zzzi 27; CHECK: [[MyAlloca:%.*]] = alloca i8, i64 64 28; Note: these dbg.declares used to contain `ptrtoint` operands. The instruction 29; selector would then decline to put the variable in the MachineFunction side 30; table. Check that the dbg.declares have `alloca` operands. 31; CHECK: #dbg_declare(ptr [[MyAlloca]], ![[ARG_ID:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 32), 32; CHECK: #dbg_declare(ptr [[MyAlloca]], ![[VAR_ID:[0-9]+]], !DIExpression(DW_OP_plus_uconst, 48), 33 34declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone 35 36!llvm.dbg.cu = !{!7} 37!llvm.module.flags = !{!24} 38 39!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 40!1 = distinct !DIGlobalVariable(name: "G", type: !2, isLocal: false, isDefinition: true) 41!2 = !DICompositeType(tag: DW_TAG_array_type, baseType: !3, size: 256, elements: !4) 42!3 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char) 43!4 = !{!5} 44!5 = !DISubrange(count: 32) 45!6 = !{i64 0, !"G"} 46; CHECK: [[TYPE]] = !{i64 0, !"G"} 47 48!7 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 169314)", isOptimized: true, emissionKind: FullDebug, file: !23, enums: !8, retainedTypes: !8, globals: !8) 49!8 = !{} 50!12 = distinct !DISubprogram(name: "zzz", linkageName: "_Z3zzzi", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !7, scopeLine: 1, file: !23, scope: !13, type: !14, retainedNodes: !8) 51!13 = !DIFile(filename: "a.cc", directory: "/usr/local/google/llvm_cmake_clang/tmp/debuginfo") 52!14 = !DISubroutineType(types: !15) 53!15 = !{!16, !16} 54!16 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed) 55!17 = !DILocalVariable(name: "p", line: 1, arg: 1, scope: !12, file: !13, type: !16) 56!18 = !DILocation(line: 1, scope: !12) 57!19 = !DILocalVariable(name: "r", line: 2, scope: !20, file: !13, type: !16) 58 59; Verify that debug descriptors for argument and local variable will be replaced 60; with descriptors that end with OpDeref (encoded as 2). 61; CHECK: ![[ARG_ID]] = !DILocalVariable(name: "p", arg: 1,{{.*}} line: 1 62; CHECK: ![[VAR_ID]] = !DILocalVariable(name: "r",{{.*}} line: 2 63; Verify that there are no more variable descriptors. 64; CHECK-NOT: !DILocalVariable(tag: DW_TAG_arg_variable 65; CHECK-NOT: !DILocalVariable(tag: DW_TAG_auto_variable 66 67 68!20 = distinct !DILexicalBlock(line: 1, column: 0, file: !23, scope: !12) 69!21 = !DILocation(line: 2, scope: !20) 70!22 = !DILocation(line: 3, scope: !20) 71!23 = !DIFile(filename: "a.cc", directory: "/usr/local/google/llvm_cmake_clang/tmp/debuginfo") 72!24 = !{i32 1, !"Debug Info Version", i32 3} 73