diff --git a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp --- a/llvm/lib/CodeGen/MachineFunctionSplitter.cpp +++ b/llvm/lib/CodeGen/MachineFunctionSplitter.cpp @@ -204,7 +204,7 @@ if (MBB.isEHPad()) LandingPads.push_back(&MBB); - else if (UseProfileData && isColdBlock(MBB, MBFI, PSI)) + else if (UseProfileData && isColdBlock(MBB, MBFI, PSI) && !SplitAllEHCode) MBB.setSectionID(MBBSectionID::ColdSectionID); } diff --git a/llvm/test/CodeGen/X86/machine-function-splitter.ll b/llvm/test/CodeGen/X86/machine-function-splitter.ll --- a/llvm/test/CodeGen/X86/machine-function-splitter.ll +++ b/llvm/test/CodeGen/X86/machine-function-splitter.ll @@ -193,9 +193,9 @@ ;; Check that all ehpads are by default treated as cold with -mfs-split-ehcode. ; MFS-EH-SPLIT-LABEL: foo8 +; MFS-EH-SPLIT: callq baz ; MFS-EH-SPLIT: .section .text.split.foo8,"ax",@progbits ; MFS-EH-SPLIT-NEXT: foo8.cold: -; MFS-EH-SPLIT: callq baz ; MFS-EH-SPLIT: callq _Unwind_Resume@PLT ; MFS-EH-SPLIT: callq _Unwind_Resume@PLT entry: @@ -306,7 +306,7 @@ ; MFS-EH-SPLIT: callq qux entry: invoke void @_Z1fv() - to label %try.cont unwind label %lpad + to label %8 unwind label %lpad lpad: %1 = landingpad { ptr, i32 } @@ -314,8 +314,6 @@ catch ptr @_ZTIi br label %2 -try.cont: - br i1 %0, label %8, label %2, !prof !17 2: ; preds = lpad %3 = call i32 @bar() br i1 %0, label %4, label %6