2017-10-31 22:52:15 +01:00
; RUN: llc < %s | FileCheck %s --check-prefix=ASM
; RUN: llc < %s -filetype=obj | llvm-readobj -codeview | FileCheck %s --check-prefix=OBJ
; Test what happens when we have two DIFile entries with differing slashes.
; Make sure we only emit one file checksum entry.
; C++ source, compiled as:
; $ clang -S -emit-llvm -g -gcodeview ../t.cpp -o t.ll
; struct Foo { Foo(); };
; extern int global;
; Foo gy;
; void f() {
; ++global;
; ++global;
; }
; The relative path with a forward slash is important for creating TWO DIFile
; entries for the same file.
; ASM: .cv_file 1 "{{.*}}t.cpp" "8B89D3B180D6A1BC83E7126D5FD870C3" 1
; ASM-NOT: .cv_file 1 "{{.*}}t.cpp"
; OBJ: SubSectionType: FileChecksums (0xF4)
; OBJ: SubSectionSize: 0x18
; OBJ: FileChecksum {
; OBJ: Filename: C:\src\llvm-project\build\t.cpp (0x1)
; OBJ: ChecksumSize: 0x10
; OBJ: ChecksumKind: MD5 (0x1)
; OBJ: ChecksumBytes: (8B 89 D3 B1 80 D6 A1 BC 83 E7 12 6D 5F D8 70 C3)
; OBJ: }
; OBJ-NOT: FileChecksum {
; ModuleID = '../t.cpp'
source_filename = "../t.cpp"
target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-windows-msvc19.11.25508"
%struct.Foo = type { i8 }
@"\01?gy@@3UFoo@@A" = global %struct.Foo zeroinitializer , align 1 , !dbg !0
@"\01?global@@3HA" = external global i32 , align 4
@llvm.global_ctors = appending global [ 1 x { i32 , void ( ) * , i8 * } ] [ { i32 , void ( ) * , i8 * } { i32 65535 , void ( ) * @_GLOBAL__sub_I_t.cpp , i8 * null } ]
; Function Attrs: noinline uwtable
define internal void @"\01??__Egy@@YAXXZ" ( ) #0 !dbg !18 {
entry:
%call = call %struct.Foo * @"\01??0Foo@@QEAA@XZ" ( %struct.Foo * @"\01?gy@@3UFoo@@A" ) , !dbg !21
ret void , !dbg !21
}
declare %struct.Foo * @"\01??0Foo@@QEAA@XZ" ( %struct.Foo * returned ) unnamed_addr #1
; Function Attrs: noinline nounwind optnone uwtable
define void @"\01?f@@YAXXZ" ( ) #2 !dbg !22 {
entry:
%0 = load i32 , i32 * @"\01?global@@3HA" , align 4 , !dbg !23
%inc = add nsw i32 %0 , 1 , !dbg !23
store i32 %inc , i32 * @"\01?global@@3HA" , align 4 , !dbg !23
%1 = load i32 , i32 * @"\01?global@@3HA" , align 4 , !dbg !24
%inc1 = add nsw i32 %1 , 1 , !dbg !24
store i32 %inc1 , i32 * @"\01?global@@3HA" , align 4 , !dbg !24
ret void , !dbg !25
}
; Function Attrs: noinline uwtable
define internal void @_GLOBAL__sub_I_t.cpp ( ) #0 !dbg !26 {
entry:
call void @"\01??__Egy@@YAXXZ" ( ) , !dbg !28
ret void
}
attributes #0 = { noinline 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 = { noinline nounwind optnone 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" }
!llvm.dbg.cu = ! { !2 }
!llvm.module.flags = ! { !13 , !14 , !15 , !16 }
!llvm.ident = ! { !17 }
!0 = !DIGlobalVariableExpression ( var: !1 , expr: !DIExpression ( ) )
!1 = distinct !DIGlobalVariable ( name: "gy" , linkageName: "\01?gy@@3UFoo@@A" , scope: !2 , file: !6 , line: 3 , type: !7 , isLocal: false , isDefinition: true )
!2 = distinct !DICompileUnit ( language: D W _ L A N G _ C _ p l u s _ p l u s , file: !3 , producer: "clang version 6.0.0 " , isOptimized: false , runtimeVersion: 0 , emissionKind: F u l l D e b u g , enums: !4 , globals: !5 )
!3 = !DIFile ( filename: "..\5Ct.cpp" , directory: "C:\5Csrc\5Cllvm-project\5Cbuild\5Ctmp" , checksumkind: C S K _ M D 5 , checksum: "8b89d3b180d6a1bc83e7126d5fd870c3" )
!4 = ! { }
!5 = ! { !0 }
!6 = !DIFile ( filename: "../t.cpp" , directory: "C:\5Csrc\5Cllvm-project\5Cbuild\5Ctmp" , checksumkind: C S K _ M D 5 , checksum: "8b89d3b180d6a1bc83e7126d5fd870c3" )
!7 = distinct !DICompositeType ( tag: D W _ T A G _ s t r u c t u r e _ type , name: "Foo" , file: !6 , line: 1 , size: 8 , elements: !8 , identifier: ".?AUFoo@@" )
!8 = ! { !9 }
!9 = !DISubprogram ( name: "Foo" , scope: !7 , file: !6 , line: 1 , type: !10 , isLocal: false , isDefinition: false , scopeLine: 1 , flags: D I F l a g P r o t o t y p e d , isOptimized: false )
!10 = !DISubroutineType ( types: !11 )
!11 = ! { null , !12 }
!12 = !DIDerivedType ( tag: D W _ T A G _ p o i n t e r _ type , baseType: !7 , size: 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 )
!13 = ! { i32 2 , !"CodeView" , i32 1 }
!14 = ! { i32 2 , !"Debug Info Version" , i32 3 }
!15 = ! { i32 1 , !"wchar_size" , i32 2 }
!16 = ! { i32 7 , !"PIC Level" , i32 2 }
!17 = ! { !"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 04:40:45 +02:00
!18 = distinct !DISubprogram ( name: "??__Egy@@YAXXZ" , scope: !6 , file: !6 , line: 3 , type: !19 , isLocal: true , isDefinition: true , scopeLine: 3 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !2 , retainedNodes: !4 )
2017-10-31 22:52:15 +01:00
!19 = !DISubroutineType ( types: !20 )
!20 = ! { null }
!21 = !DILocation ( line: 3 , column: 5 , scope: !18 )
[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 04:40:45 +02:00
!22 = distinct !DISubprogram ( name: "f" , linkageName: "\01?f@@YAXXZ" , scope: !6 , file: !6 , line: 4 , type: !19 , isLocal: false , isDefinition: true , scopeLine: 4 , flags: D I F l a g P r o t o t y p e d , isOptimized: false , unit: !2 , retainedNodes: !4 )
2017-10-31 22:52:15 +01:00
!23 = !DILocation ( line: 5 , column: 3 , scope: !22 )
!24 = !DILocation ( line: 6 , column: 3 , scope: !22 )
!25 = !DILocation ( line: 7 , column: 1 , scope: !22 )
[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 04:40:45 +02:00
!26 = distinct !DISubprogram ( linkageName: "_GLOBAL__sub_I_t.cpp" , scope: !3 , file: !3 , type: !27 , isLocal: true , isDefinition: true , flags: D I F l a g A r t i f i c i a l , isOptimized: false , unit: !2 , retainedNodes: !4 )
2017-10-31 22:52:15 +01:00
!27 = !DISubroutineType ( types: !4 )
!28 = !DILocation ( line: 0 , scope: !26 )