Skip to content

Commit

Permalink
Fix or disable warnings on latest VS dogfood
Browse files Browse the repository at this point in the history
  • Loading branch information
jkotas committed Mar 18, 2021
1 parent 705daa1 commit 3041f67
Show file tree
Hide file tree
Showing 33 changed files with 122 additions and 283 deletions.
77 changes: 31 additions & 46 deletions eng/native/configurecompiler.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -502,59 +502,44 @@ if (MSVC)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:inline>) # All inline functions must have their definition available in the current translation unit.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zc:forScope>) # Enforce standards-compliant for scope.

add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4960>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4961>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4603>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4627>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4838>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4456>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4457>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4458>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4459>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4091>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4640>)

# Disable Warnings:
# 4291: Delete not defined for new, c++ exception may cause leak.
# 5105: Windows SDK headers use 'defined' operator in some macros
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4291>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd5105>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4065>) # switch statement contains 'default' but no 'case' labels
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4100>) # 'identifier' : unreferenced formal parameter
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4127>) # conditional expression is constant
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4189>) # local variable is initialized but not referenced
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4200>) # nonstandard extension used : zero-sized array in struct/union
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4201>) # nonstandard extension used : nameless struct/union
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4245>) # conversion from 'type1' to 'type2', signed/unsigned mismatch
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4291>) # no matching operator delete found; memory will not be freed if initialization throws an exception
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4456>) # declaration of 'identifier' hides previous local declaration
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4457>) # declaration of 'identifier' hides function parameter
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4458>) # declaration of 'identifier' hides class member
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4838>) # conversion from 'type_1' to 'type_2' requires a narrowing conversion
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4960>) # 'function' is too big to be profiled
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd4961>) # No profile data was merged into '.pgd file', profile-guided optimizations disabled
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/wd5105>) # macro expansion producing 'defined' has undefined behavior

# Treat Warnings as Errors:
# 4007: 'main' : must be __cdecl.
# 4013: 'function' undefined - assuming extern returning int.
# 4102: "'%$S' : unreferenced label".
# 4551: Function call missing argument list.
# 4700: Local used w/o being initialized.
# 4806: Unsafe operation involving type 'bool'.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4007>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4013>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4102>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4551>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4700>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4806>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4007>) # 'main' : must be __cdecl.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4013>) # 'function' undefined - assuming extern returning int.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4102>) # "'%$S' : unreferenced label".
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4551>) # Function call missing argument list.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4700>) # Local used w/o being initialized.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4640>) # 'instance' : construction of local static object is not thread-safe
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/we4806>) # Unsafe operation involving type 'bool'.

# Set Warning Level 3:
# 4092: Sizeof returns 'unsigned long'.
# 4121: Structure is sensitive to alignment.
# 4125: Decimal digit in octal sequence.
# 4130: Logical operation on address of string constant.
# 4132: Const object should be initialized.
# 4212: Function declaration used ellipsis.
# 4530: C++ exception handler used, but unwind semantics are not enabled. Specify -GX.
# 35038: data member 'member1' will be initialized after data member 'member2'.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34092>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34121>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34125>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34130>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34132>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34212>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34530>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w35038>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34092>) # Sizeof returns 'unsigned long'.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34121>) # Structure is sensitive to alignment.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34125>) # Decimal digit in octal sequence.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34130>) # Logical operation on address of string constant.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34132>) # Const object should be initialized.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34212>) # Function declaration used ellipsis.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w34530>) # C++ exception handler used, but unwind semantics are not enabled. Specify -GX.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w35038>) # data member 'member1' will be initialized after data member 'member2'.

# Set Warning Level 4:
# 4177: Pragma data_seg s/b at global scope.
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w44177>)
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/w44177>) # Pragma data_seg s/b at global scope.

add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/Zi>) # enable debugging information
add_compile_options($<$<COMPILE_LANGUAGE:C,CXX>:/ZH:SHA_256>) # use SHA256 for generating hashes of compiler processed source files.
Expand Down
3 changes: 0 additions & 3 deletions src/coreclr/jit/codegencommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11299,7 +11299,6 @@ void CodeGen::genMultiRegStoreToLocal(GenTreeLclVar* lclNode)
// genConsumeReg will return the valid register, either from the COPY
// or from the original source.
assert(reg != REG_NA);
regNumber varReg = REG_NA;
if (isMultiRegVar)
{
// Each field is passed in its own register, use the field types.
Expand Down Expand Up @@ -11409,7 +11408,6 @@ void CodeGen::genRegCopy(GenTree* treeNode)
//
// There should never be any circular dependencies, and we will check that here.

GenTreeCopyOrReload* copyNode = treeNode->AsCopyOrReload();
// GenTreeCopyOrReload only reports the highest index that has a valid register.
// However, we need to ensure that we consume all the registers of the child node,
// so we use its regCount.
Expand Down Expand Up @@ -11535,7 +11533,6 @@ regNumber CodeGen::genRegCopy(GenTree* treeNode, unsigned multiRegIndex)
if (targetReg != REG_NA)
{
// We shouldn't specify a no-op move.
regMaskTP targetRegMask = genRegMask(targetReg);
assert(sourceReg != targetReg);
var_types type;
if (op1->IsMultiRegLclVar())
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/jit/codegenlinear.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1401,8 +1401,6 @@ regNumber CodeGen::genConsumeReg(GenTree* tree, unsigned multiRegIndex)
unsigned fieldVarNum = varDsc->lvFieldLclStart + multiRegIndex;
LclVarDsc* fldVarDsc = compiler->lvaGetDesc(fieldVarNum);
assert(fldVarDsc->lvLRACandidate);
bool isInReg = fldVarDsc->lvIsInReg() && reg != REG_NA;
bool isInMemory = !isInReg || fldVarDsc->lvLiveInOutOfHndlr;
bool isFieldDying = lcl->IsLastUse(multiRegIndex);

if (fldVarDsc->GetRegNum() == REG_STK)
Expand Down Expand Up @@ -1507,8 +1505,6 @@ regNumber CodeGen::genConsumeReg(GenTree* tree)
{
reg = lcl->AsLclVar()->GetRegNumByIdx(i);
}
bool isInReg = fldVarDsc->lvIsInReg() && reg != REG_NA;
bool isInMemory = !isInReg || fldVarDsc->lvLiveInOutOfHndlr;
bool isFieldDying = lcl->IsLastUse(i);

if (fldVarDsc->GetRegNum() == REG_STK)
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/codegenxarch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4230,7 +4230,6 @@ void CodeGen::genCodeForShiftLong(GenTree* tree)
void CodeGen::genCodeForShiftRMW(GenTreeStoreInd* storeInd)
{
GenTree* data = storeInd->Data();
GenTree* addr = storeInd->Addr();

assert(data->OperIsShift() || data->OperIsRotate());

Expand Down Expand Up @@ -4265,7 +4264,6 @@ void CodeGen::genCodeForShiftRMW(GenTreeStoreInd* storeInd)
// We must have the number of bits to shift stored in ECX, since we constrained this node to
// sit in ECX. In case this didn't happen, LSRA expects the code generator to move it since it's a single
// register destination requirement.
regNumber shiftReg = shiftBy->GetRegNum();
genCopyRegIfNeeded(shiftBy, REG_RCX);

// The shiftBy operand is implicit, so call the unary version of emitInsRMW.
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2762,8 +2762,6 @@ void Compiler::compInitOptions(JitFlags* jitFlags)

if (!altJitConfig || opts.altJit)
{
LPCWSTR dumpIRFormat = nullptr;

// We should only enable 'verboseDump' when we are actually compiling a matching method
// and not enable it when we are just considering inlining a matching method.
//
Expand Down
13 changes: 3 additions & 10 deletions src/coreclr/jit/emit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4698,7 +4698,7 @@ unsigned emitter::getLoopSize(insGroup* igLoopHeader, unsigned maxLoopSize DEBUG
}
else
{
instrDescAlign *alignInstrToAdj = alignInstr, *prevAlignInstr = nullptr;
instrDescAlign* alignInstrToAdj = alignInstr;
for (; alignInstrToAdj != nullptr && alignInstrToAdj->idaIG == alignInstr->idaIG;
alignInstrToAdj = alignInstrToAdj->idaNext)
{
Expand Down Expand Up @@ -4807,14 +4807,7 @@ void emitter::emitLoopAlignAdjustments()
unsigned short estimatedPaddingNeeded = emitComp->opts.compJitAlignPaddingLimit;
unsigned short alignmentBoundary = emitComp->opts.compJitAlignLoopBoundary;

if (emitComp->opts.compJitAlignLoopAdaptive)
{
// For adaptive, adjust the loop size depending on the alignment boundary
int maxBlocksAllowedForLoop = genLog2((unsigned)alignmentBoundary) - 1;
}

unsigned alignBytesRemoved = 0;
unsigned loopSize = 0;
unsigned loopIGOffset = 0;
instrDescAlign* alignInstr = emitAlignList;

Expand Down Expand Up @@ -6555,7 +6548,6 @@ void emitter::emitOutputDataSec(dataSecDsc* sec, BYTE* dst)
{
JITDUMP(" section %u, size %u, block relative addr\n", secNum++, dscSize);

unsigned elemSize = 4;
size_t numElems = dscSize / 4;
unsigned* uDst = (unsigned*)dst;
insGroup* labFirst = (insGroup*)emitCodeGetCookie(emitComp->fgFirstBB);
Expand Down Expand Up @@ -7010,10 +7002,11 @@ void emitter::emitRecordGCcall(BYTE* codePos, unsigned char callInstrSize)
assert(!emitFullGCinfo);

unsigned offs = emitCurCodeOffs(codePos);
unsigned regs = (emitThisGCrefRegs | emitThisByrefRegs) & ~RBM_INTRET;
callDsc* call;

#ifdef JIT32_GCENCODER
unsigned regs = (emitThisGCrefRegs | emitThisByrefRegs) & ~RBM_INTRET;

// The JIT32 GCInfo encoder allows us to (as the comment previously here said):
// "Bail if this is a totally boring call", but the GCInfoEncoder/Decoder interface
// requires a definition for every call site, so we skip these "early outs" when we're
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/fgdiagnostic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1952,8 +1952,6 @@ void Compiler::fgDebugCheckBBlist(bool checkBBNum /* = false */, bool checkBBRef
return;
}

DWORD startTickCount = GetTickCount();

#if defined(FEATURE_EH_FUNCLETS)
bool reachedFirstFunclet = false;
if (fgFuncletsCreated)
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/jit/fgehopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1323,7 +1323,6 @@ void Compiler::fgDebugCheckTryFinallyExits()
{
unsigned XTnum = 0;
EHblkDsc* HBtab = compHndBBtab;
unsigned cloneCount = 0;
bool allTryExitsValid = true;
for (; XTnum < compHndBBtabCount; XTnum++, HBtab++)
{
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/fgflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -704,8 +704,6 @@ void Compiler::fgRemoveCheapPred(BasicBlock* block, BasicBlock* blockPred)
assert(!fgComputePredsDone);
assert(fgCheapPredsValid);

flowList* oldEdge = nullptr;

assert(block != nullptr);
assert(blockPred != nullptr);
assert(block->bbCheapPreds != nullptr);
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/jit/fginline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1847,8 +1847,6 @@ Statement* Compiler::fgInlinePrependStatements(InlineInfo* inlineInfo)
}
else
{
CORINFO_CLASS_HANDLE structType =
lclVarInfo[lclNum + inlineInfo->argCnt].lclVerTypeInfo.GetClassHandle();
tree = gtNewBlkOpNode(gtNewLclvNode(tmpNum, lclTyp), // Dest
gtNewIconNode(0), // Value
false, // isVolatile
Expand Down
3 changes: 1 addition & 2 deletions src/coreclr/jit/fgopt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2687,8 +2687,7 @@ bool Compiler::fgOptimizeSwitchBranches(BasicBlock* block)
//
if (block->NumSucc(this) == 1)
{
// Use BBJ_ALWAYS for a switch with only a default clause, or with only one unique successor.
BasicBlock* uniqueSucc = jmpTab[0];
// Use BBJ_ALWAYS for a switch with only a default clause, or with only one unique successor.

#ifdef DEBUG
if (verbose)
Expand Down
6 changes: 0 additions & 6 deletions src/coreclr/jit/gcencode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4094,10 +4094,6 @@ void GCInfo::gcMakeRegPtrTable(
**************************************************************************
*/

unsigned count = 0;

int lastoffset = 0;

/* Count&Write untracked locals and non-enregistered args */

unsigned varNum;
Expand Down Expand Up @@ -4324,8 +4320,6 @@ void GCInfo::gcMakeRegPtrTable(

for (regPtrDsc* genRegPtrTemp = gcRegPtrList; genRegPtrTemp != nullptr; genRegPtrTemp = genRegPtrTemp->rpdNext)
{
int nextOffset = genRegPtrTemp->rpdOffs;

if (genRegPtrTemp->rpdArg)
{
if (genRegPtrTemp->rpdArgTypeGet() == rpdARG_KILL)
Expand Down
13 changes: 4 additions & 9 deletions src/coreclr/jit/gentree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3521,8 +3521,7 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)

case GT_CNS_DBL:
{
var_types targetType = tree->TypeGet();
level = 0;
level = 0;
#if defined(TARGET_XARCH)
/* We use fldz and fld1 to load 0.0 and 1.0, but all other */
/* floating point constants are loaded using an indirection */
Expand All @@ -3538,6 +3537,7 @@ unsigned Compiler::gtSetEvalOrder(GenTree* tree)
costSz = 4;
}
#elif defined(TARGET_ARM)
var_types targetType = tree->TypeGet();
if (targetType == TYP_FLOAT)
{
costEx = 1 + 2;
Expand Down Expand Up @@ -10107,9 +10107,7 @@ void Compiler::gtDispCommonEndLine(GenTree* tree)

void Compiler::gtDispNode(GenTree* tree, IndentStack* indentStack, __in __in_z __in_opt const char* msg, bool isLIR)
{
bool printPointer = true; // always true..
bool printFlags = true; // always true..
bool printCost = true; // always true..
bool printFlags = true; // always true..

int msgLength = 25;

Expand Down Expand Up @@ -16969,8 +16967,6 @@ bool GenTree::isContained() const
// They can only produce a result if the child is a SIMD equality comparison.
else if (OperKind() & GTK_RELOP)
{
// We have to cast away const-ness since AsOp() method is non-const.
const GenTree* childNode = AsOp()->gtGetOp1();
assert(isMarkedContained == false);
}

Expand Down Expand Up @@ -17262,8 +17258,7 @@ bool GenTree::IsFieldAddr(Compiler* comp, GenTree** pObj, GenTree** pStatic, Fie
//
// The CSE could be a pointer to a boxed struct
//
GenTreeLclVarCommon* lclVar = AsLclVarCommon();
ValueNum vn = gtVNPair.GetLiberal();
ValueNum vn = gtVNPair.GetLiberal();
if (vn != ValueNumStore::NoVN)
{
// Is the ValueNum a MapSelect involving a SharedStatic helper?
Expand Down
12 changes: 5 additions & 7 deletions src/coreclr/jit/hwintrinsic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,8 +416,7 @@ GenTree* HWIntrinsicInfo::lookupLastOp(const GenTreeHWIntrinsic* node)
{
assert(node != nullptr);

NamedIntrinsic id = node->gtHWIntrinsicId;
GenTree* op1 = node->gtGetOp1();
GenTree* op1 = node->gtGetOp1();

if (op1 == nullptr)
{
Expand Down Expand Up @@ -778,11 +777,10 @@ GenTree* Compiler::impHWIntrinsic(NamedIntrinsic intrinsic,
CORINFO_SIG_INFO* sig,
bool mustExpand)
{
CORINFO_InstructionSet isa = HWIntrinsicInfo::lookupIsa(intrinsic);
HWIntrinsicCategory category = HWIntrinsicInfo::lookupCategory(intrinsic);
int numArgs = sig->numArgs;
var_types retType = JITtype2varType(sig->retType);
var_types baseType = TYP_UNKNOWN;
HWIntrinsicCategory category = HWIntrinsicInfo::lookupCategory(intrinsic);
int numArgs = sig->numArgs;
var_types retType = JITtype2varType(sig->retType);
var_types baseType = TYP_UNKNOWN;

if ((retType == TYP_STRUCT) && featureSIMD)
{
Expand Down
Loading

0 comments on commit 3041f67

Please sign in to comment.