Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
166 commits
Select commit Hold shift + click to select a range
2768fd5
Merge pull request #118812 from agocke/rc1-mopup
agocke Aug 16, 2025
e2b61c7
[release/10.0-rc1] Introduce size-optimized IListSelect iterator (#11…
github-actions[bot] Aug 19, 2025
13f9524
[release/10.0-rc1] JIT: fix issue with EH clause class types for faul…
github-actions[bot] Aug 21, 2025
cbfd526
[release/10.0-rc1] Add trim analysis for implicit constructors (#118854)
github-actions[bot] Aug 21, 2025
11e7477
[release/10.0] Disable release assert on disallowed thread re-initial…
github-actions[bot] Aug 21, 2025
d934b8c
[release/10.0][Android] Avoid calling membarrier on older Android ver…
simonrozsival Aug 25, 2025
deae3d2
[Android] Normalize RSA no-padding output to modulus size to fix Veri…
github-actions[bot] Aug 26, 2025
eb88d37
[mono][aot] Fix minor gsharedvt leaks (#119057)
github-actions[bot] Aug 26, 2025
8f5d15a
- delay setting close to receive_status_ptr to not conflict with on-m…
github-actions[bot] Aug 26, 2025
adaec22
[release/10.0] Fix deadlock when creating threads from ModuleInitiali…
github-actions[bot] Aug 26, 2025
6c6dac8
[release/10.0] Fixup some Vector<T> function lookups to use the right…
github-actions[bot] Aug 26, 2025
4cf369e
[release/10.0] Avoid marking types as reflected on in CreateSpan (#11…
github-actions[bot] Aug 26, 2025
a4210ec
Add cast to ComAwareWeakReference rehydrate path (#119141)
github-actions[bot] Aug 27, 2025
718b1a9
[release/10.0] [NativeAOT] Fix floating pointer register unwinding on…
github-actions[bot] Aug 28, 2025
1151a7b
JIT: Use native sized indices in the backend for GetElement and WithE…
jakobbotsch Aug 28, 2025
fcde651
Clear TS_GCSuspendRedirected at the end of thread redirection (#119168)
github-actions[bot] Aug 28, 2025
77154d0
[release/10.0] JIT: Consistently DNER promoted parameters on arm32 (#…
github-actions[bot] Aug 28, 2025
1dc2902
Merge pull request #118890 from dotnet/merge/release/10.0-rc1-to-rele…
ViktorHofer Aug 28, 2025
cdfae41
[NativeAOT] Adjust SSP to match RSP of the throw site (#119194)
github-actions[bot] Aug 29, 2025
c2b36dc
[release/10.0] JIT: Disallow widening tailcalls in async functions (#…
github-actions[bot] Aug 29, 2025
39349e8
[release/10.0] Implement UnhandledException hook for finalizer scenar…
github-actions[bot] Aug 29, 2025
91276c8
[release/10.0] Throttle finalization a bit when doing GC stress. (#11…
github-actions[bot] Aug 29, 2025
001eb1f
Backflow from https://github.com/dotnet/dotnet / 7ac1ca6 build 281128
dotnet-maestro[bot] Sep 1, 2025
fbcaa95
Merge release/10.0 into darc-release/10.0-73ddbe27-f88a-40c0-8d5e-4f7…
dotnet-maestro[bot] Sep 1, 2025
997770f
Update dependencies from https://github.com/dotnet/dotnet build 281128
dotnet-maestro[bot] Sep 1, 2025
3669880
Update path to Microsoft.CodeAnalysis.NetAnalyzers.dll
ericstj Aug 20, 2025
d201857
Make tests clear out DOTNET_ROOT_<arch> when clearing DOTNET_ROOT
elinor-fung Aug 29, 2025
d3ff91a
Fix environment variable casing
elinor-fung Aug 29, 2025
728cf42
[release/10.0] Fix elfreader for android (#119191)
github-actions[bot] Sep 1, 2025
def63fe
[release/10.0] Add trim analyzer support for C# 14 extensions (#119195)
sbomer Sep 1, 2025
7ed142b
Merge pull request #119242 from dotnet/darc-release/10.0-73ddbe27-f88…
ViktorHofer Sep 1, 2025
2f01f72
Merge pull request #119261 from dotnet/backport/pr-119260-to-release/…
github-actions[bot] Sep 2, 2025
a1556fc
Trying to fix issue when vmModule is not assigned (#119063)
github-actions[bot] Sep 2, 2025
52de59d
[release/10.0] limit regions_range to 2x physical_mem for WKS (#119192)
github-actions[bot] Sep 2, 2025
5add7e2
[release/10.0] [browser] Append uniqueness to webcil temp path & move…
github-actions[bot] Sep 2, 2025
27371e4
Remove type constraint on IEquatable<T> for ThrowIfEqual and ThrowIfN…
github-actions[bot] Sep 2, 2025
8f771e6
[release/10.0] Improve compat for low rights users loading CAPI machi…
github-actions[bot] Sep 2, 2025
f0e957b
JIT: fix crash in LSRA seen on VMR build on AVX-512 machines (#119270)
github-actions[bot] Sep 3, 2025
15e9838
Preserve lock id members (#119283)
github-actions[bot] Sep 3, 2025
13276b6
[release/10.0] [wasm] Use lightweight marshal for enums (#119296)
github-actions[bot] Sep 3, 2025
81e8e84
Use DllImportSearchPath.AssemblyDirectory for loading jitinterface li…
github-actions[bot] Sep 3, 2025
ba62724
[mono][aot] Avoid use of local buffer that could overflow (#119202)
github-actions[bot] Sep 4, 2025
b7ffc01
[release/10.0] [S390X] Add simd fallback support for unsupported s390…
github-actions[bot] Sep 4, 2025
8c45b3d
[release/10.0] Update Microsoft.NETCore.CoreDisTools nuget package fr…
github-actions[bot] Sep 5, 2025
c5ffe27
[release/10.0] JIT: handle commas during inline return value substitu…
github-actions[bot] Sep 5, 2025
6883bb2
Use a SafeHandle when duplicating a certificate context. (#119372)
github-actions[bot] Sep 5, 2025
30c0d6c
[release/10.0] Source code updates from dotnet/dotnet (#119378)
dotnet-maestro[bot] Sep 8, 2025
a10c6d1
[release/10.0] Limit doublemapper maximum size (#119392)
github-actions[bot] Sep 8, 2025
9b91562
[release/10.0] Non-zero result of Vector3.Cross with parallel vectors…
github-actions[bot] Sep 8, 2025
52dec22
[release/10.0] [HTTP] Stress fix for docker compose (#119453)
github-actions[bot] Sep 10, 2025
8e47552
[release/10.0] Source code updates from dotnet/dotnet (#119476)
dotnet-maestro[bot] Sep 10, 2025
0338543
[release/10.0] Move MLDsa Experimental to appropriate members (#119515)
github-actions[bot] Sep 10, 2025
c2afc88
Fix NoCallback_RevokedCertificate_RevocationChecking_Fails test (#119…
github-actions[bot] Sep 10, 2025
043fcd5
[release/10.0] Fix ProfileEnter when called on a foreign thread (#119…
github-actions[bot] Sep 11, 2025
facd855
JIT: Handle more unsupported argument conversion cases (#119388)
jakobbotsch Sep 11, 2025
9ca7546
[release/10.0] Fix file size estimation when bundling symlinks (#119406)
github-actions[bot] Sep 11, 2025
a26121b
Propagate DynamicallyAccessedMembers annotations to auto-properties o…
jtschuster Sep 11, 2025
9680646
fix dac_gc_heap marshalling (#119471)
github-actions[bot] Sep 11, 2025
1c1e696
Update dependencies from https://github.com/dotnet/dotnet build 28270…
dotnet-maestro[bot] Sep 11, 2025
b801537
Remove IList.Contains use from OfType (#119608)
github-actions[bot] Sep 12, 2025
012f08c
Do not check status, it's irrelevant whether to asses if H/3 is worki…
github-actions[bot] Sep 13, 2025
ade1312
Update dependencies from https://github.com/dotnet/dotnet build 28297…
dotnet-maestro[bot] Sep 15, 2025
ba9910b
Disable DisableUnusedRsaPadding_Connects/DisableUsedRsaPadding_Throws…
github-actions[bot] Sep 15, 2025
0d4089a
[release/10.0] [OSX] ip_mreqn struct is not supported for IPv4 Multic…
github-actions[bot] Sep 15, 2025
4fab3df
[EventPipe][UserEvents] Allow empty tracepoint sets (#119666)
github-actions[bot] Sep 15, 2025
9350471
[release/10.0] Update dependencies from dnceng/internal/dotnet-optimi…
dotnet-maestro[bot] Sep 15, 2025
60a735e
[release/10.0] Update dependencies from dotnet/hotreload-utils, dotne…
dotnet-maestro[bot] Sep 15, 2025
dbe938a
Update dependencies from https://github.com/dotnet/dotnet build 28315…
dotnet-maestro[bot] Sep 16, 2025
3859ce1
Update dependencies from https://github.com/dotnet/dotnet build 28342…
dotnet-maestro[bot] Sep 17, 2025
a01b8f7
[release/10.0] Update dependencies from dotnet/icu (#118804)
dotnet-maestro[bot] Sep 17, 2025
52acd47
[release/10.0] Update dependencies from dotnet/xharness (#118831)
dotnet-maestro[bot] Sep 17, 2025
5cbec44
Fix trace state key parsing in W3C propagator to support digits (#119…
github-actions[bot] Sep 17, 2025
ebaebee
[release/10.0] Fix Tensor.StdDev vs TensorPrimitives.StdDev differenc…
github-actions[bot] Sep 17, 2025
7587124
Update dependencies from https://github.com/dotnet/dotnet build 28366…
dotnet-maestro[bot] Sep 18, 2025
3c270fd
[QUIC] Update Windows MsQuic (#119764)
ManickaP Sep 18, 2025
7fc469a
Prevent format injection in hosting Windows PAL printf functions when…
github-actions[bot] Sep 18, 2025
0657225
Set IDE0031 to suggestion in eng/CodeAnalysis.src.globalconfig (#119755)
akoeplinger Sep 18, 2025
68641b5
[release/10.0] [System.Native] check `ro.build.version.sdk_full` for …
github-actions[bot] Sep 18, 2025
5b71e44
Fix duplicate PDB in packages that specify IncludeSymbolsInPackage (#…
github-actions[bot] Sep 19, 2025
d48349d
[release/10.0] Don't warn if we can't find the backing field in trim …
jtschuster Sep 19, 2025
8ca6013
Migrate to WiX 5 (#117010) (#119884)
PranavSenthilnathan Sep 19, 2025
2c5b43c
[release/10.0] Don't try to offer a conversion to SG COM when propert…
github-actions[bot] Sep 19, 2025
c2a2017
[C++/CLI] Correctly handle the unmanaged this arg for thiscall in x86…
github-actions[bot] Sep 20, 2025
fc48aeb
[release/10.0] Consider all MemberInfo references for IsCollectible (…
jkotas Sep 20, 2025
1e72b83
[release/10.0] Fix restore of contexts in async task returning thunks…
github-actions[bot] Sep 20, 2025
9dd91fa
Update dependencies from https://github.com/dotnet/dotnet build 28382…
dotnet-maestro[bot] Sep 21, 2025
2b1d77b
Update dependencies from https://github.com/dotnet/xharness build 202…
dotnet-maestro[bot] Sep 22, 2025
878caef
[release/10.0] Revert Entitlement related changes from #116659 (#119920)
github-actions[bot] Sep 22, 2025
d8b4808
[release/10.0] Fix unloadability issue (#119469)
github-actions[bot] Sep 22, 2025
a6f6bd4
Allow disabling runtime versions via an environment variable (#119343…
elinor-fung Sep 22, 2025
e94db21
Update dependencies from https://dev.azure.com/dnceng/internal/_git/d…
dotnet-maestro[bot] Sep 22, 2025
5c142a6
SPKI and PKCS8 for Composite ML-DSA (#119837) (#119914)
PranavSenthilnathan Sep 22, 2025
a83ae91
[release/10.0] [RuntimeAsync] A few fixes for issues found when enabl…
github-actions[bot] Sep 22, 2025
aca665f
[release/10.0] Fix the Syndication Feed RFC822 DateTimeParser (#119918)
github-actions[bot] Sep 22, 2025
8836d01
Fix ReadContentAsDateTime method to keep DateTimeKind (#119917)
github-actions[bot] Sep 22, 2025
78c049d
[release/10.0] Fix ObsoleteAttribute incorrectly causing XML serializ…
github-actions[bot] Sep 22, 2025
b4b0551
Add documentation for `CompilerLoweringPreserveAttribute`. (#119963)
github-actions[bot] Sep 22, 2025
b72cc40
[release/10.0] [mono] Make the compressed interface bitmap feature us…
BrzVlad Sep 22, 2025
b5331b4
[release/10.0] [DAC] Properly dereference `internal_root_array` (#119…
github-actions[bot] Sep 22, 2025
734fa7b
JIT: Add missing containment check for indirect calls (#119812)
github-actions[bot] Sep 22, 2025
9749add
[release/10.0] Revert "JIT: Remove side effect detection quirk in loo…
github-actions[bot] Sep 22, 2025
0abfd87
[release/10.0] Implement out-of-process SetThreadContext support for …
github-actions[bot] Sep 22, 2025
7365770
[release/10.0] Fix DefaultIfEmptyIterator.TryGetElementAt returning d…
github-actions[bot] Sep 23, 2025
afbe4d2
Update dependencies from https://github.com/dotnet/icu build 20250922…
dotnet-maestro[bot] Sep 23, 2025
1e004d9
[release/10.0] Use unpredicated movprfx with SVE2 fminnmp and fmaxnmp…
github-actions[bot] Sep 24, 2025
f9b7826
[release/10.0] Fix codegen for SVE Scatter*With*Offsets* and GatherVe…
SwapnilGaikwad Sep 24, 2025
d925d45
[release/10.0] Add DateOnly and TimeOnly serializer primitives with r…
github-actions[bot] Sep 24, 2025
d8e71a4
[release/10.0] Ignore re-typed lcl in optAssertionPropLocal_RelOp (#1…
github-actions[bot] Sep 24, 2025
75890de
[release/10.0] check ImmedValNeedsReloc in genCreateAddrMode (#119757)
github-actions[bot] Sep 24, 2025
27a3d92
[release/10.0] [NativeAOT] Fix resetting apartment state (#119993)
github-actions[bot] Sep 24, 2025
70801b2
[release/10.0-rc2] Add DateOnly and TimeOnly serializer primitives wi…
StephenMolloy Sep 24, 2025
5d8ce2e
[release/10.0-rc2] Source code updates from dotnet/dotnet (#120087)
dotnet-maestro[bot] Sep 25, 2025
a890075
[release/10.0] Fix race condition when createdump tries to read /proc…
github-actions[bot] Sep 25, 2025
d51f619
[release/10.0] `UnsafeAccessor` - ambiguous name and signature match …
github-actions[bot] Sep 25, 2025
2bbfcee
Revert unhandled exception logic to prevent multiple calls. (#120103)
github-actions[bot] Sep 25, 2025
7f2f91c
[release/10.0] Add test for issue #114813 (#120088)
github-actions[bot] Sep 26, 2025
812c6ca
[release/10.0] Add test coverage for issue #99193 (#120089)
github-actions[bot] Sep 26, 2025
9743146
Fix RoundTrip_Export_Import_SPKI and fix typos for SPKI (#120102)
github-actions[bot] Sep 26, 2025
91a6ee0
[release/10.0] Update Composite ML-DSA to draft 8 (#120117)
github-actions[bot] Sep 26, 2025
ec27556
[release/10.0] [PERF] Remove hybrid globalization from iOS perf scena…
github-actions[bot] Sep 26, 2025
4c588fe
[release/10.0] Test for unloadable ALC frees file lock (#120122)
github-actions[bot] Sep 26, 2025
ce2a70d
Don't set access control if the mutex is not initially owned (#120115)
github-actions[bot] Sep 26, 2025
e04af3c
[release/10.0] Fix ResourceUpdater.Dispose() (#120136)
github-actions[bot] Sep 26, 2025
9c2d0e1
[release/10.0] Properly enumerate uninstrumented bounds when stackwal…
github-actions[bot] Sep 30, 2025
978bd06
[release/10.0] Source code updates from dotnet/dotnet (#120082)
dotnet-maestro[bot] Sep 30, 2025
4f6790b
Update dependencies from https://github.com/dotnet/xharness build 202…
dotnet-maestro[bot] Sep 30, 2025
810a76f
Load Standalone GC correctly in component scenarios. (#120235)
github-actions[bot] Sep 30, 2025
cc5f4c0
[release/10.0-rc2] [browser] Expect fingerprint in dotnet.native.wasm…
github-actions[bot] Oct 1, 2025
ac87618
Remove an STJ deep nested object test causing StackOverflow failures …
github-actions[bot] Oct 1, 2025
881a617
Update dependencies from https://github.com/dotnet/hotreload-utils bu…
dotnet-maestro[bot] Oct 2, 2025
2145b62
[release/10.0] Source code updates from dotnet/dotnet (#120286)
dotnet-maestro[bot] Oct 3, 2025
c0368f5
include memory required to do MethodDefLookup in minidumps (#120148)
github-actions[bot] Oct 3, 2025
72afd43
Backport 120366 to release/10.0 (#120381)
vcsjones Oct 3, 2025
1e4efee
[release/10.0] [mono][hotreload] Make the runtime ignore an update if…
github-actions[bot] Oct 4, 2025
617d3b2
[release/10.0] Bump OSX.12 helix queues to OSX.13 (#119989)
github-actions[bot] Oct 4, 2025
56a61b3
Revert "Use a ReaderWriterLockSlim in RcwCache (#117792)" (#120372)
github-actions[bot] Oct 6, 2025
1e7adf6
[release/10.0] Fix CopyOSContext on amd64 (#120329)
github-actions[bot] Oct 6, 2025
468465c
[release/10.0] Move coreclr EH second pass to native code (#120263)
janvorli Oct 6, 2025
c605463
[release/10.0] Add proper locking in TranslateSigHelper (#120158)
github-actions[bot] Oct 6, 2025
b4542a6
[release/10.0] JIT: Fix heap allocations (#120323)
github-actions[bot] Oct 6, 2025
f2ec4f7
[release/10.0] Localize WiX files (#120385)
PranavSenthilnathan Oct 6, 2025
05a3a9b
[release/10.0] Limit the use of a pointer to the lexical scope of the…
github-actions[bot] Oct 6, 2025
c974ad6
Update dependencies from https://dev.azure.com/dnceng/internal/_git/d…
dotnet-maestro[bot] Oct 7, 2025
60e9bd7
Update dependencies from https://github.com/dotnet/icu build 20251002…
dotnet-maestro[bot] Oct 7, 2025
d321bc6
[mono][aot] Increase the max symbol size (#120295)
github-actions[bot] Oct 8, 2025
9a6bee3
[release/10.0-rc2] Source code updates from dotnet/dotnet (#120126)
dotnet-maestro[bot] Oct 9, 2025
13aa853
Revert conditionally setting SYSTEM PATH in host install (#118092) (#…
github-actions[bot] Oct 9, 2025
647691b
[release/10.0] [browser] Expect fingerprint on assemblies promoted fr…
github-actions[bot] Oct 10, 2025
92036e4
JIT: Skip bitcast transformation for promoted locals (#120464)
github-actions[bot] Oct 10, 2025
5d4e4b0
[release/10.0] Fix race on DomainAssembly/Assembly/Module creation th…
github-actions[bot] Oct 10, 2025
a402595
[release/10.0] Avoid referencing types of JsonIgnore'd properties. (#…
github-actions[bot] Oct 11, 2025
c527b09
[release/10.0] Fix issue with array interface devirtualization (#120371)
github-actions[bot] Oct 13, 2025
7d43e0f
[release/10.0] Add MetadataUpdateDeletedAttribute and Reflection Filt…
jeffhandley Oct 14, 2025
2567739
Fix ARM64 ThreadAbort issue (#120579)
github-actions[bot] Oct 14, 2025
2db0789
[release/10.0] Set PRERELEASE to 0 (#120693)
jkotas Oct 15, 2025
0bb50b9
Merge remote-tracking branch 'upstream/release/10.0-rc2' into merge-r…
akoeplinger Oct 15, 2025
9756c8e
[release/10.0] Fix localization of links in runtime bundle (#120721)
PranavSenthilnathan Oct 15, 2025
1030751
Merge release/10.0-rc2 into release/10.0 (#120743)
ViktorHofer Oct 16, 2025
43b7b37
[release/10.0] Update dependencies from dotnet/xharness (#120655)
dotnet-maestro[bot] Oct 16, 2025
e694305
[release/10.0] Source code updates from dotnet/dotnet (#120521)
dotnet-maestro[bot] Oct 16, 2025
0ada13f
[release/10.0] [browser] Expect fingerprint on dotnet.js for preloadi…
github-actions[bot] Oct 17, 2025
7f46a7e
[release/10.0] Fix Tensor.Reshape with wildcard (#120806)
github-actions[bot] Oct 17, 2025
e055281
[release/10.0] Fix balancing groups incorrectly removed from negative…
github-actions[bot] Oct 20, 2025
60629d1
[release/10.0] Mark labels in x64 write barrier code as local/alt_ent…
github-actions[bot] Oct 22, 2025
6d0c7d7
[release/10.0] Address upcoming breaking change for span-valued colle…
github-actions[bot] Oct 29, 2025
3cce53a
Update Windows version of MsQuic
ManickaP Oct 30, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[release/10.0] Revert "JIT: Remove side effect detection quirk in loo…
…p hoisting (#118463)" with some improvements (#119346)

* Revert "JIT: Remove side effect detection quirk in loop hoisting (#118463)"

This reverts commit e0b14e9. That
change is not correct as it removes the safe guard that prevents
hoisting out of conditionally executed blocks.

* Add test

* Rename m_beforeSideEffect -> m_canHoistSideEffects

* Fix comment

* Move some code around

---------

Co-authored-by: Jakob Botsch Nielsen <jakob.botsch.nielsen@gmail.com>
  • Loading branch information
github-actions[bot] and jakobbotsch authored Sep 22, 2025
commit 9749addaffe6fbbd3e83eb307657fac748be3b6c
116 changes: 66 additions & 50 deletions src/coreclr/jit/optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3655,12 +3655,21 @@ bool Compiler::optHoistThisLoop(FlowGraphNaturalLoop* loop, LoopHoistContext* ho
}
#endif // FEATURE_MASKED_HW_INTRINSICS

// Find the set of definitely-executed blocks. These will be given priority for hoisting.
// Find the set of definitely-executed blocks.
// Ideally, the definitely-executed blocks are the ones that post-dominate the entry block.
// Until we have post-dominators, we'll special-case for single-exit blocks.
//
// TODO: We ought to consider hoisting more aggressively from conditionally executed blocks,
// if they are frequently executed and it is safe to evaluate the tree early.
// Todo: it is not clear if this is a correctness requirement or a profitability heuristic.
// It seems like the latter. Ideally there are enough safeguards to prevent hoisting exception
// or side-effect dependent things. Note that HoistVisitor uses `m_canHoistSideEffects` to determine if it's
// ok to hoist a side-effect. It allows this only for the first block (the entry block), before any
// side-effect has been seen. After the first block, it assumes that there has been a side effect and
// no further side-effect can be hoisted. It is true that we don't analyze any program behavior in the
// flow graph between the entry block and the subsequent blocks, whether they be the next block dominating
// the exit block, or the pre-headers of nested loops.
//
// We really should consider hoisting from conditionally executed blocks, if they are frequently executed
// and it is safe to evaluate the tree early.
//
assert(m_dfsTree != nullptr);
BitVecTraits traits(m_dfsTree->PostOrderTraits());
Expand Down Expand Up @@ -4116,7 +4125,7 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
};

ArrayStack<Value> m_valueStack;
bool m_beforeSideEffect;
bool m_canHoistSideEffects;
FlowGraphNaturalLoop* m_loop;
LoopHoistContext* m_hoistContext;
BasicBlock* m_currentBlock;
Expand Down Expand Up @@ -4251,7 +4260,7 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
BitVec defExec)
: GenTreeVisitor(compiler)
, m_valueStack(compiler->getAllocator(CMK_LoopHoist))
, m_beforeSideEffect(true)
, m_canHoistSideEffects(true)
, m_loop(loop)
, m_hoistContext(hoistContext)
, m_currentBlock(nullptr)
Expand All @@ -4263,26 +4272,46 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
void HoistBlock(BasicBlock* block)
{
m_currentBlock = block;
for (Statement* const stmt : block->NonPhiStatements())
{
WalkTree(stmt->GetRootNodePointer(), nullptr);
Value& top = m_valueStack.TopRef();
assert(top.Node() == stmt->GetRootNode());

// hoist the top node?
if (top.m_hoistable)
{
const bool defExecuted = BitVecOps::IsMember(m_traits, m_defExec, block->bbPostorderNum);
m_compiler->optHoistCandidate(stmt->GetRootNode(), block, m_loop, m_hoistContext, defExecuted);
}
else
const weight_t blockWeight = block->getBBWeight(m_compiler);

JITDUMP("\n HoistBlock " FMT_BB " (weight=%6s) of loop " FMT_LP " (head: " FMT_BB ")\n", block->bbNum,
refCntWtd2str(blockWeight, /* padForDecimalPlaces */ true), m_loop->GetIndex(),
m_loop->GetHeader()->bbNum);

if (blockWeight < (BB_UNITY_WEIGHT / 10))
{
JITDUMP(" block weight is too small to perform hoisting.\n");
}
else
{
for (Statement* const stmt : block->NonPhiStatements())
{
JITDUMP(" [%06u] %s: %s\n", dspTreeID(top.Node()),
top.m_invariant ? "not hoistable" : "not invariant", top.m_failReason);
}
WalkTree(stmt->GetRootNodePointer(), nullptr);
Value& top = m_valueStack.TopRef();
assert(top.Node() == stmt->GetRootNode());

m_valueStack.Reset();
// hoist the top node?
if (top.m_hoistable)
{
const bool defExecuted = BitVecOps::IsMember(m_traits, m_defExec, block->bbPostorderNum);
m_compiler->optHoistCandidate(stmt->GetRootNode(), block, m_loop, m_hoistContext, defExecuted);
}
else
{
JITDUMP(" [%06u] %s: %s\n", dspTreeID(top.Node()),
top.m_invariant ? "not hoistable" : "not invariant", top.m_failReason);
}

m_valueStack.Reset();
}
}

assert(!m_canHoistSideEffects || (block == m_loop->GetHeader()));
// After visiting the first block (which is expected to always be
// the loop header) we can no longer hoist out side effecting trees
// as the next blocks could be conditionally executed.
m_canHoistSideEffects = false;
}

fgWalkResult PreOrderVisit(GenTree** use, GenTree* user)
Expand Down Expand Up @@ -4458,10 +4487,11 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,

if (treeIsHoistable)
{
if (!m_beforeSideEffect)
if (!m_canHoistSideEffects)
{
// For now, we give up on an expression that might raise an exception if it is after the
// first possible global side effect.
// first possible global side effect (and we assume we're after that if we're not in the first
// block).
// TODO-CQ: this is when we might do loop cloning.
//
if ((tree->gtFlags & GTF_EXCEPT) != 0)
Expand All @@ -4484,24 +4514,24 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
}
}

// Next check if we need to set 'm_beforeSideEffect' to false.
// Next check if we need to set 'm_canHoistSideEffects' to false.
//
// If we have already set it to false then we can skip these checks
//
if (m_beforeSideEffect)
if (m_canHoistSideEffects)
{
// Is the value of the whole tree loop invariant?
if (!treeIsInvariant)
{
// We have a tree that is not loop invariant and we thus cannot hoist
assert(treeIsHoistable == false);

// Check if we should clear m_beforeSideEffect.
// If 'tree' can throw an exception then we need to set m_beforeSideEffect to false.
// Check if we should clear m_canHoistSideEffects.
// If 'tree' can throw an exception then we need to set m_canHoistSideEffects to false.
// Note that calls are handled below
if (tree->OperMayThrow(m_compiler) && !tree->IsCall())
{
m_beforeSideEffect = false;
m_canHoistSideEffects = false;
}
}

Expand All @@ -4517,19 +4547,19 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
GenTreeCall* call = tree->AsCall();
if (!call->IsHelperCall())
{
m_beforeSideEffect = false;
m_canHoistSideEffects = false;
}
else
{
CorInfoHelpFunc helpFunc = eeGetHelperNum(call->gtCallMethHnd);
if (s_helperCallProperties.MutatesHeap(helpFunc))
{
m_beforeSideEffect = false;
m_canHoistSideEffects = false;
}
else if (s_helperCallProperties.MayRunCctor(helpFunc) &&
(call->gtFlags & GTF_CALL_HOISTABLE) == 0)
{
m_beforeSideEffect = false;
m_canHoistSideEffects = false;
}

// Additional check for helper calls that throw exceptions
Expand All @@ -4541,7 +4571,7 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
// Does this helper call throw?
if (!s_helperCallProperties.NoThrow(helpFunc))
{
m_beforeSideEffect = false;
m_canHoistSideEffects = false;
}
}
}
Expand All @@ -4562,8 +4592,8 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
if (isGloballyVisibleStore)
{
INDEBUG(failReason = "store to globally visible memory");
treeIsHoistable = false;
m_beforeSideEffect = false;
treeIsHoistable = false;
m_canHoistSideEffects = false;
}
}
}
Expand Down Expand Up @@ -4667,22 +4697,8 @@ void Compiler::optHoistLoopBlocks(FlowGraphNaturalLoop* loop,
};

HoistVisitor visitor(this, loop, hoistContext, traits, defExecuted);
loop->VisitLoopBlocks([&](BasicBlock* block) -> BasicBlockVisit {
const weight_t blockWeight = block->getBBWeight(this);

JITDUMP("\n optHoistLoopBlocks " FMT_BB " (weight=%6s) of loop " FMT_LP " (head: " FMT_BB ")\n",
block->bbNum, refCntWtd2str(blockWeight, /* padForDecimalPlaces */ true), loop->GetIndex(),
loop->GetHeader()->bbNum);

if (blockWeight < (BB_UNITY_WEIGHT / 10))
{
JITDUMP(" block weight is too small to perform hoisting.\n");
}
else
{
visitor.HoistBlock(block);
}

loop->VisitLoopBlocksReversePostOrder([&](BasicBlock* block) -> BasicBlockVisit {
visitor.HoistBlock(block);
return BasicBlockVisit::Continue;
});

Expand Down
60 changes: 60 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_119061/Runtime_119061.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Numerics;
using System.Runtime.Intrinsics;
using Xunit;

public class Runtime_119061
{
private static C1 s_6 = new C1();

[Fact]
public static void TestEntryPoint()
{
s_6.F8 = new S0(-1);
var vr4 = s_6.F8.F0;
Vector128<short> vr6 = default(Vector128<short>);
M3(vr4, vr6);
}

private static ushort M3(int arg1, Vector128<short> arg2)
{
bool[] var0 = new bool[]
{
false
};
for (sbyte lvar1 = 10; lvar1 < 12; lvar1++)
{
if (var0[0])
{
var vr2 = (uint)(3329109910U / (-9223372036854775808L / (arg1 | 1)));
var vr1 = (short)BitOperations.LeadingZeroCount(vr2);
arg2 = Vector128.CreateScalar(vr1);
}
}

C0 vr8 = new C0();
return vr8.F1;
}

private struct S0
{
public int F0;
public S0(int f0) : this()
{
F0 = f0;
}
}

private class C0
{
public ushort F1;
}

private class C1
{
public S0 F8;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
Loading