Skip to content
3 changes: 0 additions & 3 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7358,9 +7358,6 @@ ExceptionSetFlags GenTree::OperExceptions(Compiler* comp)
case GT_CKFINITE:
return ExceptionSetFlags::ArithmeticException;

case GT_LCLHEAP:
return ExceptionSetFlags::StackOverflowException;
Comment thread
EgorBo marked this conversation as resolved.

#ifdef FEATURE_HW_INTRINSICS
case GT_HWINTRINSIC:
{
Expand Down
5 changes: 3 additions & 2 deletions src/coreclr/jit/importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10069,8 +10069,9 @@ void Compiler::impImportBlockCode(BasicBlock* block)
}

op1 = gtNewOperNode(GT_LCLHEAP, TYP_I_IMPL, op2);
// May throw a stack overflow exception. Obviously, we don't want locallocs to be CSE'd.
op1->gtFlags |= (GTF_EXCEPT | GTF_DONT_CSE);
// We do not model stack overflow from localloc as an exception side effect.
// Obviously, we don't want locallocs to be CSE'd.
op1->gtFlags |= GTF_DONT_CSE;

// Request stack security for this method.
setNeedsGSSecurityCookie();
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/jit/lower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11703,7 +11703,7 @@ void Lowering::TransformUnusedIndirection(GenTreeIndir* ind, Compiler* m_compile
// LowerLclHeap: a common logic to lower LCLHEAP.
//
// Arguments:
// blkNode - the LCLHEAP node we are lowering.
// node - the LCLHEAP node we are lowering.
//
void Lowering::LowerLclHeap(GenTree* node)
{
Expand Down
19 changes: 8 additions & 11 deletions src/coreclr/jit/morph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -948,27 +948,24 @@ void CallArgs::ArgsComplete(Compiler* comp, GenTreeCall* call)
#if !FEATURE_FIXED_OUT_ARGS
// On x86 we previously recorded a stack depth of zero when
// morphing the register arguments of any GT_IND with a GTF_IND_RNGCHK flag
// Thus we can not reorder the argument after any stack based argument
// (Note that GT_LCLHEAP sets the GTF_EXCEPT flag so we don't need to
// check for it explicitly.)
// Thus we can not reorder the argument after any stack based argument.
// GT_LCLHEAP has the same stack depth constraint, but it no longer sets
// GTF_EXCEPT, so it must be checked explicitly here.
//
if (argx->gtFlags & GTF_EXCEPT)
if (((argx->gtFlags & GTF_EXCEPT) != 0) ||
(comp->compLocallocUsed && comp->gtTreeContainsOper(argx, GT_LCLHEAP)))
{
SetNeedsTemp(&arg);
continue;
}
#else
// For Arm/X64 we can't reorder a register argument that uses a GT_LCLHEAP
//
if (argx->gtFlags & GTF_EXCEPT)
if (comp->compLocallocUsed && comp->gtTreeContainsOper(argx, GT_LCLHEAP))
{
assert(comp->compLocallocUsed);

if (comp->gtTreeContainsOper(argx, GT_LCLHEAP))
{
SetNeedsTemp(&arg);
continue;
}
SetNeedsTemp(&arg);
continue;
}
#endif
}
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,8 +588,7 @@ enum class ExceptionSetFlags : uint32_t
ArithmeticException = 0x4,
NullReferenceException = 0x8,
IndexOutOfRangeException = 0x10,
StackOverflowException = 0x20,
UnknownException = 0x40,
UnknownException = 0x20,
};

class HelperCallProperties
Expand Down
Loading