2019-05-01 13:27:20 +08:00
; RUN: llc -mtriple=x86_64-windows-msvc < %s -filetype=obj | llvm-readobj --codeview - | FileCheck %s --check-prefix=OBJ
2016-02-17 05:14:51 +08:00
; This LL file was generated by running 'clang -g -gcodeview' on the
; following code:
; void useint(int);
; void constant_var() {
; int x = 42;
; useint(x);
; useint(x);
; }
; FIXME: Find a way to describe variables optimized to constants.
2017-07-12 07:41:41 +08:00
; OBJ: {{.*}}Proc{{.*}}Sym {
2016-02-17 05:14:51 +08:00
; OBJ: DisplayName: constant_var
; OBJ: }
2017-07-12 07:41:41 +08:00
; OBJ: LocalSym {
; OBJ-NEXT: Kind:
2016-02-17 05:14:51 +08:00
; OBJ-NEXT: Type: int (0x74)
; OBJ-NEXT: Flags [ (0x100)
; OBJ-NEXT: IsOptimizedOut (0x100)
; OBJ-NEXT: ]
; OBJ-NEXT: VarName: x
; OBJ-NEXT: }
; OBJ-NOT: DefRange
; OBJ: ProcEnd
; ModuleID = 't.cpp'
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc18.0.0"
; Function Attrs: nounwind uwtable
define void @"\01?constant_var@@YAXXZ" ( ) #0 !dbg !4 {
entry:
2017-07-29 04:21:02 +08:00
tail call void @llvm.dbg.value ( metadata i32 42 , metadata !8 , metadata !14 ) , !dbg !15
2016-02-17 05:14:51 +08:00
tail call void @"\01?useint@@YAXH@Z" ( i32 42 ) #3 , !dbg !16
tail call void @"\01?useint@@YAXH@Z" ( i32 42 ) #3 , !dbg !17
ret void , !dbg !18
}
declare void @"\01?useint@@YAXH@Z" ( i32 ) #1
; Function Attrs: nounwind readnone
2017-07-29 04:21:02 +08:00
declare void @llvm.dbg.value ( metadata , metadata , metadata ) #2
2016-02-17 05:14:51 +08:00
attributes #0 = { nounwind uwtable "disable-tail-calls" = "false" "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "false" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "stack-protector-buffer-size" = "8" "target-cpu" = "x86-64" "target-features" = "+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
attributes #1 = { "disable-tail-calls" = "false" "less-precise-fpmad" = "false" "no-frame-pointer-elim" = "false" "no-infs-fp-math" = "false" "no-nans-fp-math" = "false" "stack-protector-buffer-size" = "8" "target-cpu" = "x86-64" "target-features" = "+fxsr,+mmx,+sse,+sse2" "unsafe-fp-math" = "false" "use-soft-float" = "false" }
attributes #2 = { nounwind readnone }
attributes #3 = { nounwind }
!llvm.dbg.cu = ! { !0 }
!llvm.module.flags = ! { !10 , !11 , !12 }
!llvm.ident = ! { !13 }
2016-04-15 23:57:41 +08:00
!0 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !1 , producer: "clang version 3.9.0 (trunk 260957)" , isOptimized: true , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !2 )
2016-02-17 05:14:51 +08:00
!1 = !DIFile ( filename: "t.cpp" , directory: "D:\5Csrc\5Cllvm\5Cbuild" )
!2 = ! { }
[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
!4 = distinct !DISubprogram ( name: "constant_var" , linkageName: "\01?constant_var@@YAXXZ" , scope: !1 , file: !1 , line: 2 , type: !5 , 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: !7 )
2016-02-17 05:14:51 +08:00
!5 = !DISubroutineType ( types: !6 )
!6 = ! { null }
!7 = ! { !8 }
!8 = !DILocalVariable ( name: "x" , scope: !4 , file: !1 , line: 3 , type: !9 )
!9 = !DIBasicType ( name: "int" , size: 32 , align: 32 , encoding: D W _ A T E _ s i g n e d )
!10 = ! { i32 2 , !"CodeView" , i32 1 }
!11 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!12 = ! { i32 1 , !"PIC Level" , i32 2 }
!13 = ! { !"clang version 3.9.0 (trunk 260957)" }
!14 = !DIExpression ( )
!15 = !DILocation ( line: 3 , column: 7 , scope: !4 )
!16 = !DILocation ( line: 4 , column: 3 , scope: !4 )
!17 = !DILocation ( line: 5 , column: 3 , scope: !4 )
!18 = !DILocation ( line: 6 , column: 1 , scope: !4 )