Skip to content

Commit 356f66d

Browse files
committed
Merge remote-tracking branch 'upstream/main' into asynclinq
2 parents dc1c2b8 + 7d75878 commit 356f66d

34 files changed

+1454
-205
lines changed

eng/pipelines/runtime-ioslike.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,24 @@
44

55
trigger: none
66

7+
# To reduce the load on the pipeline, enable it only for PRs that affect Mono LLVM related code.
8+
pr:
9+
branches:
10+
include:
11+
- main
12+
- release/*.*
13+
14+
paths:
15+
include:
16+
- src/mono/mono/mini/aot-*.*
17+
- src/mono/mono/mini/llvm-*.*
18+
- src/mono/mono/mini/mini-llvm-*.*
19+
- src/mono/mono/mini/intrinsics.c
20+
- src/mono/mono/mini/simd-*.*
21+
- src/mono/mono/mini/decompose.c
22+
- src/mono/mono/mini/method-to-ir.c
23+
- src/mono/mono/mini/mini.c
24+
725
variables:
826
- template: /eng/pipelines/common/variables.yml
927

eng/pipelines/runtime-llvm.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,24 @@ schedules:
2828
- main
2929
always: false # run only if there were changes since the last successful scheduled run.
3030

31+
# To reduce the load on the pipeline, enable it only for PRs that affect Mono LLVM related code.
32+
pr:
33+
branches:
34+
include:
35+
- main
36+
- release/*.*
37+
38+
paths:
39+
include:
40+
- src/mono/mono/mini/aot-*.*
41+
- src/mono/mono/mini/llvm-*.*
42+
- src/mono/mono/mini/mini-llvm-*.*
43+
- src/mono/mono/mini/intrinsics.c
44+
- src/mono/mono/mini/simd-*.*
45+
- src/mono/mono/mini/decompose.c
46+
- src/mono/mono/mini/method-to-ir.c
47+
- src/mono/mono/mini/mini.c
48+
3149
variables:
3250
- template: /eng/pipelines/common/variables.yml
3351

src/coreclr/CMakeLists.txt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,10 +170,7 @@ endif(CLR_CMAKE_HOST_WIN32)
170170
#----------------------------------
171171
include(clrdefinitions.cmake)
172172

173-
if(FEATURE_STANDALONE_GC)
174-
add_definitions(-DFEATURE_STANDALONE_GC)
175-
add_subdirectory(gc)
176-
endif(FEATURE_STANDALONE_GC)
173+
add_subdirectory(gc)
177174

178175
if (CLR_CMAKE_HOST_UNIX)
179176
include_directories("pal/inc")

src/coreclr/gc/CMakeLists.txt

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
set(CMAKE_INCLUDE_CURRENT_DIR ON)
22

3-
# Local GC meta-issue: https://github.com/dotnet/runtime/issues/8061
4-
5-
# https://github.com/dotnet/runtime/issues/8059
6-
remove_definitions(-DSTRESS_HEAP)
7-
8-
# https://github.com/dotnet/runtime/issues/8062
9-
remove_definitions(-DWRITE_BARRIER_CHECK)
3+
if(FEATURE_STANDALONE_GC)
4+
add_definitions(-DFEATURE_STANDALONE_GC)
5+
remove_definitions(-DSTRESS_HEAP)
6+
remove_definitions(-DWRITE_BARRIER_CHECK)
7+
endif(FEATURE_STANDALONE_GC)
108

119
set(GC_SOURCES
1210
gceventstatus.cpp
@@ -100,37 +98,39 @@ list(APPEND GC_SOURCES ${GC_HEADERS})
10098

10199
convert_to_absolute_path(GC_SOURCES ${GC_SOURCES})
102100

103-
# clrgcexp is build with standalone+regions
104-
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
105-
add_library_clr(clrgcexp SHARED ${GC_SOURCES})
106-
add_dependencies(clrgcexp eventing_headers)
107-
target_link_libraries(clrgcexp PRIVATE ${GC_LINK_LIBRARIES})
108-
target_compile_definitions(clrgcexp PRIVATE -DUSE_REGIONS)
109-
install_clr(TARGETS clrgcexp DESTINATIONS . COMPONENT runtime)
110-
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
111-
112-
# clrgc is build with standalone+segments
113-
add_library_clr(clrgc SHARED ${GC_SOURCES})
114-
add_dependencies(clrgc eventing_headers)
115-
target_link_libraries(clrgc PRIVATE ${GC_LINK_LIBRARIES})
116-
install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime)
117-
118-
add_definitions(-DBUILD_AS_STANDALONE)
119-
add_definitions(-DFEATURE_CONSERVATIVE_GC)
120-
121-
add_definitions(-DFX_VER_INTERNALNAME_STR=clrgc.dll)
122-
add_definitions(-DVERIFY_HEAP)
123-
if(CLR_CMAKE_HOST_APPLE)
124-
# The implementation of GCToOSInterface on Apple platforms makes use of non-POSIX
125-
# pthreads APIs, which by default are not included in the pthreads header
126-
# unless we define this macro.
127-
add_definitions(-D_DARWIN_C_SOURCE)
128-
endif(CLR_CMAKE_HOST_APPLE)
129-
130-
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
131-
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/env)
132-
133-
install_clr(TARGETS clrgc DESTINATIONS . sharedFramework COMPONENT runtime)
134-
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
135-
install_clr(TARGETS clrgcexp DESTINATIONS . sharedFramework COMPONENT runtime)
136-
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
101+
if(FEATURE_STANDALONE_GC)
102+
# clrgcexp is build with standalone+regions
103+
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
104+
add_library_clr(clrgcexp SHARED ${GC_SOURCES})
105+
add_dependencies(clrgcexp eventing_headers)
106+
target_link_libraries(clrgcexp PRIVATE ${GC_LINK_LIBRARIES})
107+
target_compile_definitions(clrgcexp PRIVATE -DUSE_REGIONS)
108+
install_clr(TARGETS clrgcexp DESTINATIONS . COMPONENT runtime)
109+
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
110+
111+
# clrgc is build with standalone+segments
112+
add_library_clr(clrgc SHARED ${GC_SOURCES})
113+
add_dependencies(clrgc eventing_headers)
114+
target_link_libraries(clrgc PRIVATE ${GC_LINK_LIBRARIES})
115+
install_clr(TARGETS clrgc DESTINATIONS . COMPONENT runtime)
116+
117+
add_definitions(-DBUILD_AS_STANDALONE)
118+
add_definitions(-DFEATURE_CONSERVATIVE_GC)
119+
120+
add_definitions(-DFX_VER_INTERNALNAME_STR=clrgc.dll)
121+
add_definitions(-DVERIFY_HEAP)
122+
if(CLR_CMAKE_HOST_APPLE)
123+
# The implementation of GCToOSInterface on Apple platforms makes use of non-POSIX
124+
# pthreads APIs, which by default are not included in the pthreads header
125+
# unless we define this macro.
126+
add_definitions(-D_DARWIN_C_SOURCE)
127+
endif(CLR_CMAKE_HOST_APPLE)
128+
129+
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
130+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/env)
131+
132+
install_clr(TARGETS clrgc DESTINATIONS . sharedFramework COMPONENT runtime)
133+
if (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
134+
install_clr(TARGETS clrgcexp DESTINATIONS . sharedFramework COMPONENT runtime)
135+
endif (CLR_CMAKE_TARGET_ARCH_ARM64 OR CLR_CMAKE_TARGET_ARCH_AMD64)
136+
endif(FEATURE_STANDALONE_GC)

src/coreclr/jit/block.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1197,6 +1197,18 @@ struct BasicBlock : private LIR::Range
11971197
// getBBWeight -- get the normalized weight of this block
11981198
weight_t getBBWeight(Compiler* comp) const;
11991199

1200+
// computeIncomingWeight -- sum the weights of the flow edges into this block
1201+
weight_t computeIncomingWeight() const
1202+
{
1203+
weight_t incomingWeight = BB_ZERO_WEIGHT;
1204+
for (FlowEdge* const predEdge : PredEdges())
1205+
{
1206+
incomingWeight += predEdge->getLikelyWeight();
1207+
}
1208+
1209+
return incomingWeight;
1210+
}
1211+
12001212
// hasProfileWeight -- Returns true if this block's weight came from profile data
12011213
bool hasProfileWeight() const
12021214
{

src/coreclr/jit/compiler.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5127,6 +5127,9 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
51275127
// Expand thread local access
51285128
DoPhase(this, PHASE_EXPAND_TLS, &Compiler::fgExpandThreadLocalAccess);
51295129

5130+
// Expand stack allocated arrays
5131+
DoPhase(this, PHASE_EXPAND_STACK_ARR, &Compiler::fgExpandStackArrayAllocations);
5132+
51305133
// Insert GC Polls
51315134
DoPhase(this, PHASE_INSERT_GC_POLLS, &Compiler::fgInsertGCPolls);
51325135

@@ -5153,6 +5156,11 @@ void Compiler::compCompile(void** methodCodePtr, uint32_t* methodCodeSize, JitFl
51535156
DoPhase(this, PHASE_SWITCH_RECOGNITION, &Compiler::optSwitchRecognition);
51545157
}
51555158

5159+
// Drop back to just checking profile likelihoods.
5160+
//
5161+
activePhaseChecks &= ~PhaseChecks::CHECK_PROFILE;
5162+
activePhaseChecks |= PhaseChecks::CHECK_LIKELIHOODS;
5163+
51565164
#ifdef DEBUG
51575165
// Stash the current estimate of the function's size if necessary.
51585166
if (verbose && opts.OptimizationEnabled())

src/coreclr/jit/compiler.h

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -691,8 +691,8 @@ class LclVarDsc
691691
unsigned char lvSingleDefDisqualifyReason = 'H';
692692
#endif
693693

694-
unsigned char lvAllDefsAreNoGc : 1; // For pinned locals: true if all defs of this local are no-gc
695-
unsigned char lvStackAllocatedBox : 1; // Local is a stack allocated box
694+
unsigned char lvAllDefsAreNoGc : 1; // For pinned locals: true if all defs of this local are no-gc
695+
unsigned char lvStackAllocatedObject : 1; // Local is a stack allocated object (class, box, array, ...)
696696

697697
#if FEATURE_MULTIREG_ARGS
698698
regNumber lvRegNumForSlot(unsigned slotNum)
@@ -807,9 +807,9 @@ class LclVarDsc
807807
return lvIsMultiRegArg || lvIsMultiRegRet;
808808
}
809809

810-
bool IsStackAllocatedBox() const
810+
bool IsStackAllocatedObject() const
811811
{
812-
return lvStackAllocatedBox;
812+
return lvStackAllocatedObject;
813813
}
814814

815815
#if defined(DEBUG)
@@ -6106,6 +6106,9 @@ class Compiler
61066106
PhaseStatus fgExpandStaticInit();
61076107
bool fgExpandStaticInitForCall(BasicBlock** pBlock, Statement* stmt, GenTreeCall* call);
61086108

6109+
PhaseStatus fgExpandStackArrayAllocations();
6110+
bool fgExpandStackArrayAllocation(BasicBlock* pBlock, Statement* stmt, GenTreeCall* call);
6111+
61096112
PhaseStatus fgVNBasedIntrinsicExpansion();
61106113
bool fgVNBasedIntrinsicExpansionForCall(BasicBlock** pBlock, Statement* stmt, GenTreeCall* call);
61116114
bool fgVNBasedIntrinsicExpansionForCall_ReadUtf8(BasicBlock** pBlock, Statement* stmt, GenTreeCall* call);
@@ -7537,6 +7540,7 @@ class Compiler
75377540
#define OMF_HAS_SPECIAL_INTRINSICS 0x00020000 // Method contains special intrinsics expanded in late phases
75387541
#define OMF_HAS_RECURSIVE_TAILCALL 0x00040000 // Method contains recursive tail call
75397542
#define OMF_HAS_EXPANDABLE_CAST 0x00080000 // Method contains casts eligible for late expansion
7543+
#define OMF_HAS_STACK_ARRAY 0x00100000 // Method contains stack allocated arrays
75407544

75417545
// clang-format on
75427546

@@ -7627,6 +7631,16 @@ class Compiler
76277631
optMethodFlags |= OMF_HAS_RECURSIVE_TAILCALL;
76287632
}
76297633

7634+
bool doesMethodHaveStackAllocatedArray()
7635+
{
7636+
return (optMethodFlags & OMF_HAS_STACK_ARRAY) != 0;
7637+
}
7638+
7639+
void setMethodHasStackAllocatedArray()
7640+
{
7641+
optMethodFlags |= OMF_HAS_STACK_ARRAY;
7642+
}
7643+
76307644
void pickGDV(GenTreeCall* call,
76317645
IL_OFFSET ilOffset,
76327646
bool isInterface,

src/coreclr/jit/compphases.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ CompPhaseNameMacro(PHASE_EXPAND_RTLOOKUPS, "Expand runtime lookups",
109109
CompPhaseNameMacro(PHASE_EXPAND_STATIC_INIT, "Expand static init", false, -1, true)
110110
CompPhaseNameMacro(PHASE_EXPAND_CASTS, "Expand casts", false, -1, true)
111111
CompPhaseNameMacro(PHASE_EXPAND_TLS, "Expand TLS access", false, -1, true)
112+
CompPhaseNameMacro(PHASE_EXPAND_STACK_ARR, "Expand stack array allocation", false, -1, true)
112113
CompPhaseNameMacro(PHASE_INSERT_GC_POLLS, "Insert GC Polls", false, -1, true)
113114
CompPhaseNameMacro(PHASE_CREATE_THROW_HELPERS, "Create throw helper blocks", false, -1, true)
114115
CompPhaseNameMacro(PHASE_DETERMINE_FIRST_COLD_BLOCK, "Determine first cold block", false, -1, true)

src/coreclr/jit/fgdiagnostic.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,10 @@ bool Compiler::fgDumpFlowGraph(Phases phase, PhasePosition pos)
955955
{
956956
fprintf(fgxFile, "\n hot=\"true\"");
957957
}
958+
if (block->HasFlag(BBF_HAS_NEWARR))
959+
{
960+
fprintf(fgxFile, "\n callsNewArr=\"true\"");
961+
}
958962
if (block->HasFlag(BBF_HAS_NEWOBJ))
959963
{
960964
fprintf(fgxFile, "\n callsNew=\"true\"");

src/coreclr/jit/gentree.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13192,6 +13192,8 @@ const char* Compiler::gtGetWellKnownArgNameForArgMsg(WellKnownArg arg)
1319213192
return "swift self";
1319313193
case WellKnownArg::X86TailCallSpecialArg:
1319413194
return "tail call";
13195+
case WellKnownArg::StackArrayLocal:
13196+
return "&lcl arr";
1319513197
default:
1319613198
return nullptr;
1319713199
}
@@ -19814,7 +19816,10 @@ void GenTreeArrAddr::ParseArrayAddress(Compiler* comp, GenTree** pArr, ValueNum*
1981419816
/* static */ void GenTreeArrAddr::ParseArrayAddressWork(
1981519817
GenTree* tree, Compiler* comp, target_ssize_t inputMul, GenTree** pArr, ValueNum* pInxVN, target_ssize_t* pOffset)
1981619818
{
19817-
if (tree->TypeIs(TYP_REF))
19819+
ValueNum vn = comp->GetValueNumStore()->VNLiberalNormalValue(tree->gtVNPair);
19820+
VNFuncApp vnf;
19821+
19822+
if (tree->TypeIs(TYP_REF) || comp->GetValueNumStore()->IsVNNewArr(vn, &vnf))
1981819823
{
1981919824
// This must be the array pointer.
1982019825
assert(*pArr == nullptr);
@@ -19917,7 +19922,7 @@ void GenTreeArrAddr::ParseArrayAddress(Compiler* comp, GenTree** pArr, ValueNum*
1991719922
// If we didn't return above, must be a contribution to the non-constant part of the index VN.
1991819923
// We don't get here for GT_CNS_INT, GT_ADD, or GT_SUB, or for GT_MUL by constant, or GT_LSH of
1991919924
// constant shift. Thus, the generated index VN does not include the parsed constant offset.
19920-
ValueNum vn = comp->GetValueNumStore()->VNLiberalNormalValue(tree->gtVNPair);
19925+
//
1992119926
if (inputMul != 1)
1992219927
{
1992319928
ValueNum mulVN = comp->GetValueNumStore()->VNForLongCon(inputMul);

0 commit comments

Comments
 (0)