Skip to content

Commit

Permalink
Fix C4018
Browse files Browse the repository at this point in the history
```
warning C4018: '<' : signed/unsigned mismatch
```
  • Loading branch information
fjeremic committed Jun 7, 2021
1 parent 6e551ea commit 131c4a7
Show file tree
Hide file tree
Showing 49 changed files with 321 additions and 324 deletions.
4 changes: 2 additions & 2 deletions compiler/codegen/CodeGenGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ OMR::CodeGenerator::buildGCMapForInstruction(TR::Instruction *instr)
localCursor = automaticIterator.getNext())
{
int32_t mapIndex = localCursor->getGCMapIndex();
if (mapIndex >= 0 && mapIndex < atlas->getIndexOfFirstSpillTemp())
if (mapIndex >= 0 && unsigned(mapIndex) < atlas->getIndexOfFirstSpillTemp())
{
if (liveLocals && liveLocals->get(localCursor->getLiveLocalIndex()))
{
Expand Down Expand Up @@ -296,7 +296,7 @@ OMR::CodeGenerator::buildGCMapForInstruction(TR::Instruction *instr)
continue;
}

TR_ASSERT( s->getGCMapIndex() >= atlas->getIndexOfFirstSpillTemp(), "Code Gen: error in building stack map");
TR_ASSERT(unsigned(s->getGCMapIndex()) >= atlas->getIndexOfFirstSpillTemp(), "Code Gen: error in building stack map");
map->setBit(s->getGCMapIndex());
}
}
Expand Down
15 changes: 7 additions & 8 deletions compiler/codegen/CodeGenRA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,9 +370,8 @@ OMR::CodeGenerator::prepareRegistersForAssignment()
TR_Array<TR::Register *>& regArray=self()->getRegisterArray();
TR::Register *registerCursor;
TR_RegisterMask km, foundKindsMask = 0;
int i;

for (i=0; i < regArray.size(); i++)
for (auto i = 0U; i < regArray.size(); i++)
{
registerCursor = regArray[i];
if (registerCursor->getKind() != TR_SSR)
Expand Down Expand Up @@ -2790,11 +2789,11 @@ OMR::CodeGenerator::simulateNodeEvaluation(TR::Node *node, TR_RegisterPressureSt
}

if (summary->_gprPressure < summary->PRESSURE_LIMIT)
TR_ASSERT(state->_gprPressure <= summary->_gprPressure, "Children of %s must record max register gprPressure in summary; %d > %d", self()->getDebug()->getName(node), state->_gprPressure, summary->_gprPressure);
TR_ASSERT(unsigned(state->_gprPressure) <= summary->_gprPressure, "Children of %s must record max register gprPressure in summary; %d > %d", self()->getDebug()->getName(node), state->_gprPressure, summary->_gprPressure);
if (summary->_fprPressure < summary->PRESSURE_LIMIT )
TR_ASSERT(state->_fprPressure <= summary->_fprPressure, "Children of %s must record max register fprPressure in summary; %d > %d", self()->getDebug()->getName(node), state->_fprPressure, summary->_fprPressure);
TR_ASSERT(unsigned(state->_fprPressure) <= summary->_fprPressure, "Children of %s must record max register fprPressure in summary; %d > %d", self()->getDebug()->getName(node), state->_fprPressure, summary->_fprPressure);
if (summary->_vrfPressure <= summary->PRESSURE_LIMIT)
TR_ASSERT(state->_vrfPressure <= summary->_vrfPressure, "Children of %s must record max register vrfPressure in summary; %d > %d", self()->getDebug()->getName(node), state->_vrfPressure, summary->_vrfPressure);
TR_ASSERT(unsigned(state->_vrfPressure) <= summary->_vrfPressure, "Children of %s must record max register vrfPressure in summary; %d > %d", self()->getDebug()->getName(node), state->_vrfPressure, summary->_vrfPressure);


// Dec children's ref counts.
Expand Down Expand Up @@ -3341,15 +3340,15 @@ OMR::CodeGenerator::TR_RegisterPressureSummary::accumulate(
// increase pressure.

uint32_t gprs = state->_gprPressure + gprTemps;
if (gprs > state->_gprLimit && state->pressureIsAtRisk())
if (gprs > unsigned(state->_gprLimit) && state->pressureIsAtRisk())
spill(TR_gprSpill, cg);

uint32_t fprs = state->_fprPressure + fprTemps;
if (fprs > state->_fprLimit && state->pressureIsAtRisk())
if (fprs > unsigned(state->_fprLimit) && state->pressureIsAtRisk())
spill(TR_fprSpill, cg);

uint32_t vrfs = state->_vrfPressure + vrfTemps;
if (vrfs > state->_vrfLimit && state->pressureIsAtRisk())
if (vrfs > unsigned(state->_vrfLimit) && state->pressureIsAtRisk())
spill(TR_vrfSpill, cg);

accumulate(gprs, fprs, vrfs);
Expand Down
2 changes: 1 addition & 1 deletion compiler/codegen/OMRCodeGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2093,7 +2093,7 @@ OMR::CodeGenerator::compute32BitMagicValues(
*s = div32BitMagicValues[mid][2];
return;
}
else if (d > div32BitMagicValues[mid][0])
else if (unsigned(d) > div32BitMagicValues[mid][0])
{
first = mid+1;
}
Expand Down
18 changes: 9 additions & 9 deletions compiler/codegen/OMRRegisterDependency.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

bool containsVirtualRegister(TR::Register *r, uint32_t numberOfRegisters)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
if (_dependencies[i].getRegister() == r)
return true;
Expand All @@ -98,7 +98,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

TR::Register *searchForRegister(TR::RealRegister::RegNum rr, uint32_t numberOfRegisters)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
if (_dependencies[i].getRealRegister() == rr)
return _dependencies[i].getRegister();
Expand All @@ -109,7 +109,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

TR::Register *searchForRegister(TR::Register* vr, uint8_t flag, uint32_t numberOfRegisters, TR::CodeGenerator *cg)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
if (_dependencies[i].getRegister() == vr && (_dependencies[i].getFlags() & flag))
return _dependencies[i].getRegister();
Expand All @@ -120,7 +120,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

TR::Register *searchForRegister(TR::RealRegister::RegNum rr, uint8_t flag, uint32_t numberOfRegisters, TR::CodeGenerator *cg)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
if (_dependencies[i].getRealRegister() == rr && (_dependencies[i].getFlags() & flag))
return _dependencies[i].getRegister();
Expand All @@ -131,7 +131,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

int32_t searchForRegisterPos(TR::Register* vr, uint8_t flag, uint32_t numberOfRegisters, TR::CodeGenerator *cg)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
if (_dependencies[i].getRegister() == vr && (_dependencies[i].getFlags() & flag))
return i;
Expand All @@ -147,7 +147,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

void blockRegisters(uint32_t numberOfRegisters, TR::CodeGenerator *cg = NULL)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
if (_dependencies[i].getRegister())
{
Expand All @@ -158,7 +158,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

void unblockRegisters(uint32_t numberOfRegisters, TR::CodeGenerator *cg = NULL)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
if (_dependencies[i].getRegister())
{
Expand All @@ -169,7 +169,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

void stopUsingDepRegs(uint32_t numberOfRegisters, TR::Register *ret1, TR::Register *ret2, TR::CodeGenerator *cg)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
auto depReg = _dependencies[i].getRegister();
if (depReg != ret1 && depReg != ret2)
Expand All @@ -181,7 +181,7 @@ class OMR_EXTENSIBLE RegisterDependencyGroup

void stopUsingDepRegs(uint32_t numberOfRegisters, int numRetReg, TR::Register **retReg, TR::CodeGenerator *cg)
{
for (auto i = 0; i < numberOfRegisters; ++i)
for (auto i = 0U; i < numberOfRegisters; ++i)
{
TR::Register *depReg = _dependencies[i].getRegister();
bool found = false;
Expand Down
2 changes: 1 addition & 1 deletion compiler/codegen/StorageInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ TR_StorageInfo::mayOverlapWith(TR_StorageInfo *info)
}
else
{
if (startOne + std::min(_length, info->_length) - 1 >= overlapStart)
if (startOne + std::min(_length, info->_length) - 1 >= unsigned(overlapStart))
{
// 1 + std::min(3,6) - 1 >= 3 --> 3 >= 3
// 123456
Expand Down
6 changes: 3 additions & 3 deletions compiler/compile/OMRCompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ bool OMR::Compilation::incInlineDepth(TR_OpaqueMethodBlock *methodInfo, TR::Reso
int32_t maxCallerIndex = TR_ByteCodeInfo::maxCallerIndex;
//This restriction is due to a limited number of bits allocated to callerIndex in TR_ByteCodeInfo
//For example, in Java TR_ByteCodeInfo::maxCallerIndex is set to 4095 (12 bits and one used for signness)
if (self()->getNumInlinedCallSites() >= maxCallerIndex)
if (self()->getNumInlinedCallSites() >= unsigned(maxCallerIndex))
{
traceMsg(self(), "The maximum number of inlined methods %d is reached\n", TR_ByteCodeInfo::maxCallerIndex);
return false;
Expand Down Expand Up @@ -1392,7 +1392,7 @@ void OMR::Compilation::decInlineDepth(bool removeInlinedCallSitesEntry)
{
if (removeInlinedCallSitesEntry)
{
while (self()->getCurrentInlinedSiteIndex() < _inlinedCallSites.size())
while (unsigned(self()->getCurrentInlinedSiteIndex()) < _inlinedCallSites.size())
_inlinedCallSites.remove(self()->getCurrentInlinedSiteIndex());
if (self()->getOption(TR_EnableOSR))
{
Expand Down Expand Up @@ -2364,7 +2364,7 @@ OMR::Compilation::setOSRCallSiteRemat(uint32_t callSiteIndex, TR::SymbolReferenc
// Check the pending push is valid
uint32_t callerNumPPSlots = self()->getOSRCallSiteRematSize(callSiteIndex);
TR_ASSERT(ppSymRef->getSymbol()->isPendingPush(), "can only perform call site remat on pending pushes");
TR_ASSERT(slot >= 0 && slot < callerNumPPSlots, "can only perform call site remat for the caller's pending pushes");
TR_ASSERT(slot >= 0 && unsigned(slot) < callerNumPPSlots, "can only perform call site remat for the caller's pending pushes");
#endif

table[slot * 2] = ppSymRef->getReferenceNumber();
Expand Down
4 changes: 2 additions & 2 deletions compiler/compile/OMRSymbolReferenceTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1888,7 +1888,7 @@ bool OMR::SymbolReferenceTable::isNonHelper(TR::SymbolReference *symRef, CommonN

bool OMR::SymbolReferenceTable::isNonHelper(int32_t ref, CommonNonhelperSymbol s)
{
if (ref >= _numHelperSymbols && ref < _numHelperSymbols + getLastCommonNonhelperSymbol() && s < getLastCommonNonhelperSymbol())
if (unsigned(ref) >= _numHelperSymbols && unsigned(ref) < _numHelperSymbols + getLastCommonNonhelperSymbol() && s < getLastCommonNonhelperSymbol())
{
return ref == getNonhelperIndex(s);
}
Expand All @@ -1905,7 +1905,7 @@ bool OMR::SymbolReferenceTable::isNonHelper(TR::SymbolReference *symRef)

bool OMR::SymbolReferenceTable::isNonHelper(int32_t ref)
{
return (ref >= _numHelperSymbols && ref < _numHelperSymbols + getLastCommonNonhelperSymbol());
return (unsigned(ref) >= _numHelperSymbols && unsigned(ref) < _numHelperSymbols + getLastCommonNonhelperSymbol());
}

OMR::SymbolReferenceTable::CommonNonhelperSymbol OMR::SymbolReferenceTable::getNonHelperSymbol(TR::SymbolReference *symRef)
Expand Down
28 changes: 14 additions & 14 deletions compiler/compile/OSRData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ TR_OSRCompilationData::addInstruction(int32_t instructionPC, TR_ByteCodeInfo bcI

while (1)
{
if (bcInfo.getCallerIndex()+1 >= getOSRMethodDataArray().size())
if (unsigned(bcInfo.getCallerIndex()+1) >= getOSRMethodDataArray().size())
{
if (trace)
traceMsg(comp, " rejected: caller index %d +1 >= %d\n", bcInfo.getCallerIndex(), getOSRMethodDataArray().size());
Expand Down Expand Up @@ -245,7 +245,7 @@ TR_OSRCompilationData::compressInstruction2SharedSlotMap()
if (curInfo.size() != nextInfo.size())
break;

int j;
size_t j;
for (j = 0; j < curInfo.size(); j++)
if (!(curInfo[j] == nextInfo[j]))
break;
Expand Down Expand Up @@ -391,7 +391,7 @@ TR_OSRCompilationData::writeInstruction2SharedSlotMap(uint8_t* buffer) const
{
*((int32_t*)buffer) = (*itr).instructionPC; buffer += sizeof(int32_t);
*((int32_t*)buffer) = (*itr).scratchBufferInfos.size(); buffer += sizeof(int32_t);
for (int j = 0; j < (*itr).scratchBufferInfos.size(); j++)
for (auto j = 0U; j < (*itr).scratchBufferInfos.size(); j++)
{
const TR_ScratchBufferInfo info = (*itr).scratchBufferInfos[j];
buffer += info.writeToBuffer(buffer);
Expand Down Expand Up @@ -569,7 +569,7 @@ void TR_OSRCompilationData::buildDefiningMap(TR::Region &region)
DefiningMaps definingMapAtOSRCodeBlocks(numOfMethods, static_cast<DefiningMap*>(NULL), comp->trMemory()->currentStackRegion());
DefiningMaps definingMapAtPrepareForOSRCalls(numOfMethods, static_cast<DefiningMap*>(NULL), comp->trMemory()->currentStackRegion());

for (auto i = 0; i < methodDataArray.size(); ++i)
for (auto i = 0U; i < methodDataArray.size(); ++i)
{
TR_OSRMethodData *osrMethodData = methodDataArray[i];
if (!osrMethodData)
Expand Down Expand Up @@ -607,7 +607,7 @@ void TR_OSRCompilationData::buildDefiningMap(TR::Region &region)

if (comp->getOption(TR_TraceOSR))
{
for (auto i = 0; i < methodDataArray.size(); ++i)
for (auto i = 0U; i < methodDataArray.size(); ++i)
{
TR_OSRMethodData *osrMethodData = methodDataArray[i];
if (!osrMethodData)
Expand All @@ -625,7 +625,7 @@ void TR_OSRCompilationData::buildDefiningMap(TR::Region &region)
void TR_OSRCompilationData::clearDefiningMap()
{
const TR_Array<TR_OSRMethodData *>& methodDataArray = getOSRMethodDataArray();
for (auto i = 0; i < methodDataArray.size(); ++i)
for (auto i = 0U; i < methodDataArray.size(); ++i)
{
TR_OSRMethodData *osrMethodData = methodDataArray[i];
if (osrMethodData)
Expand Down Expand Up @@ -935,7 +935,7 @@ TR_OSRMethodData::collectSubTreeSymRefs(TR::Node *node, TR_BitVector *subTreeSym

void TR_OSRCompilationData::buildSymRefOrderMap()
{
for (int i = 0; i < getOSRMethodDataArray().size(); i++)
for (auto i = 0U; i < getOSRMethodDataArray().size(); i++)
{
TR_OSRMethodData* osrMethodData = getOSRMethodDataArray()[i];
if (osrMethodData == NULL ||
Expand All @@ -953,7 +953,7 @@ void TR_OSRCompilationData::buildSymRefOrderMapAux( TR_Array<List<TR::SymbolRefe
if (symListArray == NULL)
return;

for (auto j = 0; j < symListArray->size(); j++)
for (auto j = 0U; j < symListArray->size(); j++)
{
List<TR::SymbolReference>& symList = (*symListArray)[j];
bool sharedSlot = symList.getSize() > 1;
Expand Down Expand Up @@ -981,7 +981,7 @@ TR::Compilation& operator<< (TR::Compilation& out, const TR_OSRCompilationData&
{
out << "{";
bool first = true;
for (int i = 0; i < osrCompilationData.getOSRMethodDataArray().size(); i++)
for (auto i = 0U; i < osrCompilationData.getOSRMethodDataArray().size(); i++)
{
TR_OSRMethodData* osrMethodData = osrCompilationData.getOSRMethodDataArray()[i];
if (osrMethodData == NULL || osrMethodData->getOSRCodeBlock() == NULL || osrMethodData->isEmpty()) continue;
Expand All @@ -1008,7 +1008,7 @@ TR::Compilation& operator<< (TR::Compilation& out, const TR_OSRCompilationData&
sprintf(tmp, "%x", (*itr).instructionPC);
const TR_OSRCompilationData::TR_ScratchBufferInfos& array2 = (*itr).scratchBufferInfos;
out << tmp << " -> " << array2.size() << "[ ";
for (int j = 0; j < array2.size(); j++)
for (auto j = 0U; j < array2.size(); j++)
{
if (j != 0)
out << ", ";
Expand Down Expand Up @@ -1113,7 +1113,7 @@ bool
TR_OSRMethodData::inlinesAnyMethod() const
{
TR::Compilation* comp = getMethodSymbol()->comp();
for (int32_t i = 0; i < comp->getNumInlinedCallSites(); i++)
for (auto i = 0U; i < comp->getNumInlinedCallSites(); i++)
{
TR_InlinedCallSite& ics = comp->getInlinedCallSite(i);
if (ics._byteCodeInfo.getCallerIndex() == inlinedSiteIndex)
Expand Down Expand Up @@ -1312,7 +1312,7 @@ TR_OSRMethodData::addInstruction(int32_t instructionPC, int32_t byteCodeIndex)
bcInfoHashTab.DataAt(hashIndex)->getSlotInfos();
TR_OSRCompilationData::TR_ScratchBufferInfos info(comp()->trMemory());
//The "composition" of the three types of tuples happens here
for (int i = 0; i < slotInfos.size(); i++)
for (auto i = 0U; i < slotInfos.size(); i++)
{
int32_t scratchBufferOffset;
bool found = slot2ScratchBufferOffset.Locate(slotInfos[i].slot, hashIndex);
Expand Down Expand Up @@ -1453,7 +1453,7 @@ TR_OSRSlotSharingInfo::addSlotInfo(int32_t slot, int32_t symRefNum, int32_t symR
static bool trace = comp->getOption(TR_TraceOSR);
TR::SymbolReferenceTable* symRefTab = comp->getSymRefTab();
bool found = false;
for (int i = 0; i < slotInfos.size(); i++)
for (auto i = 0U; i < slotInfos.size(); i++)
{
TR_SlotInfo& info = slotInfos[i];
if (info.symRefNum != -1)
Expand Down Expand Up @@ -1507,7 +1507,7 @@ TR_OSRSlotSharingInfo::addSlotInfo(int32_t slot, int32_t symRefNum, int32_t symR
TR::Compilation& operator<< (TR::Compilation& out, const TR_OSRSlotSharingInfo* osrSlotSharingInfo)
{
out << "{slotInfos: [";
for (int i = 0; i < osrSlotSharingInfo->slotInfos.size(); i++)
for (auto i = 0U; i < osrSlotSharingInfo->slotInfos.size(); i++)
{
const TR_OSRSlotSharingInfo::TR_SlotInfo& info = osrSlotSharingInfo->slotInfos[i];
if (i != 0)
Expand Down
4 changes: 2 additions & 2 deletions compiler/compile/ResolvedMethod.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -551,12 +551,12 @@ void TR_ResolvedMethod::makeParameterList(TR::ResolvedMethodSymbol *methodSym)
int32_t ordinal = 0;

uint32_t parmSlots = numberOfParameterSlots();
for (int32_t parmIndex = 0; parmIndex < parmSlots; ++parmIndex)
for (auto parmIndex = 0U; parmIndex < parmSlots; ++parmIndex)
{
parmSymbol = methodSym->comp()->getSymRefTab()->createParameterSymbol(methodSym, slot, parmType(parmIndex));
parmSymbol->setOrdinal(ordinal++);

char *s = getParameterTypeSignature(parmIndex);
char *s = getParameterTypeSignature(static_cast<int32_t>(parmIndex));
uint32_t len = static_cast<uint32_t>(strlen(s));
parmSymbol->setTypeSignature(s, len);

Expand Down
Loading

0 comments on commit 131c4a7

Please sign in to comment.