mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 20:51:52 +01:00
f625c157a1
The DWARF specification knows 3 kinds of non-empty simple location descriptions: 1. Register location descriptions - describe a variable in a register - consist of only a DW_OP_reg 2. Memory location descriptions - describe the address of a variable 3. Implicit location descriptions - describe the value of a variable - end with DW_OP_stack_value & friends The existing DwarfExpression code is pretty much ignorant of these restrictions. This used to not matter because we only emitted very short expressions that we happened to get right by accident. This patch makes DwarfExpression aware of the rules defined by the DWARF standard and now chooses the right kind of location description for each expression being emitted. This would have been an NFC commit (for the existing testsuite) if not for the way that clang describes captured block variables. Based on how the previous code in LLVM emitted locations, DW_OP_deref operations that should have come at the end of the expression are put at its beginning. Fixing this means changing the semantics of DIExpression, so this patch bumps the version number of DIExpression and implements a bitcode upgrade. There are two major changes in this patch: I had to fix the semantics of dbg.declare for describing function arguments. After this patch a dbg.declare always takes the *address* of a variable as the first argument, even if the argument is not an alloca. When lowering a DBG_VALUE, the decision of whether to emit a register location description or a memory location description depends on the MachineLocation — register machine locations may get promoted to memory locations based on their DIExpression. (Future) optimization passes that want to salvage implicit debug location for variables may do so by appending a DW_OP_stack_value. For example: DBG_VALUE, [RBP-8] --> DW_OP_fbreg -8 DBG_VALUE, RAX --> DW_OP_reg0 +0 DBG_VALUE, RAX, DIExpression(DW_OP_deref) --> DW_OP_reg0 +0 All testcases that were modified were regenerated from clang. I also added source-based testcases for each of these to the debuginfo-tests repository over the last week to make sure that no synchronized bugs slip in. The debuginfo-tests compile from source and run the debugger. https://bugs.llvm.org/show_bug.cgi?id=32382 <rdar://problem/31205000> Differential Revision: https://reviews.llvm.org/D31439 llvm-svn: 300522
62 lines
3.1 KiB
LLVM
62 lines
3.1 KiB
LLVM
; RUN: opt < %s -asan -asan-module -asan-use-after-return=0 -S | FileCheck %s
|
|
|
|
; Checks that llvm.dbg.declare instructions are updated
|
|
; accordingly as we merge allocas.
|
|
|
|
target 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"
|
|
target triple = "x86_64-unknown-linux-gnu"
|
|
|
|
define i32 @_Z3zzzi(i32 %p) nounwind uwtable sanitize_address !dbg !5 {
|
|
entry:
|
|
%p.addr = alloca i32, align 4
|
|
%r = alloca i32, align 4
|
|
store volatile i32 %p, i32* %p.addr, align 4
|
|
call void @llvm.dbg.declare(metadata i32* %p.addr, metadata !10, metadata !DIExpression()), !dbg !11
|
|
call void @llvm.dbg.declare(metadata i32* %r, metadata !12, metadata !DIExpression()), !dbg !14
|
|
%0 = load i32, i32* %p.addr, align 4, !dbg !14
|
|
%add = add nsw i32 %0, 1, !dbg !14
|
|
store volatile i32 %add, i32* %r, align 4, !dbg !14
|
|
%1 = load i32, i32* %r, align 4, !dbg !15
|
|
ret i32 %1, !dbg !15
|
|
}
|
|
|
|
; CHECK: define i32 @_Z3zzzi
|
|
; CHECK: entry:
|
|
; Verify that llvm.dbg.declare calls are in the entry basic block.
|
|
; CHECK-NOT: %entry
|
|
; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[ARG_ID:[0-9]+]], metadata ![[EMPTY:[0-9]+]])
|
|
; CHECK-NOT: %entry
|
|
; CHECK: call void @llvm.dbg.declare(metadata {{.*}}, metadata ![[VAR_ID:[0-9]+]], metadata ![[EMPTY:[0-9]+]])
|
|
|
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
!llvm.module.flags = !{!17}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.3 (trunk 169314)", isOptimized: true, emissionKind: FullDebug, file: !16, enums: !1, retainedTypes: !1, globals: !1)
|
|
!1 = !{}
|
|
!5 = distinct !DISubprogram(name: "zzz", linkageName: "_Z3zzzi", line: 1, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 1, file: !16, scope: !6, type: !7, variables: !1)
|
|
!6 = !DIFile(filename: "a.cc", directory: "/usr/local/google/llvm_cmake_clang/tmp/debuginfo")
|
|
!7 = !DISubroutineType(types: !8)
|
|
!8 = !{!9, !9}
|
|
!9 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
!10 = !DILocalVariable(name: "p", line: 1, arg: 1, scope: !5, file: !6, type: !9)
|
|
!11 = !DILocation(line: 1, scope: !5)
|
|
!12 = !DILocalVariable(name: "r", line: 2, scope: !13, file: !6, type: !9)
|
|
|
|
; Verify that debug descriptors for argument and local variable will be replaced
|
|
; with descriptors that end with OpDeref (encoded as 2).
|
|
; CHECK: ![[ARG_ID]] = !DILocalVariable(name: "p", arg: 1,{{.*}} line: 1
|
|
; CHECK: ![[EMPTY]] = !DIExpression()
|
|
; CHECK: ![[VAR_ID]] = !DILocalVariable(name: "r",{{.*}} line: 2
|
|
; Verify that there are no more variable descriptors.
|
|
; CHECK-NOT: !DILocalVariable(tag: DW_TAG_arg_variable
|
|
; CHECK-NOT: !DILocalVariable(tag: DW_TAG_auto_variable
|
|
|
|
|
|
!13 = distinct !DILexicalBlock(line: 1, column: 0, file: !16, scope: !5)
|
|
!14 = !DILocation(line: 2, scope: !13)
|
|
!15 = !DILocation(line: 3, scope: !13)
|
|
!16 = !DIFile(filename: "a.cc", directory: "/usr/local/google/llvm_cmake_clang/tmp/debuginfo")
|
|
!17 = !{i32 1, !"Debug Info Version", i32 3}
|