diff --git a/src/coreclr/jit/CMakeLists.txt b/src/coreclr/jit/CMakeLists.txt index 3dadf640040780..cfd3ad77b9f0ee 100644 --- a/src/coreclr/jit/CMakeLists.txt +++ b/src/coreclr/jit/CMakeLists.txt @@ -16,6 +16,15 @@ if (MSVC) add_compile_options($<$:/permissive->) endif() +# The JIT enforces -Wunused-function, -Wtautological-compare and -Wunused-value +# (overriding the repo-wide -Wno-* counterparts from configurecompiler.cmake) so +# that dead helpers, always-true/always-false comparisons and discarded +# expressions are caught early. Any helper or comparison that is only meaningful +# under a target/DEBUG #ifdef must be guarded by the same condition. +if (CLR_CMAKE_HOST_UNIX OR CLR_CMAKE_HOST_WASI) + add_compile_options(-Wunused-function -Wtautological-compare -Wunused-value) +endif() + function(create_standalone_jit) set(oneValueArgs TARGET OS ARCH) diff --git a/src/coreclr/jit/emitriscv64.cpp b/src/coreclr/jit/emitriscv64.cpp index babb7122eda7f5..c82e79956d499b 100644 --- a/src/coreclr/jit/emitriscv64.cpp +++ b/src/coreclr/jit/emitriscv64.cpp @@ -2922,18 +2922,6 @@ static unsigned UpperNBitsOfWordSignExtend(ssize_t word) return UpperNBitsOfWord(word + kSignExtend); } -static unsigned UpperWordOfDoubleWord(ssize_t immediate) -{ - return static_cast(immediate >> 32); -} - -static unsigned LowerWordOfDoubleWord(ssize_t immediate) -{ - static constexpr size_t kWordMask = WordMask(32); - - return static_cast(immediate & kWordMask); -} - template static ssize_t DoubleWordSignExtend(ssize_t doubleWord) { @@ -2943,20 +2931,6 @@ static ssize_t DoubleWordSignExtend(ssize_t doubleWord) return doubleWord + (kLowerSignExtend | kUpperSignExtend); } -template -static ssize_t UpperWordOfDoubleWordSingleSignExtend(ssize_t doubleWord) -{ - static constexpr size_t kUpperSignExtend = static_cast(1) << (31 - UpperMaskSize); - - return UpperWordOfDoubleWord(doubleWord + kUpperSignExtend); -} - -template -static ssize_t UpperWordOfDoubleWordDoubleSignExtend(ssize_t doubleWord) -{ - return UpperWordOfDoubleWord(DoubleWordSignExtend(doubleWord)); -} - /*static*/ unsigned emitter::TrimSignedToImm12(ssize_t imm12) { assert(isValidSimm12(imm12)); @@ -5768,7 +5742,7 @@ emitter::insExecutionCharacteristics emitter::getInsExecutionCharacteristics(ins } regNumber baseReg = id->idReg2(); - if (baseReg != REG_SP || baseReg != REG_FP) + if ((baseReg != REG_SP) && (baseReg != REG_FP)) result.insLatency += PERFSCORE_LATENCY_1C; // assume non-stack load/stores are more likely to cache-miss result.insThroughput += immediateBuildingCost; diff --git a/src/coreclr/jit/emitxarch.cpp b/src/coreclr/jit/emitxarch.cpp index 32d20d45385819..0f686bacacab39 100644 --- a/src/coreclr/jit/emitxarch.cpp +++ b/src/coreclr/jit/emitxarch.cpp @@ -1586,6 +1586,7 @@ bool emitter::Is4ByteSSEInstruction(instruction ins) const return !UseVEXEncoding() && EncodedBySSE38orSSE3A(ins); } +#ifdef DEBUG //------------------------------------------------------------------------ // isLowSIMDReg: Checks if a register is a register supported by any SIMD encoding // @@ -1602,6 +1603,7 @@ static bool isLowSimdReg(regNumber reg) return (reg >= REG_XMM0) && (reg <= REG_XMM7); #endif } +#endif // DEBUG //------------------------------------------------------------------------ // GetEmbRoundingMode: Get the rounding mode for embedded rounding diff --git a/src/coreclr/jit/gentree.cpp b/src/coreclr/jit/gentree.cpp index 6b837121819bbd..3b9191eaa7564a 100644 --- a/src/coreclr/jit/gentree.cpp +++ b/src/coreclr/jit/gentree.cpp @@ -10467,7 +10467,11 @@ bool GenTreeOp::UsesDivideByConstOptimized(Compiler* comp) if (isSignedDivide) { // If the divisor is the minimum representable integer value then the result is either 0 or 1 - if ((divType == TYP_INT && divisorValue == INT_MIN) || (divType == TYP_LONG && divisorValue == INT64_MIN)) + if ((divType == TYP_INT && divisorValue == INT_MIN) +#if defined(TARGET_64BIT) + || (divType == TYP_LONG && divisorValue == INT64_MIN) +#endif + ) { return true; } @@ -31726,7 +31730,7 @@ NamedIntrinsic GenTreeHWIntrinsic::GetHWIntrinsicIdForCmpOp(Compiler* comp, } else if (isScalar) { - reverseCond ? NI_X86Base_CompareScalarNotLessThanOrEqual : NI_X86Base_CompareScalarGreaterThan; + id = reverseCond ? NI_X86Base_CompareScalarNotLessThanOrEqual : NI_X86Base_CompareScalarGreaterThan; } else { diff --git a/src/coreclr/jit/hwintrinsic.cpp b/src/coreclr/jit/hwintrinsic.cpp index aed5d2f236e6d3..f9808f6ff44063 100644 --- a/src/coreclr/jit/hwintrinsic.cpp +++ b/src/coreclr/jit/hwintrinsic.cpp @@ -1661,46 +1661,6 @@ static bool impIsTableDrivenHWIntrinsic(NamedIntrinsic intrinsicId, HWIntrinsicC return (category != HW_Category_Special) && !HWIntrinsicInfo::HasSpecialImport(intrinsicId); } -//------------------------------------------------------------------------ -// isSupportedBaseType -// -// Arguments: -// intrinsicId - HW intrinsic id -// baseJitType - Base JIT type of the intrinsic. -// -// Return Value: -// returns true if the baseType is supported for given intrinsic. -// -static bool isSupportedBaseType(NamedIntrinsic intrinsic, CorInfoType baseJitType) -{ - if (baseJitType == CORINFO_TYPE_UNDEF) - { - return false; - } - - var_types baseType = JitType2PreciseVarType(baseJitType); - - // We don't actually check the intrinsic outside of the false case as we expect - // the exposed managed signatures are either generic and support all types - // or they are explicit and support the type indicated. - - if (varTypeIsArithmetic(baseType)) - { - return true; - } - -#ifdef DEBUG - CORINFO_InstructionSet isa = HWIntrinsicInfo::lookupIsa(intrinsic); -#ifdef TARGET_XARCH - assert((isa == InstructionSet_Vector512) || (isa == InstructionSet_Vector256) || (isa == InstructionSet_Vector128)); -#endif // TARGET_XARCH -#ifdef TARGET_ARM64 - assert((isa == InstructionSet_Vector64) || (isa == InstructionSet_Vector128)); -#endif // TARGET_ARM64 -#endif // DEBUG - return false; -} - static bool isSupportedBaseType(NamedIntrinsic intrinsic, var_types baseType) { if (baseType == TYP_UNDEF) diff --git a/src/coreclr/jit/ifconversion.cpp b/src/coreclr/jit/ifconversion.cpp index 51636fe614809b..1f4414f4a93521 100644 --- a/src/coreclr/jit/ifconversion.cpp +++ b/src/coreclr/jit/ifconversion.cpp @@ -742,6 +742,7 @@ GenTree* OptIfConversionDsc::TryOptimizeSelect(GenTreeConditional* select) return nullptr; } +#ifdef TARGET_RISCV64 struct IntConstSelectOper { genTreeOps oper; @@ -794,6 +795,7 @@ static IntConstSelectOper MatchIntConstSelectValues(int64_t trueVal, int64_t fal return {GT_NONE}; } +#endif // TARGET_RISCV64 //----------------------------------------------------------------------------- // TrySelectToCnsOpCond: Try to optimize: diff --git a/src/coreclr/jit/importercalls.cpp b/src/coreclr/jit/importercalls.cpp index 69d7066826707e..62c0b2b267e82e 100644 --- a/src/coreclr/jit/importercalls.cpp +++ b/src/coreclr/jit/importercalls.cpp @@ -4777,8 +4777,7 @@ GenTree* Compiler::impIntrinsic(CORINFO_CLASS_HANDLE clsHnd, // This is now known to be a multi-dimension array with a constant dimension // that is in range; we can expand it as an intrinsic. - impPopStack().val; // Pop the dim and array object; we already have a pointer to them. - impPopStack().val; + impPopStack(2); // Pop the dim and array object; we already have a pointer to them. // Make sure there are no global effects in the array (such as it being a function // call), so we can mark the generated indirection with GTF_IND_INVARIANT. In the diff --git a/src/coreclr/jit/lower.cpp b/src/coreclr/jit/lower.cpp index 9ebadb786c2095..4924fd0b6d599b 100644 --- a/src/coreclr/jit/lower.cpp +++ b/src/coreclr/jit/lower.cpp @@ -8202,8 +8202,11 @@ bool Lowering::TryLowerConstIntUDivOrUMod(GenTreeOp* divMod) { // If the divisor is greater or equal than 2^(N - 1) then the result is 1 // iff the dividend is greater or equal than the divisor. - if (((type == TYP_INT) && (divisorValue > (UINT32_MAX / 2))) || - ((type == TYP_LONG) && (divisorValue > (UINT64_MAX / 2)))) + if (((type == TYP_INT) && (divisorValue > (UINT32_MAX / 2))) +#if defined(TARGET_64BIT) + || ((type == TYP_LONG) && (divisorValue > (UINT64_MAX / 2))) +#endif + ) { divMod->ChangeOper(GT_GE); divMod->SetUnsigned(); @@ -8493,7 +8496,11 @@ bool Lowering::TryLowerConstIntDivOrMod(GenTree* node, GenTree** nextNode) if (isDiv) { - if ((type == TYP_INT && divisorValue == INT_MIN) || (type == TYP_LONG && divisorValue == INT64_MIN)) + if ((type == TYP_INT && divisorValue == INT_MIN) +#if defined(TARGET_64BIT) + || (type == TYP_LONG && divisorValue == INT64_MIN) +#endif + ) { // If the divisor is the minimum representable integer value then we can use a compare, // the result is 1 iff the dividend equals divisor. @@ -10445,6 +10452,7 @@ static bool IsStoreCoalescingInvariantNode(Compiler* compiler, GenTree* node, bo return node->OperIs(GT_LCL_VAR) && !compiler->lvaVarAddrExposed(node->AsLclVar()->GetLclNum()); } +#if defined(TARGET_XARCH) || defined(TARGET_ARM64) //------------------------------------------------------------------------ // TryGetStoreCoalescingConstantBits: get the raw bits for a constant used by store // coalescing. @@ -10487,6 +10495,7 @@ static bool TryGetStoreCoalescingConstantBits(GenTree* value, uint64_t* bits) return false; } +#endif // TARGET_XARCH || TARGET_ARM64 //------------------------------------------------------------------------ // GetLoadStoreCoalescingData: given a STOREIND/IND node, get the data needed to perform diff --git a/src/coreclr/jit/scev.cpp b/src/coreclr/jit/scev.cpp index 36542081136d6f..b4d83cce55ca84 100644 --- a/src/coreclr/jit/scev.cpp +++ b/src/coreclr/jit/scev.cpp @@ -1469,6 +1469,7 @@ ValueNumPair ScalarEvolutionContext::MaterializeVN(Scev* scev) return Materialize(scev, false, nullptr, &vnp) ? vnp : ValueNumPair(); } +#ifdef DEBUG //------------------------------------------------------------------------ // RelopEvaluationResultString: Convert a RelopEvaluationResult to a string. // @@ -1492,6 +1493,7 @@ static const char* RelopEvaluationResultString(RelopEvaluationResult result) return "n/a"; } } +#endif // DEBUG //------------------------------------------------------------------------ // EvaluateRelop: