2017-03-07 18:28:54 +01:00
|
|
|
; RUN: llvm-as < %s -o %t
|
|
|
|
; RUN: llvm-dis < %t -o - | FileCheck %s
|
2017-03-07 19:26:36 +01:00
|
|
|
; Created at -O1 from:
|
|
|
|
; int sink(int);
|
|
|
|
; __attribute__((always_inline)) int f(int i) { return sink(i); }
|
|
|
|
; __attribute__((always_inline)) int g(int j) { return sink(j); }
|
|
|
|
; __attribute__((nodebug)) int nodebug(int k) { return f(k)+g(k); }
|
2017-03-07 18:28:54 +01:00
|
|
|
source_filename = "t.c"
|
|
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-apple-macosx10.12.0"
|
|
|
|
|
2017-03-07 19:26:36 +01:00
|
|
|
declare i32 @sink(i32) local_unnamed_addr
|
2017-03-07 18:28:54 +01:00
|
|
|
|
2017-03-07 19:26:36 +01:00
|
|
|
define i32 @nodebug(i32 %k) local_unnamed_addr #2 {
|
2017-03-07 18:28:54 +01:00
|
|
|
entry:
|
|
|
|
; This should not set off the FnArg Verifier. The two variables are in differrent scopes.
|
2017-03-07 19:26:36 +01:00
|
|
|
tail call void @llvm.dbg.value(metadata i32 %k, i64 0, metadata !12, metadata !13) #4, !dbg !14
|
|
|
|
%call.k = tail call i32 @sink(i32 %k) #4, !dbg !15
|
|
|
|
tail call void @llvm.dbg.value(metadata i32 %k, i64 0, metadata !19, metadata !13) #4, !dbg !20
|
|
|
|
%call.k3 = tail call i32 @sink(i32 %k) #4, !dbg !21
|
|
|
|
%add = add nsw i32 %call.k3, %call.k
|
|
|
|
ret i32 %add
|
2017-03-07 18:28:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind readnone
|
2017-03-07 19:26:36 +01:00
|
|
|
declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #3
|
2017-03-07 18:28:54 +01:00
|
|
|
|
2017-03-07 19:26:36 +01:00
|
|
|
attributes #2 = { nounwind ssp uwtable }
|
|
|
|
attributes #3 = { nounwind readnone }
|
2017-03-07 18:28:54 +01:00
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!3, !4, !5}
|
|
|
|
!llvm.ident = !{!6}
|
|
|
|
|
2017-03-07 19:26:36 +01:00
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 (trunk 297153) (llvm/trunk 297155)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
|
2017-03-07 18:28:54 +01:00
|
|
|
!1 = !DIFile(filename: "t.c", directory: "/tmp")
|
|
|
|
!2 = !{}
|
|
|
|
!3 = !{i32 2, !"Dwarf Version", i32 4}
|
|
|
|
!4 = !{i32 2, !"Debug Info Version", i32 3}
|
|
|
|
!5 = !{i32 1, !"PIC Level", i32 2}
|
|
|
|
!6 = !{!"clang version 5.0.0 (trunk 297153) (llvm/trunk 297155)"}
|
[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
|
|
|
!7 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !11)
|
2017-03-07 18:28:54 +01:00
|
|
|
!8 = !DISubroutineType(types: !9)
|
2017-03-07 19:26:36 +01:00
|
|
|
!9 = !{!10, !10}
|
|
|
|
!10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
|
|
|
|
!11 = !{!12}
|
|
|
|
; CHECK: !DILocalVariable(name: "i", arg: 1
|
|
|
|
!12 = !DILocalVariable(name: "i", arg: 1, scope: !7, file: !1, line: 2, type: !10)
|
|
|
|
!13 = !DIExpression()
|
|
|
|
!14 = !DILocation(line: 2, column: 42, scope: !7)
|
|
|
|
!15 = !DILocation(line: 2, column: 54, scope: !7)
|
|
|
|
!16 = !DILocation(line: 2, column: 47, scope: !7)
|
[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
|
|
|
!17 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !18)
|
2017-03-07 19:26:36 +01:00
|
|
|
!18 = !{!19}
|
|
|
|
; CHECK: !DILocalVariable(name: "j", arg: 1
|
|
|
|
!19 = !DILocalVariable(name: "j", arg: 1, scope: !17, file: !1, line: 3, type: !10)
|
|
|
|
!20 = !DILocation(line: 3, column: 42, scope: !17)
|
|
|
|
!21 = !DILocation(line: 3, column: 54, scope: !17)
|
|
|
|
!22 = !DILocation(line: 3, column: 47, scope: !17)
|