llvm-project/llvm/test/CodeGen/AArch64/basic-block-sections-cold.ll
Daniel Hoekwater ea06384bf6
[CodeGen][AArch64] Only split safe blocks in BBSections (#81553)
Some types of machine function and machine basic block are unsafe to
split on AArch64: basic blocks that contain jump table dispatch or
targets (D157124), and blocks that contain inline ASM GOTO blocks
or their targets (D158647) all cause issues and have been excluded
from Machine Function Splitting on AArch64.

These issues are caused by any transformation pass that places
same-function basic blocks in different text sections
(MachineFunctionSplitter and BasicBlockSections) and must be
special-cased in both passes.
2024-02-14 10:58:07 -08:00

52 lines
1.9 KiB
LLVM

;; Check if basic blocks that don't get unique sections are placed in cold sections.
;; Basic block with id 1 and 2 must be in the cold section.
;;
;; Profile for version 0
; RUN: echo '!_Z3bazb' > %t1
; RUN: echo '!!0' >> %t1
;;
;; Profile for version 1
; RUN: echo 'v1' > %t2
; RUN: echo 'f _Z3bazb' >> %t2
; RUN: echo 'c 0' >> %t2
;;
; RUN: llc < %s -mtriple=aarch64 -function-sections -basic-block-sections=%t1 -unique-basic-block-section-names | FileCheck %s -check-prefix=SECTIONS
; RUN: llc < %s -mtriple=aarch64 -function-sections -basic-block-sections=%t2 -unique-basic-block-section-names | FileCheck %s -check-prefix=SECTIONS
; RUN: llc < %s -mtriple=aarch64 -function-sections -basic-block-sections=%t1 -unique-basic-block-section-names -bbsections-cold-text-prefix=".text.unlikely." | FileCheck %s -check-prefix=SPLIT
define void @_Z3bazb(i1 zeroext %0) nounwind {
br i1 %0, label %2, label %4
2: ; preds = %1
%3 = call i32 @_Z3barv()
br label %6
4: ; preds = %1
%5 = call i32 @_Z3foov()
br label %6
6: ; preds = %2, %4
ret void
}
declare i32 @_Z3barv() #1
declare i32 @_Z3foov() #1
; SECTIONS: .section .text.hot._Z3bazb,"ax",@progbits
; SECTIONS: _Z3bazb:
; Check that the basic block with id 1 doesn't get a section.
; SECTIONS-NOT: .section .text{{.*}}._Z3bazb.1,"ax",@progbits,unique
; Check that a single cold section is started here and id 1 and 2 blocks are placed here.
; SECTIONS: .section .text.split._Z3bazb,"ax",@progbits
; SECTIONS: _Z3bazb.cold:
; SECTIONS-NOT: .section .text.hot._Z3bazb._Z3bazb.2,"ax",@progbits,unique
; SECTIONS: .LBB0_2:
; SECTIONS: .size _Z3bazb, .Lfunc_end{{[0-9]}}-_Z3bazb
; SPLIT: .section .text.unlikely._Z3bazb,"ax",@progbits
; SPLIT-NEXT: _Z3bazb.cold:
; SPLIT-NEXT: bl _Z3barv
; SPLIT: .LBB0_2:
; SPLIT: .LBB_END0_2: