171 lines · plain
1; RUN: llc -mtriple=aarch64 -partition-static-data-sections \2; RUN: -function-sections -unique-section-names=false \3; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always4 5; Repeat the RUN command above for big-endian systems.6; RUN: llc -mtriple=aarch64_be -partition-static-data-sections \7; RUN: -function-sections -unique-section-names=false \8; RUN: %s -o - 2>&1 | FileCheck %s --dump-input=always9 10; Tests that constant pool hotness is aggregated across the module. The11; static-data-splitter processes data from cold_func first, unprofiled_func12; secondly, and then hot_func. Specifically, tests that13; - If a constant is accessed by hot functions, all constant pools for this14; constant (e.g., from an unprofiled function, or cold function) should have15; `.hot` suffix. For instance, double 0.68 is seen by both @cold_func and16; @hot_func, so two CPI emits (under label LCPI0_0 and LCPI2_0) have `.hot`17; suffix.18; - Similarly if a constant is accessed by both cold function and un-profiled19; function, constant pools for this constant should not have `.unlikely` suffix.20 21;; Constant pools for function @cold_func.22; CHECK: .section .rodata.cst8.hot.,"aM",@progbits,823; CHECK-NEXT: .p2align24; CHECK-NEXT: .LCPI0_0:25; CHECK-NEXT: .xword 0x3fe5c28f5c28f5c3 // double 0.6800000000000000526; CHECK-NEXT: .section .rodata.cst8.unlikely.,"aM",@progbits,827; CHECK-NEXT: .p2align28; CHECK-NEXT: .LCPI0_1:29; CHECK-NEXT: .xword 0x3fe5eb851eb851ec // double 0.6850000000000000530; CHECK-NEXT: .section .rodata.cst8,"aM",@progbits,831; CHECK-NEXT: .p2align32; CHECK-NEXT: .LCPI0_2:33; CHECK-NEXT: .byte 0 // 0x034; CHECK-NEXT: .byte 4 // 0x435; CHECK-NEXT: .byte 8 // 0x836; CHECK-NEXT: .byte 12 // 0xc37; CHECK-NEXT: .byte 255 // 0xff38; CHECK-NEXT: .byte 255 // 0xff39; CHECK-NEXT: .byte 255 // 0xff40; CHECK-NEXT: .byte 255 // 0xff41 42;; Constant pools for function @unprofiled_func43; CHECK: .section .rodata.cst8,"aM",@progbits,844; CHECK-NEXT: .p2align45; CHECK-NEXT: .LCPI1_0:46; CHECK-NEXT: .byte 0 // 0x047; CHECK-NEXT: .byte 4 // 0x448; CHECK-NEXT: .byte 8 // 0x849; CHECK-NEXT: .byte 12 // 0xc50; CHECK-NEXT: .byte 255 // 0xff51; CHECK-NEXT: .byte 255 // 0xff52; CHECK-NEXT: .byte 255 // 0xff53; CHECK-NEXT: .byte 255 // 0xff54; CHECK-NEXT: .section .rodata.cst16,"aM",@progbits,1655; CHECK-NEXT: .p2align56; CHECK-NEXT: .LCPI1_1:57; CHECK-NEXT: .word 2 // 0x258; CHECK-NEXT: .word 3 // 0x359; CHECK-NEXT: .word 5 // 0x560; CHECK-NEXT: .word 7 // 0x761; CHECK-NEXT: .section .rodata.cst16.hot.,"aM",@progbits,1662; CHECK-NEXT: .p2align63; CHECK-NEXT: .LCPI1_2:64; CHECK-NEXT: .word 442 // 0x1ba65; CHECK-NEXT: .word 100 // 0x6466; CHECK-NEXT: .word 0 // 0x067; CHECK-NEXT: .word 0 // 0x068 69;; Constant pools for function @hot_func70; CHECK: .section .rodata.cst8.hot.,"aM",@progbits,871; CHECK-NEXT: .p2align72; CHECK-NEXT: .LCPI2_0:73; CHECK-NEXT: .xword 0x3fe5c28f5c28f5c3 // double 0.6800000000000000574; CHECK-NEXT: .section .rodata.cst16.hot.,"aM",@progbits,1675; CHECK-NEXT: .p2align76; CHECK-NEXT: .LCPI2_1:77; CHECK-NEXT: .word 0 // 0x078; CHECK-NEXT: .word 100 // 0x6479; CHECK-NEXT: .word 0 // 0x080; CHECK-NEXT: .word 442 // 0x1ba81; CHECK-NEXT: .LCPI2_2:82; CHECK-NEXT: .word 442 // 0x1ba83; CHECK-NEXT: .word 100 // 0x6484; CHECK-NEXT: .word 0 // 0x085; CHECK-NEXT: .word 0 // 0x086 87;; For global variable @val88;; The section name remains `.rodata.cst32` without hotness prefix because89;; the variable has external linkage and not analyzed. Compiler need symbolized90;; data access profiles to annotate such global variables' hotness.91; CHECK: .section .rodata.cst32,"aM",@progbits,3292; CHECK-NEXT: .globl val93 94define i32 @cold_func(double %x, <16 x i8> %a, <16 x i8> %b) !prof !16 {95 %2 = tail call i32 (...) @func_taking_arbitrary_param(double 6.800000e-01)96 %num = tail call i32 (...) @func_taking_arbitrary_param(double 6.8500000e-01)97 %t1 = call <8 x i8> @llvm.aarch64.neon.tbl2.v8i8(<16 x i8> %a, <16 x i8> %b, <8 x i8> <i8 0, i8 4, i8 8, i8 12, i8 -1, i8 -1, i8 -1, i8 -1>)98 %t2 = bitcast <8 x i8> %t1 to <2 x i32>99 %3 = extractelement <2 x i32> %t2, i32 1100 %sum = add i32 %2, %3101 %ret = add i32 %sum, %num102 ret i32 %ret103}104 105declare <8 x i8> @llvm.aarch64.neon.tbl2.v8i8(<16 x i8>, <16 x i8>, <8 x i8>)106declare i32 @func_taking_arbitrary_param(...)107 108define <4 x i1> @unprofiled_func(<16 x i8> %a, <16 x i8> %b) {109 %t1 = call <8 x i8> @llvm.aarch64.neon.tbl2.v8i8(<16 x i8> %a, <16 x i8> %b, <8 x i8> <i8 0, i8 4, i8 8, i8 12, i8 -1, i8 -1, i8 -1, i8 -1>)110 %t2 = bitcast <8 x i8> %t1 to <4 x i16>111 %t3 = zext <4 x i16> %t2 to <4 x i32>112 %t4 = add <4 x i32> %t3, <i32 2, i32 3, i32 5, i32 7>113 %cmp = icmp ule <4 x i32> <i32 442, i32 100, i32 0, i32 0>, %t4114 ret <4 x i1> %cmp115}116 117define <4 x i1> @hot_func(i32 %0, <4 x i32> %a) !prof !17 {118 %2 = tail call i32 (...) @func_taking_arbitrary_param(double 6.800000e-01)119 %b = add <4 x i32> <i32 0, i32 100, i32 0, i32 442>, %a120 %c = icmp ule <4 x i32> %b, <i32 442, i32 100, i32 0, i32 0>121 ret <4 x i1> %c122}123 124@val = unnamed_addr constant i256 1125 126define i32 @main(i32 %0, ptr %1) !prof !16 {127 br label %7128 1295: ; preds = %7130 %x = call double @double_func()131 %a = call <16 x i8> @vector_func_16i8()132 %b = call <16 x i8> @vector_func_16i8()133 call void @cold_func(double %x, <16 x i8> %a, <16 x i8> %b)134 ret i32 0135 1367: ; preds = %7, %2137 %8 = phi i32 [ 0, %2 ], [ %10, %7 ]138 %seed_val = load i256, ptr @val139 %9 = call i32 @seed(i256 %seed_val)140 call void @hot_func(i32 %9)141 %10 = add i32 %8, 1142 %11 = icmp eq i32 %10, 100000143 br i1 %11, label %5, label %7, !prof !18144}145 146declare i32 @seed(i256)147declare double @double_func()148declare <4 x i32> @vector_func()149declare <16 x i8> @vector_func_16i8()150 151!llvm.module.flags = !{!1}152 153!1 = !{i32 1, !"ProfileSummary", !2}154!2 = !{!3, !4, !5, !6, !7, !8, !9, !10, !11, !12}155!3 = !{!"ProfileFormat", !"InstrProf"}156!4 = !{!"TotalCount", i64 1460617}157!5 = !{!"MaxCount", i64 849536}158!6 = !{!"MaxInternalCount", i64 32769}159!7 = !{!"MaxFunctionCount", i64 849536}160!8 = !{!"NumCounts", i64 23784}161!9 = !{!"NumFunctions", i64 3301}162!10 = !{!"IsPartialProfile", i64 0}163!11 = !{!"PartialProfileRatio", double 0.000000e+00}164!12 = !{!"DetailedSummary", !13}165!13 = !{!14, !15}166!14 = !{i32 990000, i64 166, i32 73}167!15 = !{i32 999999, i64 3, i32 1463}168!16 = !{!"function_entry_count", i64 1}169!17 = !{!"function_entry_count", i64 100000}170!18 = !{!"branch_weights", i32 1, i32 99999}171