2016-09-28 07:47:03 +08:00
|
|
|
; RUN: opt < %s -S -inline -pass-remarks-output=%t -pass-remarks=inline \
|
|
|
|
; RUN: -pass-remarks-missed=inline -pass-remarks-analysis=inline \
|
|
|
|
; RUN: -pass-remarks-with-hotness 2>&1 | FileCheck %s
|
|
|
|
; RUN: cat %t | FileCheck -check-prefix=YAML %s
|
|
|
|
|
2017-08-22 00:45:47 +08:00
|
|
|
; RUN: opt < %s -S -passes=inline -pass-remarks-output=%t -pass-remarks=inline \
|
|
|
|
; RUN: -pass-remarks-missed=inline -pass-remarks-analysis=inline \
|
|
|
|
; RUN: -pass-remarks-with-hotness 2>&1 | FileCheck %s
|
|
|
|
; RUN: cat %t | FileCheck -check-prefix=YAML %s
|
|
|
|
|
2016-09-28 07:47:03 +08:00
|
|
|
; Check the YAML file for inliner-generated passed and analysis remarks. This
|
|
|
|
; is the input:
|
|
|
|
|
|
|
|
; 1 int foo() { return 1; }
|
|
|
|
; 2
|
|
|
|
; 3 int bar() {
|
|
|
|
; 4 return foo();
|
|
|
|
; 5 }
|
|
|
|
|
Enrich inline messages
Summary:
This patch improves Inliner to provide causes/reasons for negative inline decisions.
1. It adds one new message field to InlineCost to report causes for Always and Never instances. All Never and Always instantiations must provide a simple message.
2. Several functions that used to return the inlining results as boolean are changed to return InlineResult which carries the cause for negative decision.
3. Changed remark priniting and debug output messages to provide the additional messages and related inline cost.
4. Adjusted tests for changed printing.
Patch by: yrouban (Yevgeny Rouban)
Reviewers: craig.topper, sammccall, sgraenitz, NutshellySima, shchenz, chandlerc, apilipenko, javed.absar, tejohnson, dblaikie, sanjoy, eraman, xbolva00
Reviewed By: tejohnson, xbolva00
Subscribers: xbolva00, llvm-commits, arsenm, mehdi_amini, eraman, haicheng, steven_wu, dexonsmith
Differential Revision: https://reviews.llvm.org/D49412
llvm-svn: 338969
2018-08-05 22:53:08 +08:00
|
|
|
; CHECK: remark: /tmp/s.c:4:10: foo inlined into bar with (cost={{[0-9\-]+}}, threshold={{[0-9]+}}) (hotness: 30)
|
2016-09-28 07:47:03 +08:00
|
|
|
|
2017-08-22 00:45:47 +08:00
|
|
|
; YAML: --- !Passed
|
2016-09-28 07:47:03 +08:00
|
|
|
; YAML-NEXT: Pass: inline
|
2017-08-22 00:45:47 +08:00
|
|
|
; YAML-NEXT: Name: Inlined
|
2018-10-13 00:31:20 +08:00
|
|
|
; YAML-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 4, Column: 10 }
|
2016-09-28 07:47:03 +08:00
|
|
|
; YAML-NEXT: Function: bar
|
|
|
|
; YAML-NEXT: Hotness: 30
|
|
|
|
; YAML-NEXT: Args:
|
|
|
|
; YAML-NEXT: - Callee: foo
|
2018-10-13 00:31:20 +08:00
|
|
|
; YAML-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 1, Column: 0 }
|
2017-08-22 00:45:47 +08:00
|
|
|
; YAML-NEXT: - String: ' inlined into '
|
2016-09-28 07:47:03 +08:00
|
|
|
; YAML-NEXT: - Caller: bar
|
2018-10-13 00:31:20 +08:00
|
|
|
; YAML-NEXT: DebugLoc: { File: '/tmp/s.c', Line: 3, Column: 0 }
|
Enrich inline messages
Summary:
This patch improves Inliner to provide causes/reasons for negative inline decisions.
1. It adds one new message field to InlineCost to report causes for Always and Never instances. All Never and Always instantiations must provide a simple message.
2. Several functions that used to return the inlining results as boolean are changed to return InlineResult which carries the cause for negative decision.
3. Changed remark priniting and debug output messages to provide the additional messages and related inline cost.
4. Adjusted tests for changed printing.
Patch by: yrouban (Yevgeny Rouban)
Reviewers: craig.topper, sammccall, sgraenitz, NutshellySima, shchenz, chandlerc, apilipenko, javed.absar, tejohnson, dblaikie, sanjoy, eraman, xbolva00
Reviewed By: tejohnson, xbolva00
Subscribers: xbolva00, llvm-commits, arsenm, mehdi_amini, eraman, haicheng, steven_wu, dexonsmith
Differential Revision: https://reviews.llvm.org/D49412
llvm-svn: 338969
2018-08-05 22:53:08 +08:00
|
|
|
; YAML-NEXT: - String: ' with '
|
|
|
|
; YAML-NEXT: - String: '(cost='
|
2016-11-14 19:14:41 +08:00
|
|
|
; YAML-NEXT: - Cost: '{{[0-9\-]+}}'
|
Enrich inline messages
Summary:
This patch improves Inliner to provide causes/reasons for negative inline decisions.
1. It adds one new message field to InlineCost to report causes for Always and Never instances. All Never and Always instantiations must provide a simple message.
2. Several functions that used to return the inlining results as boolean are changed to return InlineResult which carries the cause for negative decision.
3. Changed remark priniting and debug output messages to provide the additional messages and related inline cost.
4. Adjusted tests for changed printing.
Patch by: yrouban (Yevgeny Rouban)
Reviewers: craig.topper, sammccall, sgraenitz, NutshellySima, shchenz, chandlerc, apilipenko, javed.absar, tejohnson, dblaikie, sanjoy, eraman, xbolva00
Reviewed By: tejohnson, xbolva00
Subscribers: xbolva00, llvm-commits, arsenm, mehdi_amini, eraman, haicheng, steven_wu, dexonsmith
Differential Revision: https://reviews.llvm.org/D49412
llvm-svn: 338969
2018-08-05 22:53:08 +08:00
|
|
|
; YAML-NEXT: - String: ', threshold='
|
2016-10-05 01:05:04 +08:00
|
|
|
; YAML-NEXT: - Threshold: '{{[0-9]+}}'
|
|
|
|
; YAML-NEXT: - String: ')'
|
2016-09-28 07:47:03 +08:00
|
|
|
; YAML-NEXT: ...
|
|
|
|
|
|
|
|
; ModuleID = '/tmp/s.c'
|
|
|
|
source_filename = "/tmp/s.c"
|
|
|
|
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
|
|
|
|
target triple = "x86_64-apple-macosx10.11.0"
|
|
|
|
|
|
|
|
; Function Attrs: nounwind ssp uwtable
|
|
|
|
define i32 @foo() #0 !dbg !7 {
|
|
|
|
entry:
|
|
|
|
ret i32 1, !dbg !9
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind ssp uwtable
|
|
|
|
define i32 @bar() #0 !dbg !10 !prof !13 {
|
|
|
|
entry:
|
|
|
|
%call = call i32 @foo(), !dbg !11
|
|
|
|
ret i32 %call, !dbg !12
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes #0 = { nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "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"="core2" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
|
|
|
|
|
|
|
|
!llvm.dbg.cu = !{!0}
|
|
|
|
!llvm.module.flags = !{!3, !4, !5}
|
|
|
|
!llvm.ident = !{!6}
|
|
|
|
|
|
|
|
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 4.0.0 (trunk 282540) (llvm/trunk 282542)", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !2)
|
|
|
|
!1 = !DIFile(filename: "/tmp/s.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 4.0.0 (trunk 282540) (llvm/trunk 282542)"}
|
[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
|
|
|
!7 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !8, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: true, unit: !0, retainedNodes: !2)
|
2016-09-28 07:47:03 +08:00
|
|
|
!8 = !DISubroutineType(types: !2)
|
|
|
|
!9 = !DILocation(line: 1, column: 13, 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 10:40:45 +08:00
|
|
|
!10 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 3, type: !8, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, retainedNodes: !2)
|
2016-09-28 07:47:03 +08:00
|
|
|
!11 = !DILocation(line: 4, column: 10, scope: !10)
|
|
|
|
!12 = !DILocation(line: 4, column: 3, scope: !10)
|
|
|
|
!13 = !{!"function_entry_count", i64 30}
|