140 lines · plain
1target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"2target triple = "x86_64-grtev4-linux-gnu"3 4; Tests that constant pool hotness is aggregated across the module. The5; static-data-splitter processes data from @cold_func first, two functions6; without profiles secondly, and then @hot_func. Specifically, tests that7; 1. If a constant is accessed by hot functions, all constant pools for this8; constant (e.g., from an unprofiled function, or cold function) should have9; .hot suffix.10; 2. Similarly if a constant is accessed by both cold function and un-profiled11; function, constant pools for this constant should not have .unlikely suffix.12 13; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \14; RUN: -function-sections -data-sections -unique-section-names=false \15; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always16 17; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \18; RUN: -function-sections -data-sections -unique-section-names \19; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always20 21; RUN: llc -mtriple=x86_64-unknown-linux-gnu -partition-static-data-sections \22; RUN: -function-sections=false -data-sections=false \23; RUN: -unique-section-names=false \24; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always25 26;; For function @cold_func27; CHECK: .section .rodata.cst8.hot.,"aM",@progbits,828; CHECK-NEXT: .p2align29; CHECK-NEXT: .LCPI0_0:30; CHECK-NEXT: .quad 0x3fe5c28f5c28f5c3 # double 0.6800000000000000531; CHECK-NEXT: .section .rodata.cst8.unlikely.,"aM",@progbits,832; CHECK-NEXT: .p2align33; CHECK-NEXT: .LCPI0_1:34; CHECK-NEXT: .quad 0x3eb0000000000000 # double 9.5367431640625E-735; CHECK-NEXT: .section .rodata.cst8,"aM",@progbits,836; CHECK-NEXT: .p2align37; CHECK-NEXT: .LCPI0_2:38; CHECK-NEXT: .quad 0x3fc0000000000000 # double 0.12539 40;; For function @unprofiled_func_double41; CHECK: .section .rodata.cst8,"aM",@progbits,842; CHECK-NEXT: .p2align43; CHECK-NEXT: .LCPI1_0:44; CHECK-NEXT: .quad 0x3fc0000000000000 # double 0.12545 46;; For function @unprofiled_func_float47; CHECK: .section .rodata.cst4,"aM",@progbits,448; CHECK-NEXT: .p2align49; CHECK-NEXT: .LCPI2_0:50; CHECK-NEXT: .long 0x3e000000 # float 0.12551 52;; For function @hot_func53; CHECK: .section .rodata.cst8.hot.,"aM",@progbits,854; CHECK-NEXT: .p2align55; CHECK-NEXT: .LCPI3_0:56; CHECK-NEXT: .quad 0x3fe5c28f5c28f5c3 # double 0.6800000000000000557; CHECK-NEXT: .section .rodata.cst16.hot.,"aM",@progbits,1658; CHECK-NEXT: .p2align59; CHECK-NEXT: .LCPI3_1:60; CHECK-NEXT: .long 2147483648 # 0x8000000061; CHECK-NEXT: .long 2147483648 # 0x8000000062; CHECK-NEXT: .long 2147483648 # 0x8000000063; CHECK-NEXT: .long 2147483648 # 0x8000000064; CHECK-NEXT: .LCPI3_2:65; CHECK-NEXT: .long 2147484090 # 0x800001ba66; CHECK-NEXT: .long 2147483748 # 0x8000006467; CHECK-NEXT: .long 2147483648 # 0x8000000068; CHECK-NEXT: .long 2147483648 # 0x8000000069 70; CHECK: .section .rodata.cst32,"aM",@progbits,3271; CHECK-NEXT: .globl val72 73define double @cold_func(double %x) !prof !16 {74 %2 = tail call i32 (...) @func_taking_arbitrary_param(double 6.800000e-01)75 %y = fmul double %x, 0x3EB000000000000076 %z = fmul double %y, 0x3fc000000000000077 ret double %z78}79 80define double @unprofiled_func_double(double %x) {81 %z = fmul double %x, 0x3fc000000000000082 ret double %z83}84 85define float @unprofiled_func_float(float %x) {86 %z = fmul float %x, 0x3fc000000000000087 ret float %z88}89 90define <4 x i1> @hot_func(i32 %0, <4 x i32> %a) !prof !17 {91 %2 = tail call i32 (...) @func_taking_arbitrary_param(double 6.800000e-01)92 %b = icmp ule <4 x i32> %a, <i32 442, i32 100, i32 0, i32 0>93 ret <4 x i1> %b94}95 96@val = unnamed_addr constant i256 197 98define i32 @main(i32 %0, ptr %1) !prof !16 {99 br label %7100 1015: ; preds = %7102 %x = call double @double_func()103 call void @cold_func(double %x)104 ret i32 0105 1067: ; preds = %7, %2107 %8 = phi i32 [ 0, %2 ], [ %10, %7 ]108 %seed_val = load i256, ptr @val109 %9 = call i32 @seed(i256 %seed_val)110 call void @hot_func(i32 %9)111 %10 = add i32 %8, 1112 %11 = icmp eq i32 %10, 100000113 br i1 %11, label %5, label %7, !prof !18114}115 116declare i32 @seed(i256)117declare double @double_func()118declare i32 @func_taking_arbitrary_param(...)119 120!llvm.module.flags = !{!1}121 122!1 = !{i32 1, !"ProfileSummary", !2}123!2 = !{!3, !4, !5, !6, !7, !8, !9, !10, !11, !12}124!3 = !{!"ProfileFormat", !"InstrProf"}125!4 = !{!"TotalCount", i64 1460617}126!5 = !{!"MaxCount", i64 849536}127!6 = !{!"MaxInternalCount", i64 32769}128!7 = !{!"MaxFunctionCount", i64 849536}129!8 = !{!"NumCounts", i64 23784}130!9 = !{!"NumFunctions", i64 3301}131!10 = !{!"IsPartialProfile", i64 0}132!11 = !{!"PartialProfileRatio", double 0.000000e+00}133!12 = !{!"DetailedSummary", !13}134!13 = !{!14, !15}135!14 = !{i32 990000, i64 166, i32 73}136!15 = !{i32 999999, i64 1, i32 1463}137!16 = !{!"function_entry_count", i64 1}138!17 = !{!"function_entry_count", i64 100000}139!18 = !{!"branch_weights", i32 1, i32 99999}140