2014-08-30 06:44:07 +08:00
; RUN: llc -mtriple=x86_64-apple-darwin %s -o %t -filetype=obj
2017-09-12 06:59:45 +08:00
; RUN: llvm-dwarfdump -debug-info %t | FileCheck %s
2014-08-30 06:44:07 +08:00
;
; Test the DW_AT_accessibility DWARF attribute.
;
;
; Regenerate me:
; clang++ -g tools/clang/test/CodeGenCXX/debug-info-access.cpp -S -emit-llvm -o -
;
; struct A {
; void pub_default();
; static int pub_default_static;
; };
;
; class B : public A {
; public:
; void pub();
; static int public_static;
; protected:
; void prot();
; private:
; void priv_default();
; };
;
; union U {
; void union_pub_default();
; private:
; int union_priv;
; };
;
; void free() {}
;
; A a;
; B b;
; U u;
; CHECK: DW_TAG_member
; CHECK: DW_AT_name {{.*}}"pub_default_static")
; CHECK-NOT: DW_AT_accessibility
; CHECK-NOT: DW_TAG
;
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}}"pub_default")
; CHECK-NOT: DW_AT_accessibility
; CHECK: DW_TAG
;
; CHECK: DW_TAG_inheritance
; CHECK-NOT: DW_TAG
2014-09-05 03:39:20 +08:00
; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public)
2014-08-30 06:44:07 +08:00
;
; CHECK: DW_TAG_member
; CHECK: DW_AT_name {{.*}}"public_static")
; CHECK-NOT: DW_TAG
2014-09-05 03:39:20 +08:00
; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public)
2014-08-30 06:44:07 +08:00
;
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}}"pub")
; CHECK-NOT: DW_TAG
2014-09-05 03:39:20 +08:00
; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_public)
2014-08-30 06:44:07 +08:00
;
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}}"prot")
; CHECK-NOT: DW_TAG
2014-09-05 03:39:20 +08:00
; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_protected)
2014-08-30 06:44:07 +08:00
;
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}}"priv_default")
; CHECK-NOT: DW_AT_accessibility
; CHECK: DW_TAG
;
; CHECK: DW_TAG_member
; CHECK: DW_AT_name {{.*}}"union_priv")
; CHECK-NOT: DW_TAG
2014-09-05 03:39:20 +08:00
; CHECK: DW_AT_accessibility {{.*}}(DW_ACCESS_private)
2014-08-30 06:44:07 +08:00
;
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}}"union_pub_default")
; CHECK-NOT: DW_AT_accessibility
; CHECK: DW_TAG
;
; CHECK: DW_TAG_subprogram
; CHECK: DW_AT_name {{.*}}"free")
; CHECK-NOT: DW_AT_accessibility
; CHECK-NOT: DW_TAG
;
; ModuleID = '/llvm/tools/clang/test/CodeGenCXX/debug-info-access.cpp'
2016-12-22 08:45:21 +08:00
source_filename = "test/DebugInfo/X86/debug-info-access.ll"
2014-08-30 06:44:07 +08:00
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-apple-macosx10.10.0"
%struct.A = type { i8 }
%class.B = type { i8 }
%union.U = type { i32 }
2016-12-22 08:45:21 +08:00
@a = global %struct.A zeroinitializer , align 1 , !dbg !0
@b = global %class.B zeroinitializer , align 1 , !dbg !11
@u = global %union.U zeroinitializer , align 4 , !dbg !23
2014-08-30 06:44:07 +08:00
; Function Attrs: nounwind ssp uwtable
2016-12-22 08:45:21 +08:00
define void @_Z4freev ( ) #0 !dbg !39 {
ret void , !dbg !42
2014-08-30 06:44:07 +08:00
}
attributes #0 = { nounwind ssp uwtable }
2016-12-22 08:45:21 +08:00
!llvm.dbg.cu = ! { !32 }
!llvm.module.flags = ! { !36 , !37 }
!llvm.ident = ! { !38 }
2017-08-31 02:06:51 +08:00
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!1 = !DIGlobalVariable ( name: "a" , scope: null , file: !2 , line: 37 , type: !3 , isLocal: false , isDefinition: true )
!2 = !DIFile ( filename: "/llvm/tools/clang/test/CodeGenCXX/debug-info-access.cpp" , directory: "" )
!3 = !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "A" , file: !2 , line: 3 , size: 8 , align: 8 , elements: !4 , identifier: "_ZTS1A" )
!4 = ! { !5 , !7 }
!5 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "pub_default_static" , scope: !3 , file: !2 , line: 7 , baseType: !6 , flags: D I F l a g S t a t i c M e m b e r )
!6 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!7 = !DISubprogram ( name: "pub_default" , linkageName: "_ZN1A11pub_defaultEv" , scope: !3 , file: !2 , line: 5 , type: !8 , isLocal: false , isDefinition: false , scopeLine: 5 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false )
!8 = !DISubroutineType ( types: !9 )
!9 = ! { null , !10 }
!10 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !3 , size: 64 , align: 64 , flags: D I F l a g A r t i f i c i a l | D I F l a g O b j e c t P o i n t e r )
2017-08-31 02:06:51 +08:00
!11 = !DIGlobalVariableExpression ( var: !12 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!12 = !DIGlobalVariable ( name: "b" , scope: null , file: !2 , line: 38 , type: !13 , isLocal: false , isDefinition: true )
!13 = !DICompositeType ( tag: D W _ T A G _ c l a s s _ type , name: "B" , file: !2 , line: 11 , size: 8 , align: 8 , elements: !14 , identifier: "_ZTS1B" )
!14 = ! { !15 , !16 , !17 , !21 , !22 }
!15 = !DIDerivedType ( tag: D W _ T A G _ i n h e r i t a n c e , scope: !13 , baseType: !3 , flags: D I F l a g P u b l i c )
!16 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "public_static" , scope: !13 , file: !2 , line: 16 , baseType: !6 , flags: D I F l a g P u b l i c | D I F l a g S t a t i c M e m b e r )
!17 = !DISubprogram ( name: "pub" , linkageName: "_ZN1B3pubEv" , scope: !13 , file: !2 , line: 14 , type: !18 , isLocal: false , isDefinition: false , scopeLine: 14 , virtualIndex: 6 , flags: D I F l a g P u b l i c | D I F l a g P r o t o t y p e d , isOptimized: false )
!18 = !DISubroutineType ( types: !19 )
!19 = ! { null , !20 }
!20 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !13 , size: 64 , align: 64 , flags: D I F l a g A r t i f i c i a l | D I F l a g O b j e c t P o i n t e r )
!21 = !DISubprogram ( name: "prot" , linkageName: "_ZN1B4protEv" , scope: !13 , file: !2 , line: 19 , type: !18 , isLocal: false , isDefinition: false , scopeLine: 19 , virtualIndex: 6 , flags: D I F l a g P r o t e c t e d | D I F l a g P r o t o t y p e d , isOptimized: false )
!22 = !DISubprogram ( name: "priv_default" , linkageName: "_ZN1B12priv_defaultEv" , scope: !13 , file: !2 , line: 22 , type: !18 , isLocal: false , isDefinition: false , scopeLine: 22 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false )
2017-08-31 02:06:51 +08:00
!23 = !DIGlobalVariableExpression ( var: !24 , expr: !DIExpression ( ) )
2016-12-22 08:45:21 +08:00
!24 = !DIGlobalVariable ( name: "u" , scope: null , file: !2 , line: 39 , type: !25 , isLocal: false , isDefinition: true )
!25 = !DICompositeType ( tag: D W _ T A G _ u n i o n _ type , name: "U" , file: !2 , line: 25 , size: 32 , align: 32 , elements: !26 , identifier: "_ZTS1U" )
!26 = ! { !27 , !28 }
!27 = !DIDerivedType ( tag: D W _ T A G _ m e m b e r , name: "union_priv" , scope: !25 , file: !2 , line: 30 , baseType: !6 , size: 32 , align: 32 , flags: D I F l a g P r i v a t e )
!28 = !DISubprogram ( name: "union_pub_default" , linkageName: "_ZN1U17union_pub_defaultEv" , scope: !25 , file: !2 , line: 27 , type: !29 , isLocal: false , isDefinition: false , scopeLine: 27 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false )
!29 = !DISubroutineType ( types: !30 )
!30 = ! { null , !31 }
!31 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !25 , size: 64 , align: 64 , flags: D I F l a g A r t i f i c i a l | D I F l a g O b j e c t P o i n t e r )
!32 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !2 , producer: "clang version 3.6.0 " , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !33 , retainedTypes: !34 , globals: !35 , imports: !33 )
!33 = ! { }
!34 = ! { !3 , !13 , !25 }
!35 = ! { !0 , !11 , !23 }
!36 = ! { i32 2 , !"Dwarf Version" , i32 2 }
!37 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!38 = ! { !"clang version 3.6.0 " }
[DebugInfo] Add DILabel metadata and intrinsic llvm.dbg.label.
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.
llvm-svn: 331841
2018-05-09 10:40:45 +08:00
!39 = distinct !DISubprogram ( name: "free" , linkageName: "_Z4freev" , scope: !2 , file: !2 , line: 35 , type: !40 , isLocal: false , isDefinition: true , scopeLine: 35 , virtualIndex: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !32 , retainedNodes: !33 )
2016-12-22 08:45:21 +08:00
!40 = !DISubroutineType ( types: !41 )
!41 = ! { null }
!42 = !DILocation ( line: 35 , column: 14 , scope: !39 )
2014-08-30 06:44:07 +08:00