2017-09-06 04:14:58 +08:00
; RUN: llc < %s | FileCheck %s
; FIXME: fastisel screws up the order here.
; RUNX: llc -O0 < %s | FileCheck %s
; Source to regenerate:
; $ clang --target=x86_64-windows-msvc -S annotation.c -g -gcodeview -o t.ll \
; -emit-llvm -O1 -Xclang -disable-llvm-passes -fms-extensions
; void g(void);
; void f(void) {
; g();
; __annotation(L"a1", L"a2");
; g();
; }
; ModuleID = 'annotation.c'
source_filename = "annotation.c"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.0.24215"
; Function Attrs: nounwind uwtable
define void @f ( ) #0 !dbg !8 {
entry:
call void @g ( ) , !dbg !11
call void @llvm.codeview.annotation ( metadata !12 ) , !dbg !13
call void @g ( ) , !dbg !14
ret void , !dbg !15
}
; CHECK-LABEL: f: # @f
; CHECK: callq g
; CHECK: .Lannotation0:
; CHECK: callq g
; CHECK: retq
; CHECK-LABEL: .short 4423 # Record kind: S_GPROC32_ID
; CHECK: .short 4121 # Record kind: S_ANNOTATION
; CHECK-NEXT: .secrel32 .Lannotation0
; CHECK-NEXT: .secidx .Lannotation0
; CHECK-NEXT: .short 2
; CHECK-NEXT: .asciz "a1"
; CHECK-NEXT: .asciz "a2"
; CHECK-LABEL: .short 4431 # Record kind: S_PROC_ID_END
declare void @g ( ) #1
; Function Attrs: nounwind
declare void @llvm.codeview.annotation ( metadata ) #2
attributes #0 = { nounwind uwtable "correctly-rounded-divide-sqrt-fp-math" = "false" "disable-tail-calls" = "false" "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "false" "no-infs-fp-math" = "false" "no-jump-tables" = "false" "no-nans-fp-math" = "false" "no-signed-zeros-fp-math" = "false" "no-trapping-math" = "false" "stack-protector-buffer-size" = "8" "target-cpu" = "x86-64" "target-features" = "+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
attributes #1 = { "correctly-rounded-divide-sqrt-fp-math" = "false" "disable-tail-calls" = "false" "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "false" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "no-signed-zeros-fp-math" = "false" "no-trapping-math" = "false" "stack-protector-buffer-size" = "8" "target-cpu" = "x86-64" "target-features" = "+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
attributes #2 = { nounwind }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !3 , !4 , !5 , !6 }
!llvm.ident = ! { !7 }
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C 99 , file: !1 , producer: "clang version 6.0.0 " , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
!1 = !DIFile ( filename: "annotation.c" , directory: "C:\5Csrc\5Cllvm-project\5Cbuild" , checksumkind: C S K _ M D 5 , checksum: "51164221112d8a5baa55a995027e4ba5" )
!2 = ! { }
!3 = ! { i32 2 , !"CodeView" , i32 1 }
!4 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!5 = ! { i32 1 , !"wchar_size" , i32 2 }
!6 = ! { i32 7 , !"PIC Level" , i32 2 }
!7 = ! { !"clang version 6.0.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
!8 = distinct !DISubprogram ( name: "f" , scope: !1 , file: !1 , line: 2 , type: !9 , isLocal: false , isDefinition: true , scopeLine: 2 , flags: D I F l a g P r o t o t y p e d , isOptimized: true , unit: !0 , retainedNodes: !2 )
2017-09-06 04:14:58 +08:00
!9 = !DISubroutineType ( types: !10 )
!10 = ! { null }
!11 = !DILocation ( line: 3 , column: 3 , scope: !8 )
!12 = ! { !"a1" , !"a2" }
!13 = !DILocation ( line: 4 , column: 3 , scope: !8 )
!14 = !DILocation ( line: 5 , column: 3 , scope: !8 )
!15 = !DILocation ( line: 6 , column: 1 , scope: !8 )