From: Andy Ayers Date: Fri, 21 Jul 2023 20:06:10 +0000 (-0700) Subject: Block inlining of IntroSort (#89310) X-Git-Tag: accepted/tizen/unified/riscv/20231226.055536~841 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=f79676ce92341e42875773d5ed855c76eda34ac5;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Block inlining of IntroSort (#89310) With PGO and (via #88749) one level of recursive inlining enabled, the jit sees the recursive call made by `IntroSort` as an attractive inline candidate, but it isn't. Fixes #89106. --- diff --git a/src/libraries/System.Private.CoreLib/src/System/Array.cs b/src/libraries/System.Private.CoreLib/src/System/Array.cs index 313b064..cecfcf1 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Array.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Array.cs @@ -2207,6 +2207,9 @@ namespace System } } + // IntroSort is recursive; block it from being inlined into itself as + // this is currenly not profitable. + [MethodImpl(MethodImplOptions.NoInlining)] private void IntroSort(int lo, int hi, int depthLimit) { Debug.Assert(hi >= lo); @@ -2421,6 +2424,9 @@ namespace System } } + // IntroSort is recursive; block it from being inlined into itself as + // this is currenly not profitable. + [MethodImpl(MethodImplOptions.NoInlining)] private void IntroSort(int lo, int hi, int depthLimit) { Debug.Assert(hi >= lo); diff --git a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs index cf481d8..1d937f4 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Collections/Generic/ArraySortHelper.cs @@ -128,6 +128,9 @@ namespace System.Collections.Generic } } + // IntroSort is recursive; block it from being inlined into itself as + // this is currenly not profitable. + [MethodImpl(MethodImplOptions.NoInlining)] private static void IntroSort(Span keys, int depthLimit, Comparison comparer) { Debug.Assert(!keys.IsEmpty); @@ -402,6 +405,9 @@ namespace System.Collections.Generic j = t; } + // IntroSort is recursive; block it from being inlined into itself as + // this is currenly not profitable. + [MethodImpl(MethodImplOptions.NoInlining)] private static void IntroSort(Span keys, int depthLimit) { Debug.Assert(!keys.IsEmpty);