diff --git a/include/base/SMPDataFlowAnalysis.h b/include/base/SMPDataFlowAnalysis.h index a2cf19cfb1f4472c9c2d3a226694e70d4f69f949..087ce17d7b366615fc317c21e25e40d9a81e70ce 100644 --- a/include/base/SMPDataFlowAnalysis.h +++ b/include/base/SMPDataFlowAnalysis.h @@ -540,7 +540,7 @@ enum SMPOperandType { // What type is a given register or memory operand? #define MakeProfDerived(OpType) ((SMPOperandType)(OpType | PROF_BASE)) // Meet function over any two types in the type lattice. -SMPOperandType SMPTypeMeet(SMPOperandType Type1, SMPOperandType Type2); +SMPOperandType SMPTypeMeet(SMPOperandType Type1, SMPOperandType Type2, bool &ErrorFlag); // Meet function for SCCP constant propagation; updates NewConstStruct void STARSConstantTypeMeet(struct STARS_SCCP_Const_Struct OldConstStruct, struct STARS_SCCP_Const_Struct &NewConstStruct); diff --git a/src/base/SMPDataFlowAnalysis.cpp b/src/base/SMPDataFlowAnalysis.cpp index 4294fa82fa1e165bafe8cbdb7ef52a4731f1352b..b2d6eccab610997d80d5c49f4fba67f82b995575 100644 --- a/src/base/SMPDataFlowAnalysis.cpp +++ b/src/base/SMPDataFlowAnalysis.cpp @@ -2777,8 +2777,9 @@ bool MDKnownOperandType(const STARSOpndTypePtr &TempOp) { } // Meet function over any two types in the type lattice. -SMPOperandType SMPTypeMeet(SMPOperandType Type1, SMPOperandType Type2) { +SMPOperandType SMPTypeMeet(SMPOperandType Type1, SMPOperandType Type2, bool &ErrorFlag) { SMPOperandType MeetType = UNKNOWN; + ErrorFlag = false; bool ProfDerived = IsProfDerived(Type1) || IsProfDerived(Type2); if (IsEqType(UNINIT, Type1)) MeetType = Type2; @@ -2790,16 +2791,20 @@ SMPOperandType SMPTypeMeet(SMPOperandType Type1, SMPOperandType Type2) { MeetType = CODEPTR; else if (IsDataPtr(Type2) || IsUnknown(Type2)) MeetType = UNKNOWN; - else + else { SMP_msg("ERROR #1 in SMPTypeMeet.\n"); + ErrorFlag = true; + } } else if (IsDataPtr(Type1)) { if (IsDataPtr(Type2)) // two different POINTER subtypes MeetType = POINTER; else if (IsNumeric(Type2) || IsUnknown(Type2)) MeetType = UNKNOWN; - else + else { SMP_msg("ERROR #2 in SMPTypeMeet.\n"); + ErrorFlag = true; + } } if (ProfDerived && IsNotEqType(UNINIT, MeetType)) MeetType = MakeProfDerived(MeetType); diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index 24606f0cf636661430b408f9b19beda5f009da62..d7ae435a9a88691c05b7018e6d23c27d478bcb00 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -3117,7 +3117,12 @@ bool SMPFunction::MDFindReturnTypes(void) { if ((! UseOp->IsRegOp()) || (global_STARS_program->GetSTARS_MD_LAST_SAVED_REG_NUM() < UseOp->GetReg())) continue; SMPOperandType OldType = this->ReturnRegTypes.at(UseOp->GetReg()); - SMPOperandType NewType = SMPTypeMeet(OldType, CurrUse->GetType()); + bool TypeErrorFlag = false; + SMPOperandType NewType = SMPTypeMeet(OldType, CurrUse->GetType(), TypeErrorFlag); + if (TypeErrorFlag) { + SMP_msg("ERROR: TypeMeet error in MDFindReturnTypes() func at %llx return at %llx\n", + (uint64_t) this->GetFirstFuncAddr(), (uint64_t) CurrInst->GetAddr()); + } if (NewType != OldType) { this->ReturnRegTypes[UseOp->GetReg()] = NewType; changed = true; @@ -3172,7 +3177,12 @@ void SMPFunction::MDFindIncomingTypes(void) { // Found it. See if we have type info. SMPOperandType CallSiteType = CallSiteUseIter->GetType(); SMPOperandType OldType = this->IncomingRegTypes[RegNum]; - this->IncomingRegTypes[RegNum] = SMPTypeMeet(CallSiteType, OldType); + bool TypeErrorFlag = false; + this->IncomingRegTypes[RegNum] = SMPTypeMeet(CallSiteType, OldType, TypeErrorFlag); + if (TypeErrorFlag) { + SMP_msg("ERROR: TypeMeet error in MDFindIncomingTypes() at %llx\n", + (uint64_t) this->GetFirstFuncAddr()); + } // Note this type meet function is used in an aggressive way here, as // a mixture of UNINIT and NUMERIC at various call sites will produce NUMERIC, for example. // We are not demanding that all call sites have a consistent type with no UNINIT instances. @@ -13201,7 +13211,12 @@ void SMPFunction::GatherIncomingArgTypes(void) { } else { // Not the first time to see arg; could be processing an arg one byte at a time, for example. // Do not increment ArgCount for duplicate processing. MaxInArgIndex does not need updating, either. - this->InArgTypes[ArgIndex] = (unsigned short) SMPTypeMeet((SMPOperandType) this->InArgTypes[ArgIndex], ArgType); + bool TypeErrorFlag = false; + this->InArgTypes[ArgIndex] = (unsigned short) SMPTypeMeet((SMPOperandType) this->InArgTypes[ArgIndex], ArgType, TypeErrorFlag); + if (TypeErrorFlag) { + SMP_msg("ERROR: TypeMeet error in GatherIncomingArgType() for func at %llx\n", + (uint64_t) this->GetFirstFuncAddr()); + } } } else { diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp index 4a56f203ffc26fa0ca533b957cac0d720ecfad0c..c37bb92eff3311d236e45534dd507248381c7ccc 100644 --- a/src/base/SMPInstr.cpp +++ b/src/base/SMPInstr.cpp @@ -11393,7 +11393,12 @@ void SMPInstr::MDSetWidthSignInfo(bool UseFP) { else if (FGEntry.SizeInfo & FG_MASK_DATAPOINTER) { NewDefType = POINTER; } - NewDefType = SMPTypeMeet(DefType, NewDefType); + bool TypeErrorFlag = false; + NewDefType = SMPTypeMeet(DefType, NewDefType, TypeErrorFlag); + if (TypeErrorFlag) { + SMP_msg("ERROR: TypeMeet error in MDSetWidthSignInfo() at %llx\n", + (uint64_t) this->GetAddr()); + } bool UpdateType = ((NewDefType != DefType) && (DefType == UNINIT)); if (UpdateType) { DefIter = this->SetDefType(DefOp, NewDefType); @@ -12792,7 +12797,12 @@ bool SMPInstr::InferTypes(void) { STARSOpndTypePtr CallUseOp = CallUseIter->GetOp(); if (CalleeFunc->GetMarkerInstDefType(CallUseOp, CallUseType)) { // CalleeFunc marker inst DEFed the current use with type CallUseType. - CallUseType = SMPTypeMeet(CallUseType, CallUseIter->GetType()); + bool TypeErrorFlag = false; + CallUseType = SMPTypeMeet(CallUseType, CallUseIter->GetType(), TypeErrorFlag); + if (TypeErrorFlag) { + SMP_msg("ERROR: TypeMeet error at call addr %llx CalleeAddr %llx\n", + (uint64_t) this->GetAddr(), (uint64_t) CalleeAddr); + } CallUseIter = this->SetUseType(CallUseOp, CallUseType); } ++CallUseIter;