Skip to content

Commit

Permalink
JIT: Delete IL verification failure helpers in importer (dotnet#108996)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanasifkhalid authored Nov 4, 2024
1 parent 4362771 commit 2bb4bb7
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 354 deletions.
1 change: 0 additions & 1 deletion src/coreclr/jit/block.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ void BasicBlock::dspFlags() const
{BBF_REMOVED, "del"},
{BBF_DONT_REMOVE, "keep"},
{BBF_INTERNAL, "internal"},
{BBF_FAILED_VERIFICATION, "failV"},
{BBF_HAS_SUPPRESSGC_CALL, "sup-gc"},
{BBF_LOOP_HEAD, "loophead"},
{BBF_HAS_LABEL, "label"},
Expand Down
71 changes: 35 additions & 36 deletions src/coreclr/jit/block.h
Original file line number Diff line number Diff line change
Expand Up @@ -424,44 +424,43 @@ enum BasicBlockFlags : uint64_t
BBF_DONT_REMOVE = MAKE_BBFLAG( 3), // BB should not be removed during flow graph optimizations
BBF_IMPORTED = MAKE_BBFLAG( 4), // BB byte-code has been imported
BBF_INTERNAL = MAKE_BBFLAG( 5), // BB has been added by the compiler
BBF_FAILED_VERIFICATION = MAKE_BBFLAG( 6), // BB has verification exception
BBF_NEEDS_GCPOLL = MAKE_BBFLAG( 7), // BB may need a GC poll because it uses the slow tail call helper
BBF_FUNCLET_BEG = MAKE_BBFLAG( 8), // BB is the beginning of a funclet
BBF_CLONED_FINALLY_BEGIN = MAKE_BBFLAG( 9), // First block of a cloned finally region
BBF_CLONED_FINALLY_END = MAKE_BBFLAG(10), // Last block of a cloned finally region
BBF_HAS_NULLCHECK = MAKE_BBFLAG(11), // BB contains a null check
BBF_HAS_SUPPRESSGC_CALL = MAKE_BBFLAG(12), // BB contains a call to a method with SuppressGCTransitionAttribute
BBF_RUN_RARELY = MAKE_BBFLAG(13), // BB is rarely run (catch clauses, blocks with throws etc)
BBF_LOOP_HEAD = MAKE_BBFLAG(14), // BB is the head of a loop (can reach a predecessor)
BBF_HAS_LABEL = MAKE_BBFLAG(15), // BB needs a label
BBF_LOOP_ALIGN = MAKE_BBFLAG(16), // Block is lexically the first block in a loop we intend to align.
BBF_HAS_ALIGN = MAKE_BBFLAG(17), // BB ends with 'align' instruction
BBF_HAS_JMP = MAKE_BBFLAG(18), // BB executes a JMP instruction (instead of return)
BBF_GC_SAFE_POINT = MAKE_BBFLAG(19), // BB has a GC safe point (e.g. a call)
BBF_HAS_IDX_LEN = MAKE_BBFLAG(20), // BB contains simple index or length expressions on an SD array local var.
BBF_HAS_MD_IDX_LEN = MAKE_BBFLAG(21), // BB contains simple index, length, or lower bound expressions on an MD array local var.
BBF_HAS_MDARRAYREF = MAKE_BBFLAG(22), // Block has a multi-dimensional array reference
BBF_HAS_NEWOBJ = MAKE_BBFLAG(23), // BB contains 'new' of an object type.

BBF_RETLESS_CALL = MAKE_BBFLAG(24), // BBJ_CALLFINALLY that will never return (and therefore, won't need a paired
BBF_NEEDS_GCPOLL = MAKE_BBFLAG( 6), // BB may need a GC poll because it uses the slow tail call helper
BBF_FUNCLET_BEG = MAKE_BBFLAG( 7), // BB is the beginning of a funclet
BBF_CLONED_FINALLY_BEGIN = MAKE_BBFLAG( 8), // First block of a cloned finally region
BBF_CLONED_FINALLY_END = MAKE_BBFLAG( 9), // Last block of a cloned finally region
BBF_HAS_NULLCHECK = MAKE_BBFLAG(10), // BB contains a null check
BBF_HAS_SUPPRESSGC_CALL = MAKE_BBFLAG(11), // BB contains a call to a method with SuppressGCTransitionAttribute
BBF_RUN_RARELY = MAKE_BBFLAG(12), // BB is rarely run (catch clauses, blocks with throws etc)
BBF_LOOP_HEAD = MAKE_BBFLAG(13), // BB is the head of a loop (can reach a predecessor)
BBF_HAS_LABEL = MAKE_BBFLAG(14), // BB needs a label
BBF_LOOP_ALIGN = MAKE_BBFLAG(15), // Block is lexically the first block in a loop we intend to align.
BBF_HAS_ALIGN = MAKE_BBFLAG(16), // BB ends with 'align' instruction
BBF_HAS_JMP = MAKE_BBFLAG(17), // BB executes a JMP instruction (instead of return)
BBF_GC_SAFE_POINT = MAKE_BBFLAG(18), // BB has a GC safe point (e.g. a call)
BBF_HAS_IDX_LEN = MAKE_BBFLAG(19), // BB contains simple index or length expressions on an SD array local var.
BBF_HAS_MD_IDX_LEN = MAKE_BBFLAG(20), // BB contains simple index, length, or lower bound expressions on an MD array local var.
BBF_HAS_MDARRAYREF = MAKE_BBFLAG(21), // Block has a multi-dimensional array reference
BBF_HAS_NEWOBJ = MAKE_BBFLAG(22), // BB contains 'new' of an object type.

BBF_RETLESS_CALL = MAKE_BBFLAG(23), // BBJ_CALLFINALLY that will never return (and therefore, won't need a paired
// BBJ_CALLFINALLYRET); see isBBCallFinallyPair().
BBF_COLD = MAKE_BBFLAG(25), // BB is cold
BBF_PROF_WEIGHT = MAKE_BBFLAG(26), // BB weight is computed from profile data
BBF_KEEP_BBJ_ALWAYS = MAKE_BBFLAG(27), // A special BBJ_ALWAYS block, used by EH code generation. Keep the jump kind
BBF_COLD = MAKE_BBFLAG(24), // BB is cold
BBF_PROF_WEIGHT = MAKE_BBFLAG(25), // BB weight is computed from profile data
BBF_KEEP_BBJ_ALWAYS = MAKE_BBFLAG(26), // A special BBJ_ALWAYS block, used by EH code generation. Keep the jump kind
// as BBJ_ALWAYS. Used on x86 for the final step block out of a finally.
BBF_HAS_CALL = MAKE_BBFLAG(28), // BB contains a call
BBF_DOMINATED_BY_EXCEPTIONAL_ENTRY = MAKE_BBFLAG(29), // Block is dominated by exceptional entry.
BBF_BACKWARD_JUMP = MAKE_BBFLAG(30), // BB is surrounded by a backward jump/switch arc
BBF_BACKWARD_JUMP_SOURCE = MAKE_BBFLAG(31), // Block is a source of a backward jump
BBF_BACKWARD_JUMP_TARGET = MAKE_BBFLAG(32), // Block is a target of a backward jump
BBF_PATCHPOINT = MAKE_BBFLAG(33), // Block is a patchpoint
BBF_PARTIAL_COMPILATION_PATCHPOINT = MAKE_BBFLAG(34), // Block is a partial compilation patchpoint
BBF_HAS_HISTOGRAM_PROFILE = MAKE_BBFLAG(35), // BB contains a call needing a histogram profile
BBF_TAILCALL_SUCCESSOR = MAKE_BBFLAG(36), // BB has pred that has potential tail call
BBF_RECURSIVE_TAILCALL = MAKE_BBFLAG(37), // Block has recursive tailcall that may turn into a loop
BBF_NO_CSE_IN = MAKE_BBFLAG(38), // Block should kill off any incoming CSE
BBF_CAN_ADD_PRED = MAKE_BBFLAG(39), // Ok to add pred edge to this block, even when "safe" edge creation disabled
BBF_HAS_VALUE_PROFILE = MAKE_BBFLAG(40), // Block has a node that needs a value probing
BBF_HAS_CALL = MAKE_BBFLAG(27), // BB contains a call
BBF_DOMINATED_BY_EXCEPTIONAL_ENTRY = MAKE_BBFLAG(28), // Block is dominated by exceptional entry.
BBF_BACKWARD_JUMP = MAKE_BBFLAG(29), // BB is surrounded by a backward jump/switch arc
BBF_BACKWARD_JUMP_SOURCE = MAKE_BBFLAG(30), // Block is a source of a backward jump
BBF_BACKWARD_JUMP_TARGET = MAKE_BBFLAG(31), // Block is a target of a backward jump
BBF_PATCHPOINT = MAKE_BBFLAG(32), // Block is a patchpoint
BBF_PARTIAL_COMPILATION_PATCHPOINT = MAKE_BBFLAG(33), // Block is a partial compilation patchpoint
BBF_HAS_HISTOGRAM_PROFILE = MAKE_BBFLAG(34), // BB contains a call needing a histogram profile
BBF_TAILCALL_SUCCESSOR = MAKE_BBFLAG(35), // BB has pred that has potential tail call
BBF_RECURSIVE_TAILCALL = MAKE_BBFLAG(36), // Block has recursive tailcall that may turn into a loop
BBF_NO_CSE_IN = MAKE_BBFLAG(37), // Block should kill off any incoming CSE
BBF_CAN_ADD_PRED = MAKE_BBFLAG(38), // Ok to add pred edge to this block, even when "safe" edge creation disabled
BBF_HAS_VALUE_PROFILE = MAKE_BBFLAG(39), // Block has a node that needs a value probing

// The following are sets of flags.

Expand Down
39 changes: 12 additions & 27 deletions src/coreclr/jit/compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -4912,7 +4912,7 @@ class Compiler
void impImportBlockPending(BasicBlock* block);

// Similar to impImportBlockPending, but assumes that block has already been imported once and is being
// reimported for some reason. It specifically does *not* look at verCurrentState to set the EntryState
// reimported for some reason. It specifically does *not* look at stackState to set the EntryState
// for the block, but instead, just re-uses the block's existing EntryState.
void impReimportBlockPending(BasicBlock* block);

Expand Down Expand Up @@ -11230,37 +11230,22 @@ class Compiler
}
#endif // DEBUG

/*
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XX XX
XX IL verification stuff XX
XX XX
XX XX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
*/

public:
EntryState verCurrentState;

void verInitBBEntryState(BasicBlock* block, EntryState* currentState);
EntryState stackState;

void verInitCurrentState();
void verResetCurrentState(BasicBlock* block, EntryState* currentState);
void initBBEntryState(BasicBlock* block, EntryState* currentState);

void verConvertBBToThrowVerificationException(BasicBlock* block DEBUGARG(bool logMsg));
void verHandleVerificationFailure(BasicBlock* block DEBUGARG(bool logMsg));
typeInfo verMakeTypeInfoForLocal(unsigned lclNum);
typeInfo verMakeTypeInfo(CORINFO_CLASS_HANDLE clsHnd); // converts from jit type representation to typeInfo
typeInfo verMakeTypeInfo(CorInfoType ciType,
CORINFO_CLASS_HANDLE clsHnd); // converts from jit type representation to typeInfo
void initCurrentState();
void resetCurrentState(BasicBlock* block, EntryState* currentState);

typeInfo verParseArgSigToTypeInfo(CORINFO_SIG_INFO* sig, CORINFO_ARG_LIST_HANDLE args);
typeInfo makeTypeInfoForLocal(unsigned lclNum);
typeInfo makeTypeInfo(CORINFO_CLASS_HANDLE clsHnd); // converts from jit type representation to typeInfo
typeInfo makeTypeInfo(CorInfoType ciType,
CORINFO_CLASS_HANDLE clsHnd); // converts from jit type representation to typeInfo

bool verCheckTailCallConstraint(OPCODE opcode,
CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken);
bool checkTailCallConstraint(OPCODE opcode,
CORINFO_RESOLVED_TOKEN* pResolvedToken,
CORINFO_RESOLVED_TOKEN* pConstrainedResolvedToken);

#ifdef DEBUG

Expand Down
28 changes: 13 additions & 15 deletions src/coreclr/jit/hwintrinsicarm64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1263,7 +1263,7 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
break;
}

impSpillSideEffect(true, verCurrentState.esStackDepth -
impSpillSideEffect(true, stackState.esStackDepth -
2 DEBUGARG("Spilling op1 side effects for vector CreateSequence"));

op2 = impPopStack().val;
Expand Down Expand Up @@ -1554,11 +1554,11 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,
assert(sig->numArgs == 3);
assert(varTypeIsFloating(simdBaseType));

impSpillSideEffect(true, verCurrentState.esStackDepth -
3 DEBUGARG("Spilling op1 side effects for FusedMultiplyAdd"));
impSpillSideEffect(true,
stackState.esStackDepth - 3 DEBUGARG("Spilling op1 side effects for FusedMultiplyAdd"));

impSpillSideEffect(true, verCurrentState.esStackDepth -
2 DEBUGARG("Spilling op2 side effects for FusedMultiplyAdd"));
impSpillSideEffect(true,
stackState.esStackDepth - 2 DEBUGARG("Spilling op2 side effects for FusedMultiplyAdd"));

op3 = impSIMDPopStack();
op2 = impSIMDPopStack();
Expand Down Expand Up @@ -2011,10 +2011,10 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,

if (varTypeIsFloating(simdBaseType))
{
impSpillSideEffect(true, verCurrentState.esStackDepth -
impSpillSideEffect(true, stackState.esStackDepth -
3 DEBUGARG("Spilling op1 side effects for MultiplyAddEstimate"));

impSpillSideEffect(true, verCurrentState.esStackDepth -
impSpillSideEffect(true, stackState.esStackDepth -
2 DEBUGARG("Spilling op2 side effects for MultiplyAddEstimate"));
}

Expand Down Expand Up @@ -2273,17 +2273,17 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,

if (sig->numArgs == 3)
{
impSpillSideEffect(true, verCurrentState.esStackDepth -
3 DEBUGARG("Spilling op1 side effects for HWIntrinsic"));
impSpillSideEffect(true,
stackState.esStackDepth - 3 DEBUGARG("Spilling op1 side effects for HWIntrinsic"));

op3 = impPopStack().val;
}
else
{
assert(sig->numArgs == 2);

impSpillSideEffect(true, verCurrentState.esStackDepth -
2 DEBUGARG("Spilling op1 side effects for HWIntrinsic"));
impSpillSideEffect(true,
stackState.esStackDepth - 2 DEBUGARG("Spilling op1 side effects for HWIntrinsic"));
}

op2 = impPopStack().val;
Expand Down Expand Up @@ -2323,8 +2323,7 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,

var_types simdType = getSIMDTypeForSize(simdSize);

impSpillSideEffect(true,
verCurrentState.esStackDepth - 2 DEBUGARG("Spilling op1 side effects for HWIntrinsic"));
impSpillSideEffect(true, stackState.esStackDepth - 2 DEBUGARG("Spilling op1 side effects for HWIntrinsic"));

op2 = impPopStack().val;

Expand Down Expand Up @@ -2356,8 +2355,7 @@ GenTree* Compiler::impSpecialIntrinsic(NamedIntrinsic intrinsic,

var_types simdType = getSIMDTypeForSize(simdSize);

impSpillSideEffect(true,
verCurrentState.esStackDepth - 2 DEBUGARG("Spilling op1 side effects for HWIntrinsic"));
impSpillSideEffect(true, stackState.esStackDepth - 2 DEBUGARG("Spilling op1 side effects for HWIntrinsic"));

op2 = impPopStack().val;

Expand Down
Loading

0 comments on commit 2bb4bb7

Please sign in to comment.