From ee44e7ab75ff4853a11b1c61e655654b0c8bd9c5 Mon Sep 17 00:00:00 2001 From: Egor Bogatov Date: Tue, 21 Jul 2026 03:21:16 +0200 Subject: [PATCH] Remove unused JIT functions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: d4822663-897d-47d5-8d36-6128ffa76703 --- src/coreclr/jit/compiler.cpp | 115 -------------------------------- src/coreclr/jit/compiler.h | 34 ---------- src/coreclr/jit/emitriscv64.cpp | 9 --- src/coreclr/jit/lower.h | 11 --- src/coreclr/jit/lsra.h | 31 --------- src/coreclr/jit/priorityqueue.h | 31 --------- 6 files changed, 231 deletions(-) diff --git a/src/coreclr/jit/compiler.cpp b/src/coreclr/jit/compiler.cpp index 4b86c77c39fe41..38e96f3ba8f9cc 100644 --- a/src/coreclr/jit/compiler.cpp +++ b/src/coreclr/jit/compiler.cpp @@ -1724,18 +1724,6 @@ CORINFO_CONST_LOOKUP Compiler::compGetHelperFtn(CorInfoHelpFunc ftnNum) return lookup; } -unsigned Compiler::compGetTypeSize(CorInfoType cit, CORINFO_CLASS_HANDLE clsHnd) -{ - var_types sigType = genActualType(JITtype2varType(cit)); - unsigned sigSize; - sigSize = genTypeSize(sigType); - if (cit == CORINFO_TYPE_VALUECLASS) - { - sigSize = info.compCompHnd->getClassSize(clsHnd); - } - return sigSize; -} - #ifdef DEBUG static bool DidComponentUnitTests = false; @@ -1875,46 +1863,6 @@ const char* Compiler::compRegVarName(regNumber reg, bool displayVar, bool isFloa return getRegName(reg); } -const char* Compiler::compRegNameForSize(regNumber reg, size_t size) -{ -#if CPU_HAS_BYTE_REGS - if (size == 1 || size == 2) - { - // clang-format off - static const char* sizeNames[][2] = - { - { "al", "ax" }, - { "cl", "cx" }, - { "dl", "dx" }, - { "bl", "bx" }, - #ifdef TARGET_AMD64 - { "spl", "sp" }, // ESP - { "bpl", "bp" }, // EBP - { "sil", "si" }, // ESI - { "dil", "di" }, // EDI - { "r8b", "r8w" }, - { "r9b", "r9w" }, - { "r10b", "r10w" }, - { "r11b", "r11w" }, - { "r12b", "r12w" }, - { "r13b", "r13w" }, - { "r14b", "r14w" }, - { "r15b", "r15w" }, - #endif // TARGET_AMD64 - }; - // clang-format on - - assert(isByteReg(reg)); - assert(genRegMask(reg) & RBM_BYTE_REGS); - assert(size == 1 || size == 2); - - return sizeNames[reg][size - 1]; - } -#endif // CPU_HAS_BYTE_REGS - - return compRegVarName(reg, true); -} - #ifdef DEBUG const char* Compiler::compLocalVarName(unsigned varNum, unsigned offs) { @@ -8113,54 +8061,8 @@ Compiler::NodeToIntMap* Compiler::FindReachableNodesInNodeTestData() return reachable; } -void Compiler::TransferTestDataToNode(GenTree* from, GenTree* to) -{ - TestLabelAndNum tlAndN; - // We can't currently associate multiple annotations with a single node. - // If we need to, we can fix this... - - // If the table is null, don't create it just to do the lookup, which would fail... - if (m_nodeTestData != nullptr && GetNodeTestData()->Lookup(from, &tlAndN)) - { - assert(!GetNodeTestData()->Lookup(to, &tlAndN)); - // We can't currently associate multiple annotations with a single node. - // If we need to, we can fix this... - TestLabelAndNum tlAndNTo; - assert(!GetNodeTestData()->Lookup(to, &tlAndNTo)); - - GetNodeTestData()->Remove(from); - GetNodeTestData()->Set(to, tlAndN); - } -} - #endif // DEBUG -/* -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XX XX -XX jvc XX -XX XX -XX Functions for the stand-alone version of the JIT . XX -XX XX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX -*/ - -/*****************************************************************************/ -void codeGeneratorCodeSizeBeg() -{ -} - -/***************************************************************************** - * - * Used for counting pointer assignments. - */ - -/*****************************************************************************/ -void codeGeneratorCodeSizeEnd() -{ -} /***************************************************************************** * * Gather statistics - mainly used for the standalone @@ -9146,23 +9048,6 @@ void Compiler::AddLoopHoistStats() s_totalHoistedExpressions += m_totalHoistedExpressions; } -void Compiler::PrintPerMethodLoopHoistStats() -{ - double pctWithHoisted = 0.0; - if (m_loopsConsidered > 0) - { - pctWithHoisted = 100.0 * (double(m_loopsWithHoistedExpressions) / double(m_loopsConsidered)); - } - double exprsPerLoopWithExpr = 0.0; - if (m_loopsWithHoistedExpressions > 0) - { - exprsPerLoopWithExpr = double(m_totalHoistedExpressions) / double(m_loopsWithHoistedExpressions); - } - printf("Considered %d loops. Of these, we hoisted expressions out of %d (%5.2f%%).\n", m_loopsConsidered, - m_loopsWithHoistedExpressions, pctWithHoisted); - printf(" A total of %d expressions were hoisted, an average of %5.2f per loop-with-hoisted-expr.\n", - m_totalHoistedExpressions, exprsPerLoopWithExpr); -} #endif // LOOP_HOIST_STATS //------------------------------------------------------------------------ diff --git a/src/coreclr/jit/compiler.h b/src/coreclr/jit/compiler.h index ca98cc9be25bad..624b411005fa5c 100644 --- a/src/coreclr/jit/compiler.h +++ b/src/coreclr/jit/compiler.h @@ -4142,7 +4142,6 @@ class Compiler void gtDispLclVarStructType(unsigned lclNum); void gtDispSsaName(unsigned lclNum, unsigned ssaNum, bool isDef); void gtDispClassLayout(ClassLayout* layout, var_types type); - void gtDispILLocation(const ILLocation& loc); void gtDispStmt(Statement* stmt, const char* msg = nullptr); void gtDispBlockStmts(BasicBlock* block); void gtPrintArgPrefix(GenTreeCall* call, CallArg* arg, char** bufp, unsigned* bufLength); @@ -6645,9 +6644,6 @@ class Compiler GCPOLL_INLINE }; - // Initialize the per-block variable sets (used for liveness analysis). - void fgInitBlockVarSets(); - PhaseStatus StressSplitTree(); void SplitTreesRandomly(); void SplitTreesRemoveCommas(); @@ -6862,7 +6858,6 @@ class Compiler PhaseStatus fgFindOperOrder(); #ifdef TARGET_WASM - FlowGraphDfsTree* fgWasmDfs(); PhaseStatus fgWasmEhFlow(); void fgWasmEhTransformTry(ArrayStack* catchRetBlocks, unsigned regionIndex, unsigned catchRetIndexLocalNum); PhaseStatus fgWasmControlFlow(); @@ -6901,9 +6896,6 @@ class Compiler bool fgCastNeeded(GenTree* tree, var_types toType); bool fgCastRequiresHelper(var_types fromType, var_types toType, bool overflow = false); - void fgLoopCallTest(BasicBlock* srcBB, BasicBlock* dstBB); - void fgLoopCallMark(); - unsigned fgGetCodeEstimate(BasicBlock* block); #if DUMP_FLOWGRAPHS @@ -7186,10 +7178,6 @@ class Compiler hashBv* fgAvailableOutgoingArgTemps; ArrayStack* fgUsedSharedTemps = nullptr; - void fgSetRngChkTarget(GenTree* tree, bool delay = true); - - BasicBlock* fgSetRngChkTargetInner(SpecialCodeKind kind, bool delay); - #if REARRANGE_ADDS void fgMoveOpsLeft(GenTree* tree); #endif @@ -7498,10 +7486,6 @@ class Compiler #endif PhaseStatus fgPromoteStructs(); - void fgMorphLocalField(GenTree* tree, GenTree* parent); - - // Reset the refCount for implicit byrefs. - void fgResetImplicitByRefRefCount(); // Identify all candidates for last-use copy omission. PhaseStatus fgMarkImplicitByRefCopyOmissionCandidates(); @@ -8267,7 +8251,6 @@ class Compiler GenTree* optPropGetValueRec(unsigned lclNum, unsigned ssaNum, optPropKind valueKind, int walkDepth); GenTree* optPropGetValue(unsigned lclNum, unsigned ssaNum, optPropKind valueKind); GenTree* optEarlyPropRewriteTree(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); - bool optDoEarlyPropForBlock(BasicBlock* block); bool optDoEarlyPropForFunc(); PhaseStatus optEarlyProp(); bool optFoldNullCheck(GenTree* tree, LocalNumberToNullCheckTreeMap* nullCheckMap); @@ -9223,7 +9206,6 @@ class Compiler // Assertion Gen functions. void optAssertionGen(GenTree* tree); - AssertionIndex optAssertionGenCast(GenTreeCast* cast); AssertionInfo optCreateJTrueBoundsAssertion(GenTree* tree); AssertionInfo optAssertionGenJtrue(GenTree* tree); AssertionIndex optCreateJtrueAssertions(GenTree* op1, GenTree* op2, bool equals); @@ -9237,8 +9219,6 @@ class Compiler // Assertion creation functions. AssertionIndex optCreateAssertion(GenTree* op1, GenTree* op2, bool equals); - bool optTryExtractSubrangeAssertion(GenTree* source, IntegralRange* pRange); - void optCreateComplementaryAssertion(AssertionIndex assertionIndex); AssertionIndex optAddAssertion(const AssertionDsc& assertion); @@ -12087,11 +12067,6 @@ class Compiler CORINFO_CONST_LOOKUP compGetHelperFtn(CorInfoHelpFunc ftnNum); - // Several JIT/EE interface functions return a CorInfoType, and also return a - // class handle as an out parameter if the type is a value class. Returns the - // size of the type these describe. - unsigned compGetTypeSize(CorInfoType cit, CORINFO_CLASS_HANDLE clsHnd); - #ifdef DEBUG // Components used by the compiler may write unit test suites, and // have them run within this method. They will be run only once per process, and only @@ -12127,7 +12102,6 @@ class Compiler unsigned m_totalHoistedExpressions = 0; void AddLoopHoistStats(); - void PrintPerMethodLoopHoistStats(); static CritSecObject s_loopHoistStatsLock; // This lock protects the data structures below. static unsigned s_loopsConsidered; @@ -12200,11 +12174,7 @@ class Compiler const char* compLocalVarName(unsigned varNum, unsigned offs); VarName compVarName(regNumber reg, bool isFloatReg = false); - const char* compFPregVarName(unsigned fpReg, bool displayVar = false); - void compDspSrcLinesByNativeIP(UNATIVE_OFFSET curIP); - void compDspSrcLinesByLineNum(unsigned line, bool seek = false); #endif // DEBUG - const char* compRegNameForSize(regNumber reg, size_t size); const char* compRegVarName(regNumber reg, bool displayVar = false, bool isFloatReg = false); //------------------------------------------------------------------------- @@ -12553,10 +12523,6 @@ class Compiler // currently occur in the AST graph. NodeToIntMap* FindReachableNodesInNodeTestData(); - // Node "from" is being eliminated, and being replaced by node "to". If "from" had any associated - // test data, associate that data with "to". - void TransferTestDataToNode(GenTree* from, GenTree* to); - // These are the methods that test that the various conditions implied by the // test attributes are satisfied. void JitTestCheckSSA(); // SSA builder tests. diff --git a/src/coreclr/jit/emitriscv64.cpp b/src/coreclr/jit/emitriscv64.cpp index 14bcbc03eac4b1..cc157b10facb11 100644 --- a/src/coreclr/jit/emitriscv64.cpp +++ b/src/coreclr/jit/emitriscv64.cpp @@ -2879,15 +2879,6 @@ static unsigned UpperNBitsOfWordSignExtend(ssize_t word) return UpperNBitsOfWord(word + kSignExtend); } -template -static ssize_t DoubleWordSignExtend(ssize_t doubleWord) -{ - static constexpr size_t kLowerSignExtend = static_cast(1) << (63 - LowerMaskSize); - static constexpr size_t kUpperSignExtend = static_cast(1) << (63 - UpperMaskSize); - - return doubleWord + (kLowerSignExtend | kUpperSignExtend); -} - /*static*/ unsigned emitter::TrimSignedToImm12(ssize_t imm12) { assert(isValidSimm12(imm12)); diff --git a/src/coreclr/jit/lower.h b/src/coreclr/jit/lower.h index 0313bf4871087d..33e094c205e29b 100644 --- a/src/coreclr/jit/lower.h +++ b/src/coreclr/jit/lower.h @@ -252,23 +252,12 @@ class Lowering final : public Phase return m_compiler->gtNewPhysRegNode(reg, type); } - GenTree* ThisReg(GenTreeCall* call) - { - return PhysReg(m_compiler->codeGen->genGetThisArgReg(call), TYP_REF); - } - GenTree* Offset(GenTree* base, unsigned offset) { var_types resultType = base->TypeIs(TYP_REF) ? TYP_BYREF : base->TypeGet(); return new (m_compiler, GT_LEA) GenTreeAddrMode(resultType, base, nullptr, 0, offset); } - GenTree* OffsetByIndex(GenTree* base, GenTree* index) - { - var_types resultType = base->TypeIs(TYP_REF) ? TYP_BYREF : base->TypeGet(); - return new (m_compiler, GT_LEA) GenTreeAddrMode(resultType, base, index, 0, 0); - } - GenTree* OffsetByIndexWithScale(GenTree* base, GenTree* index, unsigned scale) { var_types resultType = base->TypeIs(TYP_REF) ? TYP_BYREF : base->TypeGet(); diff --git a/src/coreclr/jit/lsra.h b/src/coreclr/jit/lsra.h index ba30cb3f742c59..3541e1a2309349 100644 --- a/src/coreclr/jit/lsra.h +++ b/src/coreclr/jit/lsra.h @@ -587,15 +587,6 @@ inline bool leafInRange(GenTree* leaf, int lower, int upper, int multiple) return true; } -inline bool leafAddInRange(GenTree* leaf, int lower, int upper, int multiple = 1) -{ - if (!leaf->OperIs(GT_ADD)) - { - return false; - } - return leafInRange(leaf->gtGetOp2(), lower, upper, multiple); -} - inline bool isCandidateVar(const LclVarDsc* varDsc) { return varDsc->lvLRACandidate; @@ -956,15 +947,6 @@ class LinearScan : public RegAllocInterface { return false; } - // In a retail build we support only the default traversal order - bool isTraversalLayoutOrder() - { - return false; - } - bool isTraversalPredFirstOrder() - { - return true; - } bool getLsraExtendLifeTimes() { return false; @@ -1896,11 +1878,6 @@ class LinearScan : public RegAllocInterface { regsBusyUntilKill.AddRegNum(reg, regType); } - void clearRegBusyUntilKill(regNumber reg) - { - regsBusyUntilKill.RemoveRegNumFromMask(reg); - } - bool isRegInUse(regNumber reg, var_types regType) { return regsInUseThisLocation.IsRegNumPresent(reg, regType); @@ -2365,14 +2342,6 @@ class Interval : public Referenceable return varDsc->lvVarIndex; } - bool isAssignedTo(regNumber regNum) - { - // This uses regMasks to handle the case where a double actually occupies two registers - // TODO-Throughput: This could/should be done more cheaply. - return (physReg != REG_NA && - (genSingleTypeRegMask(physReg, registerType) & genSingleTypeRegMask(regNum)) != RBM_NONE); - } - // Assign the related interval. void assignRelatedInterval(Interval* newRelatedInterval) { diff --git a/src/coreclr/jit/priorityqueue.h b/src/coreclr/jit/priorityqueue.h index ea26a5c8c1fd38..dc51f0efdea0f6 100644 --- a/src/coreclr/jit/priorityqueue.h +++ b/src/coreclr/jit/priorityqueue.h @@ -11,35 +11,6 @@ class PriorityQueue jitstd::vector data; Compare comp; -#ifdef DEBUG - // Returns true only if each element has a higher priority than its children. - bool VerifyMaxHeap() const - { - for (size_t i = 0; i < data.size(); i++) - { - const size_t leftChild = (2 * i) + 1; - const size_t rightChild = leftChild + 1; - - if (rightChild < data.size()) - { - if (comp(data[i], data[leftChild]) || comp(data[i], data[rightChild])) - { - return false; - } - } - else if (leftChild < data.size()) - { - if (comp(data[i], data[leftChild])) - { - return false; - } - } - } - - return true; - } -#endif // DEBUG - public: PriorityQueue(const jitstd::allocator& allocator, const Compare& compare) : data(allocator) @@ -82,7 +53,6 @@ class PriorityQueue } data[i] = value; - // assert(VerifyMaxHeap()); } // Remove and return the root element. @@ -120,7 +90,6 @@ class PriorityQueue data[i] = lastElem; data.pop_back(); - // assert(VerifyMaxHeap()); return root; } };