Skip to content

Commit 5064384

Browse files
committed
Add skipFunction() check to MachineFunctionSplitter pass
1 parent d4ca474 commit 5064384

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

llvm/lib/CodeGen/MachineFunctionSplitter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ bool MachineFunctionSplitter::runOnMachineFunction(MachineFunction &MF) {
136136
// of exception handling code may be split to cold if user passes the
137137
// mfs-split-ehcode flag.
138138
bool UseProfileData = MF.getFunction().hasProfileData();
139-
if (!UseProfileData && !SplitAllEHCode)
139+
if (!skipFunction(MF.getFunction()) && !UseProfileData && !SplitAllEHCode)
140140
return false;
141141

142142
const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
; REQUIRES: x86-registered-target
2+
3+
; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -split-machine-functions | FileCheck %s
4+
5+
;; Check that functions with optnone attribute are not split.
6+
; CHECK-LABEL: foo_optnone:
7+
; CHECK-NOT: .section .text.split.foo_optnone
8+
; CHECK-NOT: foo_optnone.cold:
9+
; CHECK: .LBB0_2:
10+
; CHECK: .size foo_optnone
11+
12+
define void @foo_optnone(i1 zeroext %0) nounwind optnone noinline !prof !14 !section_prefix !15 {
13+
entry:
14+
br i1 %0, label %hot, label %cold, !prof !17
15+
16+
hot:
17+
%1 = call i32 @bar()
18+
br label %exit
19+
20+
cold:
21+
%2 = call i32 @baz()
22+
br label %exit
23+
24+
exit:
25+
%3 = tail call i32 @qux()
26+
ret void
27+
}
28+
29+
declare i32 @bar()
30+
declare i32 @baz()
31+
declare i32 @qux()
32+
33+
!llvm.module.flags = !{!0}
34+
!0 = !{i32 1, !"ProfileSummary", !1}
35+
!1 = !{!2, !3, !4, !5, !6, !7, !8, !9}
36+
!2 = !{!"ProfileFormat", !"InstrProf"}
37+
!3 = !{!"TotalCount", i64 10000}
38+
!4 = !{!"MaxCount", i64 10}
39+
!5 = !{!"MaxInternalCount", i64 1}
40+
!6 = !{!"MaxFunctionCount", i64 1000}
41+
!7 = !{!"NumCounts", i64 3}
42+
!8 = !{!"NumFunctions", i64 5}
43+
!9 = !{!"DetailedSummary", !10}
44+
!10 = !{!11, !12, !13}
45+
!11 = !{i32 10000, i64 100, i32 1}
46+
!12 = !{i32 999900, i64 100, i32 1}
47+
!13 = !{i32 999999, i64 1, i32 2}
48+
!14 = !{!"function_entry_count", i64 7000}
49+
!15 = !{!"function_section_prefix", !"hot"}
50+
!17 = !{!"branch_weights", i32 7000, i32 0}

0 commit comments

Comments
 (0)