mirror of
https://github.com/RPCS3/llvm.git
synced 2025-05-16 02:16:23 +00:00

In order to set breakpoints on labels and list source code around labels, we need collect debug information for labels, i.e., label name, the function label belong, line number in the file, and the address label located. In order to keep these information in LLVM IR and to allow backend to generate debug information correctly. We create a new kind of metadata for labels, DILabel. The format of DILabel is !DILabel(scope: !1, name: "foo", file: !2, line: 3) We hope to keep debug information as much as possible even the code is optimized. So, we create a new kind of intrinsic for label metadata to avoid the metadata is eliminated with basic block. The intrinsic will keep existing if we keep it from optimized out. The format of the intrinsic is llvm.dbg.label(metadata !1) It has only one argument, that is the DILabel metadata. The intrinsic will follow the label immediately. Backend could get the label metadata through the intrinsic's parameter. We also create DIBuilder API for labels to be used by Frontend. Frontend could use createLabel() to allocate DILabel objects, and use insertLabel() to insert llvm.dbg.label intrinsic in LLVM IR. Differential Revision: https://reviews.llvm.org/D45024 Patch by Hsiangkai Wang. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@331841 91177308-0d34-0410-b5e6-96231b3b80d8
111 lines
4.2 KiB
LLVM
111 lines
4.2 KiB
LLVM
; REQUIRES: default_triple, object-emission
|
|
;
|
|
; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - \
|
|
; RUN: | %llc_dwarf -dwarf-linkage-names=All -filetype=obj -O0 \
|
|
; RUN: | llvm-dwarfdump -v -debug-info - \
|
|
; RUN: | FileCheck %s
|
|
; RUN: llvm-link %p/type-unique-odr-b.ll %s -S -o - \
|
|
; RUN: | %llc_dwarf -dwarf-linkage-names=All -filetype=obj -O0 \
|
|
; RUN: | llvm-dwarfdump -v -debug-info - \
|
|
; RUN: | FileCheck %s
|
|
;
|
|
; Test ODR-based type uniquing for C++ class members.
|
|
; rdar://problem/15851313.
|
|
;
|
|
; $ cat -n type-unique-odr-a.cpp
|
|
; 1 class A {
|
|
; 2 int data;
|
|
; 3 protected:
|
|
; 4 void getFoo();
|
|
; 5 };
|
|
; 6
|
|
; 7 static void bar() {
|
|
; 8 A a;
|
|
; 9 }
|
|
; 10
|
|
; 11 void baz() { bar(); }
|
|
;; #include "ab.h"
|
|
; foo_t bar() {
|
|
; return A().getFoo();
|
|
; }
|
|
;
|
|
; CHECK: DW_TAG_class_type
|
|
; CHECK-NEXT: DW_AT_name {{.*}} "A"
|
|
; CHECK-NOT: DW_TAG
|
|
; CHECK: DW_TAG_member
|
|
; CHECK-NEXT: DW_AT_name {{.*}} "data"
|
|
; CHECK-NOT: DW_TAG
|
|
; CHECK: DW_TAG_subprogram
|
|
; CHECK-NOT: DW_TAG
|
|
; CHECK: DW_AT_linkage_name {{.*}} "_ZN1A6getFooEv"
|
|
; CHECK-NOT: DW_TAG
|
|
; CHECK: DW_AT_name {{.*}} "getFoo"
|
|
|
|
; Ensure that there aren't any other subprograms in class A.
|
|
; CHECK-NOT: DW_TAG
|
|
; CHECK: DW_TAG_formal_parameter
|
|
; CHECK-NOT: DW_TAG
|
|
; CHECK: NULL
|
|
; CHECK-NOT: DW_TAG
|
|
; CHECK: NULL
|
|
; CHECK-NOT: DW_TAG
|
|
; CHECK: DW_TAG_base_type
|
|
|
|
; Ensure that getFoo and A are only emitted once.
|
|
; CHECK-NOT: AT_name{{.*(getFoo)|("A")}}
|
|
|
|
; ModuleID = 'type-unique-odr-a.cpp'
|
|
|
|
%class.A = type { i32 }
|
|
|
|
; Function Attrs: nounwind
|
|
define void @_Z3bazv() #0 !dbg !15 {
|
|
entry:
|
|
call void @_ZL3barv(), !dbg !23
|
|
ret void, !dbg !23
|
|
}
|
|
|
|
; Function Attrs: nounwind
|
|
define internal void @_ZL3barv() #0 !dbg !19 {
|
|
entry:
|
|
%a = alloca %class.A, align 4
|
|
call void @llvm.dbg.declare(metadata %class.A* %a, metadata !24, metadata !DIExpression()), !dbg !25
|
|
ret void, !dbg !26
|
|
}
|
|
|
|
; Function Attrs: nounwind readnone
|
|
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
|
|
|
|
attributes #0 = { nounwind }
|
|
attributes #1 = { nounwind readnone }
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
!llvm.module.flags = !{!20, !21}
|
|
!llvm.ident = !{!22}
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.5.0 ", isOptimized: false, emissionKind: FullDebug, file: !1, enums: !2, retainedTypes: !3, globals: !2, imports: !2)
|
|
!1 = !DIFile(filename: "<unknown>", directory: "")
|
|
!2 = !{}
|
|
!3 = !{!4}
|
|
!4 = !DICompositeType(tag: DW_TAG_class_type, name: "A", line: 1, size: 32, align: 32, file: !5, elements: !6, identifier: "_ZTS1A")
|
|
!5 = !DIFile(filename: "type-unique-odr-a.cpp", directory: "")
|
|
!6 = !{!7, !9}
|
|
!7 = !DIDerivedType(tag: DW_TAG_member, name: "data", line: 2, size: 32, align: 32, flags: DIFlagPrivate, file: !5, scope: !4, baseType: !8)
|
|
!8 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
|
|
!9 = !DISubprogram(name: "getFoo", linkageName: "_ZN1A6getFooEv", line: 4, isLocal: false, isDefinition: false, virtualIndex: 6, flags: DIFlagProtected | DIFlagPrototyped, isOptimized: false, scopeLine: 4, file: !5, scope: !4, type: !10)
|
|
!10 = !DISubroutineType(types: !11)
|
|
!11 = !{null, !12}
|
|
!12 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, flags: DIFlagArtificial | DIFlagObjectPointer, baseType: !4)
|
|
!15 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", line: 11, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 11, file: !5, scope: !16, type: !17, retainedNodes: !2)
|
|
!16 = !DIFile(filename: "type-unique-odr-a.cpp", directory: "")
|
|
!17 = !DISubroutineType(types: !18)
|
|
!18 = !{null}
|
|
!19 = distinct !DISubprogram(name: "bar", linkageName: "_ZL3barv", line: 7, isLocal: true, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: false, unit: !0, scopeLine: 7, file: !5, scope: !16, type: !17, retainedNodes: !2)
|
|
!20 = !{i32 2, !"Dwarf Version", i32 4}
|
|
!21 = !{i32 1, !"Debug Info Version", i32 3}
|
|
!22 = !{!"clang version 3.5.0 "}
|
|
!23 = !DILocation(line: 11, scope: !15)
|
|
!24 = !DILocalVariable(name: "a", line: 8, scope: !19, file: !16, type: !4)
|
|
!25 = !DILocation(line: 8, scope: !19)
|
|
!26 = !DILocation(line: 9, scope: !19)
|