2016-08-17 01:12:50 +08:00
; REQUIRES: object-emission
; RUN: llc -O2 -filetype=obj -mtriple=x86_64-unknown-linux-gnu < %s \
2017-09-12 06:59:45 +08:00
; RUN: | llvm-dwarfdump -debug-line - | FileCheck %s
2016-08-17 01:12:50 +08:00
;
; Generated with clang -O2 -g from
;
; typedef float __m128 __attribute__((__vector_size__(16)));
;
; extern __m128 doSomething(__m128, __m128);
;
;
; __m128 foo(__m128 X) { // line 6
; const __m128 V = {0.5f, 0.5f, 0.5f, 0.5f}; // line 7
; __m128 Sub = X - V; // line 8
; __m128 Add = X + V; // line 9
;
; __m128 Result = doSomething(Add, Sub); // line 11
;
; return V - Result; // line 13
; }
;
;
; We want to see line 13 after line 11 without any other line in between.
; CHECK: 0x{{[0-9a-f]*}} 11
; CHECK-NOT: 0x{{[0-9a-f]*}} 8
; CHECK-NOT: 0x{{[0-9a-f]*}} 9
; CHECK: 0x{{[0-9a-f]*}} 13
; CHECK-NOT: 0x{{[0-9a-f]*}} 8
; CHECK-NOT: 0x{{[0-9a-f]*}} 9
; ModuleID = 'test.c'
source_filename = "test.c"
; target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
; target triple = "x86_64-unknown-linux-gnu"
; Function Attrs: nounwind uwtable
define < 4 x float > @foo ( < 4 x float > %X ) local_unnamed_addr #0 !dbg !6 {
entry:
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata < 4 x float > %X , metadata !15 , metadata !21 ) , !dbg !22
tail call void @llvm.dbg.value ( metadata < 4 x float > < float 5.000000e-01 , float 5.000000e-01 , float 5.000000e-01 , float 5.000000e-01 > , metadata !16 , metadata !21 ) , !dbg !23
2016-08-17 01:12:50 +08:00
%sub = fadd < 4 x float > %X , < float -5.000000e-01 , float -5.000000e-01 , float -5.000000e-01 , float -5.000000e-01 > , !dbg !24
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata < 4 x float > %sub , metadata !18 , metadata !21 ) , !dbg !25
2016-08-17 01:12:50 +08:00
%add = fadd < 4 x float > %X , < float 5.000000e-01 , float 5.000000e-01 , float 5.000000e-01 , float 5.000000e-01 > , !dbg !26
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata < 4 x float > %add , metadata !19 , metadata !21 ) , !dbg !27
2016-08-17 01:12:50 +08:00
%call = tail call < 4 x float > @doSomething ( < 4 x float > %add , < 4 x float > %sub ) #3 , !dbg !28
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata < 4 x float > %call , metadata !20 , metadata !21 ) , !dbg !29
2016-08-17 01:12:50 +08:00
%sub1 = fsub < 4 x float > < float 5.000000e-01 , float 5.000000e-01 , float 5.000000e-01 , float 5.000000e-01 > , %call , !dbg !30
ret < 4 x float > %sub1 , !dbg !31
}
declare < 4 x float > @doSomething ( < 4 x float > , < 4 x float > ) local_unnamed_addr #1
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #2
2016-08-17 01:12:50 +08:00
attributes #0 = { nounwind uwtable }
attributes #1 = { nounwind uwtable }
attributes #2 = { nounwind readnone }
attributes #3 = { nounwind }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 }
!llvm.ident = ! { !5 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !1 , producer: "clang version 4.0.0 (trunk 278291)" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "test.c" , directory: "/home/test" )
!2 = ! { }
!3 = ! { i32 2 , !"Dwarf Version" , i32 4 }
!4 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!5 = ! { !"clang version 4.0.0 (trunk 278291)" }
[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
!6 = distinct !DISubprogram ( name: "foo" , scope: !1 , file: !1 , line: 6 , type: !7 , isLocal: false , isDefinition: true , scopeLine: 6 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !0 , retainedNodes: !14 )
2016-08-17 01:12:50 +08:00
!7 = !DISubroutineType ( types: !8 )
!8 = ! { !9 , !9 }
!9 = !DIDerivedType ( tag: D W _ T A G _ t y p e d e f , name: "__m128" , file: !1 , line: 1 , baseType: !10 )
!10 = !DICompositeType ( tag: D W _ T A G _ a r r a y _ type , baseType: !11 , size: 128 , align: 128 , flags: D I F l a g V e c t or , elements: !12 )
!11 = !DIBasicType ( name: "float" , size: 32 , align: 32 , encoding: D W _ A T E _ float )
!12 = ! { !13 }
!13 = !DISubrange ( count: 4 )
!14 = ! { !15 , !16 , !18 , !19 , !20 }
!15 = !DILocalVariable ( name: "X" , arg: 1 , scope: !6 , file: !1 , line: 6 , type: !9 )
!16 = !DILocalVariable ( name: "V" , scope: !6 , file: !1 , line: 7 , type: !17 )
!17 = !DIDerivedType ( tag: D W _ T A G _ c o n s t _ type , baseType: !9 )
!18 = !DILocalVariable ( name: "Sub" , scope: !6 , file: !1 , line: 8 , type: !9 )
!19 = !DILocalVariable ( name: "Add" , scope: !6 , file: !1 , line: 9 , type: !9 )
!20 = !DILocalVariable ( name: "Result" , scope: !6 , file: !1 , line: 11 , type: !9 )
!21 = !DIExpression ( )
!22 = !DILocation ( line: 6 , column: 19 , scope: !6 )
!23 = !DILocation ( line: 7 , column: 16 , scope: !6 )
!24 = !DILocation ( line: 8 , column: 18 , scope: !6 )
!25 = !DILocation ( line: 8 , column: 10 , scope: !6 )
!26 = !DILocation ( line: 9 , column: 18 , scope: !6 )
!27 = !DILocation ( line: 9 , column: 10 , scope: !6 )
!28 = !DILocation ( line: 11 , column: 19 , scope: !6 )
!29 = !DILocation ( line: 11 , column: 10 , scope: !6 )
!30 = !DILocation ( line: 13 , column: 12 , scope: !6 )
!31 = !DILocation ( line: 13 , column: 3 , scope: !6 )