@@ -6162,8 +6162,27 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals()
6162
6162
}
6163
6163
#elif defined(TARGET_LOONGARCH64)
6164
6164
6165
+ int PSP_MonAcquire_Size = 0 ;
6165
6166
assert (compCalleeRegsPushed >= 2 );
6166
6167
stkOffs = (compCalleeRegsPushed << 3 );
6168
+ if (lvaMonAcquired != BAD_VAR_NUM)
6169
+ {
6170
+ originalFrameStkOffs += lvaLclSize (lvaMonAcquired);
6171
+ if (!opts.IsOSR ())
6172
+ {
6173
+ PSP_MonAcquire_Size = lvaLclSize (lvaMonAcquired);
6174
+ stkOffs += lvaLclSize (lvaMonAcquired);
6175
+ }
6176
+ }
6177
+
6178
+ #if FEATURE_EH_FUNCLETS
6179
+ if (lvaPSPSym != BAD_VAR_NUM)
6180
+ {
6181
+ PSP_MonAcquire_Size += TARGET_POINTER_SIZE;
6182
+ originalFrameStkOffs += TARGET_POINTER_SIZE;
6183
+ stkOffs += TARGET_POINTER_SIZE;
6184
+ }
6185
+ #endif
6167
6186
6168
6187
#elif defined(TARGET_RISCV64)
6169
6188
@@ -6266,59 +6285,6 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals()
6266
6285
}
6267
6286
#endif // TARGET_AMD64
6268
6287
6269
- #if defined(TARGET_LOONGARCH64)
6270
- // For LoongArch64, after the `lvaAssignVirtualFrameOffsetsToLocals`, there is no need
6271
- // to recompute the LclVarDsc's StackOffset within the `lvaFixVirtualFrameOffsets`.
6272
- assert (codeGen->isFramePointerUsed ());
6273
- int PSP_MonAcquire_Size = 0 ;
6274
- #if FEATURE_EH_FUNCLETS
6275
- if (lvaPSPSym != BAD_VAR_NUM)
6276
- {
6277
- // If we need a PSPSym, allocate it first, before anything else, including
6278
- // padding (so we can avoid computing the same padding in the funclet
6279
- // frame). Note that there is no special padding requirement for the PSPSym.
6280
- noway_assert (codeGen->isFramePointerUsed ()); // We need an explicit frame pointer
6281
- stkOffs = lvaAllocLocalAndSetVirtualOffset (lvaPSPSym, TARGET_POINTER_SIZE, stkOffs + TARGET_POINTER_SIZE);
6282
- PSP_MonAcquire_Size += TARGET_POINTER_SIZE;
6283
- }
6284
- #endif // FEATURE_EH_FUNCLETS
6285
-
6286
- if (lvaMonAcquired != BAD_VAR_NUM)
6287
- {
6288
- // For OSR we use the flag set up by the original method.
6289
- if (opts.IsOSR ())
6290
- {
6291
- originalFrameStkOffs += lvaLclSize (lvaMonAcquired);
6292
- assert (info.compPatchpointInfo ->HasMonitorAcquired ());
6293
- int originalOffset = info.compPatchpointInfo ->MonitorAcquiredOffset ();
6294
- int offset = originalFrameStkOffs + PSP_MonAcquire_Size + originalOffset;
6295
-
6296
- JITDUMP (
6297
- " ---OSR--- V%02u (on tier0 frame, monitor acquired) tier0 FP-rel offset %d tier0 frame offset %d new "
6298
- " virt offset %d\n " ,
6299
- lvaMonAcquired, originalOffset, originalFrameStkOffs + PSP_MonAcquire_Size, offset);
6300
-
6301
- lvaTable[lvaMonAcquired].SetStackOffset (offset);
6302
- }
6303
- else
6304
- {
6305
- // This var must go first, in what is called the 'frame header' for EnC so that it is
6306
- // preserved when remapping occurs. See vm\eetwain.cpp for detailed comment specifying frame
6307
- // layout requirements for EnC to work.
6308
- stkOffs = stkOffs + PSP_MonAcquire_Size + lvaLclSize (lvaMonAcquired);
6309
- stkOffs = lvaAllocLocalAndSetVirtualOffset (lvaMonAcquired, lvaLclSize (lvaMonAcquired), stkOffs);
6310
- stkOffs -= PSP_MonAcquire_Size;
6311
- PSP_MonAcquire_Size += lvaLclSize (lvaMonAcquired);
6312
- }
6313
- }
6314
- if (opts.IsOSR ())
6315
- {
6316
- originalFrameStkOffs += PSP_MonAcquire_Size;
6317
- originalFrameSize = originalFrameStkOffs;
6318
- }
6319
- stkOffs = stkOffs - (compCalleeRegsPushed << 3 );
6320
-
6321
- #else
6322
6288
if (lvaMonAcquired != BAD_VAR_NUM)
6323
6289
{
6324
6290
// For OSR we use the flag set up by the original method.
@@ -6344,9 +6310,8 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals()
6344
6310
stkOffs = lvaAllocLocalAndSetVirtualOffset (lvaMonAcquired, lvaLclSize (lvaMonAcquired), stkOffs);
6345
6311
}
6346
6312
}
6347
- #endif
6348
6313
6349
- #if defined(FEATURE_EH_FUNCLETS) && (defined(TARGET_ARMARCH) || defined(TARGET_RISCV64))
6314
+ #if defined(FEATURE_EH_FUNCLETS) && (defined(TARGET_ARMARCH) || defined(TARGET_LOONGARCH64) || defined( TARGET_RISCV64))
6350
6315
if (lvaPSPSym != BAD_VAR_NUM)
6351
6316
{
6352
6317
// On ARM/ARM64, if we need a PSPSym we allocate it early since funclets
@@ -6355,7 +6320,12 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals()
6355
6320
noway_assert (codeGen->isFramePointerUsed ()); // We need an explicit frame pointer
6356
6321
stkOffs = lvaAllocLocalAndSetVirtualOffset (lvaPSPSym, TARGET_POINTER_SIZE, stkOffs);
6357
6322
}
6358
- #endif // FEATURE_EH_FUNCLETS && (TARGET_ARMARCH || TARGET_RISCV64)
6323
+ #endif // FEATURE_EH_FUNCLETS && (TARGET_ARMARCH || TARGET_LOONGARCH64 || TARGET_RISCV64)
6324
+
6325
+ #if defined(TARGET_LOONGARCH64)
6326
+ // From here, all the stack local values are below the FP, so the offset is negative.
6327
+ stkOffs = 0 ;
6328
+ #endif
6359
6329
6360
6330
if (mustDoubleAlign)
6361
6331
{
@@ -6973,9 +6943,7 @@ void Compiler::lvaAssignVirtualFrameOffsetsToLocals()
6973
6943
#endif // FEATURE_FIXED_OUT_ARGS
6974
6944
6975
6945
#if defined(TARGET_LOONGARCH64)
6976
- noway_assert (compLclFrameSize + originalFrameSize ==
6977
- (unsigned )(originalFrameStkOffs + PSP_MonAcquire_Size - stkOffs));
6978
-
6946
+ noway_assert (compLclFrameSize == (unsigned )(PSP_MonAcquire_Size - stkOffs));
6979
6947
#else
6980
6948
6981
6949
#if defined(TARGET_RISCV64)
0 commit comments