llvm-6502/test/Transforms/Inline/inline-cold.ll
Manman Ren c7ac256d52 Set default of inlinecold-threshold to 225.
225 is the default value of inline-threshold. This change will make sure
we have the same inlining behavior as prior to r200886.

As Chandler points out, even though we don't have code in our testing
suite that uses cold attribute, there are larger applications that do
use cold attribute.

r200886 + this commit intend to keep the same behavior as prior to r200886.
We can later on tune the inlinecold-threshold.

The main purpose of r200886 is to help performance of instrumentation based
PGO before we actually hook up inliner with analysis passes such as BPI and BFI.
For instrumentation based PGO, we try to increase inlining of hot functions and
reduce inlining of cold functions by setting inlinecold-threshold.

Another option suggested by Chandler is to use a boolean flag that controls
if we should use OptSizeThreshold for cold functions. The default value
of the boolean flag should not change the current behavior. But it gives us
less freedom in controlling inlining of cold functions.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200898 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-06 01:59:22 +00:00

89 lines
2.3 KiB
LLVM

; RUN: opt < %s -inline -S -inlinecold-threshold=75 | FileCheck %s
; Test that functions with attribute Cold are not inlined while the
; same function without attribute Cold will be inlined.
@a = global i32 4
; This function should be larger than the cold threshold (75), but smaller
; than the regular threshold.
; Function Attrs: nounwind readnone uwtable
define i32 @simpleFunction(i32 %a) #0 {
entry:
%a1 = load volatile i32* @a
%x1 = add i32 %a1, %a1
%a2 = load volatile i32* @a
%x2 = add i32 %x1, %a2
%a3 = load volatile i32* @a
%x3 = add i32 %x2, %a3
%a4 = load volatile i32* @a
%x4 = add i32 %x3, %a4
%a5 = load volatile i32* @a
%x5 = add i32 %x4, %a5
%a6 = load volatile i32* @a
%x6 = add i32 %x5, %a6
%a7 = load volatile i32* @a
%x7 = add i32 %x6, %a6
%a8 = load volatile i32* @a
%x8 = add i32 %x7, %a8
%a9 = load volatile i32* @a
%x9 = add i32 %x8, %a9
%a10 = load volatile i32* @a
%x10 = add i32 %x9, %a10
%a11 = load volatile i32* @a
%x11 = add i32 %x10, %a11
%a12 = load volatile i32* @a
%x12 = add i32 %x11, %a12
%add = add i32 %x12, %a
ret i32 %add
}
; Function Attrs: nounwind cold readnone uwtable
define i32 @ColdFunction(i32 %a) #1 {
; CHECK-LABEL: @ColdFunction
; CHECK: ret
entry:
%a1 = load volatile i32* @a
%x1 = add i32 %a1, %a1
%a2 = load volatile i32* @a
%x2 = add i32 %x1, %a2
%a3 = load volatile i32* @a
%x3 = add i32 %x2, %a3
%a4 = load volatile i32* @a
%x4 = add i32 %x3, %a4
%a5 = load volatile i32* @a
%x5 = add i32 %x4, %a5
%a6 = load volatile i32* @a
%x6 = add i32 %x5, %a6
%a7 = load volatile i32* @a
%x7 = add i32 %x6, %a6
%a8 = load volatile i32* @a
%x8 = add i32 %x7, %a8
%a9 = load volatile i32* @a
%x9 = add i32 %x8, %a9
%a10 = load volatile i32* @a
%x10 = add i32 %x9, %a10
%a11 = load volatile i32* @a
%x11 = add i32 %x10, %a11
%a12 = load volatile i32* @a
%x12 = add i32 %x11, %a12
%add = add i32 %x12, %a
ret i32 %add
}
; Function Attrs: nounwind readnone uwtable
define i32 @bar(i32 %a) #0 {
; CHECK-LABEL: @bar
; CHECK: call i32 @ColdFunction(i32 5)
; CHECK-NOT: call i32 @simpleFunction(i32 6)
; CHECK: ret
entry:
%0 = tail call i32 @ColdFunction(i32 5)
%1 = tail call i32 @simpleFunction(i32 6)
%add = add i32 %0, %1
ret i32 %add
}
attributes #0 = { nounwind readnone uwtable }
attributes #1 = { nounwind cold readnone uwtable }