diff --git a/src/base/SMPBasicBlock.cpp b/src/base/SMPBasicBlock.cpp index a05623ded40190d9b6082df4580cfde4f71594a3..6694e5121f664091a43bbc54af7a6c5eb56fac70 100644 --- a/src/base/SMPBasicBlock.cpp +++ b/src/base/SMPBasicBlock.cpp @@ -1233,7 +1233,7 @@ std::vector<SMPInstr *>::const_iterator SMPBasicBlock::GetInstConstIterFromAddr( // Get the InstVec index for the instruction at InstAddr. Assert if not found. size_t SMPBasicBlock::GetIndexFromInstAddr(STARS_ea_t InstAddr) const { - SMPInstr *CurrInst = NULL; + SMPInstr *CurrInst = nullptr; STARS_ea_t CurrAddr = 0; size_t VecIndex = 0; size_t UpperLimit = this->InstVec.size(); @@ -1276,7 +1276,7 @@ size_t SMPBasicBlock::GetIndexFromInstAddr(STARS_ea_t InstAddr) const { return VecIndex; } // end of SMPBasicBlock::GetIndexFromInstAddr() -// Find the compare or test that sets the flags used in COND_BRANCH at end of block, else NULL; If decrement found instead, fill DecAddr +// Find the compare or test that sets the flags used in COND_BRANCH at end of block, else nullptr; If decrement found instead, fill DecAddr // Set the BranchOperator to correspond to the type of COND_BRANCH opcode. SMPInstr * SMPBasicBlock::FindBranchCompareOrTest(SMPoperator &BranchOperator, STARS_ea_t &DecAddr) const { SMPInstr *CompareOrTestInst = nullptr; @@ -1572,7 +1572,7 @@ STARS_ea_t SMPBasicBlock::GetUltimateDefAddr(const STARSOpndTypePtr &UseOp, STAR else if (RecurseOnMoves) { if (!(STARS_IsBlockNumPseudoID(DefAddr) || STARS_IsSSAMarkerPseudoID(DefAddr))) { // not Phi or SSA Marker DEF, real inst found SMPInstr *CurrInst = this->GetFunc()->GetInstFromAddr(DefAddr); - assert(NULL != CurrInst); + assert(nullptr != CurrInst); bool NewDefMoveOp = false; #if 0 if (CurrInst->MDIsMoveInstr()) { @@ -1650,7 +1650,7 @@ bool SMPBasicBlock::GetUltimateInitValue(const STARSOpndTypePtr &UseOp, STARS_ea else { if (!(STARS_IsBlockNumPseudoID(DefAddr) || STARS_IsSSAMarkerPseudoID(DefAddr))) { // not Phi or SSA Marker DEF, real inst found SMPInstr *CurrInst = this->GetFunc()->GetInstFromAddr(DefAddr); - assert(NULL != CurrInst); + assert(nullptr != CurrInst); STARS_uval_t ConstValue; bool NewDefMoveOp = CurrInst->IsSimpleOrExtendedCopy(DefMoveOp); if (NewDefMoveOp && DefMoveOp->IsImmedOp()) { @@ -1746,7 +1746,7 @@ bool SMPBasicBlock::GetUltimateInitValue(const STARSOpndTypePtr &UseOp, STARS_ea // Does DefOp get written out in truncated form (lower bits only)? bool SMPBasicBlock::IsOpDestTruncatedWrite(const STARSOpndTypePtr &DefOp, int DefSSANum, STARS_ea_t DefAddr) { vector<SMPInstr *>::iterator InstIter; - SMPInstr *LastUseInst = NULL; + SMPInstr *LastUseInst = nullptr; set<DefOrUse, LessDefUse>::iterator DefIter; bool RegisterOp = (DefOp->IsRegOp()); bool LastUseIsTruncatedWrite = false; @@ -1780,7 +1780,7 @@ bool SMPBasicBlock::IsOpDestTruncatedWrite(const STARSOpndTypePtr &DefOp, int De // otherwise, it is. LastUseIsTruncatedWrite = LastUseInst->IsNonAddressReg(DefOp); } - if (!LastUseIsTruncatedWrite && (NULL != LastUseInst)) { + if (!LastUseIsTruncatedWrite && (nullptr != LastUseInst)) { // See if we can recurse through a regular move. if (LastUseInst->MDIsMoveInstr()) { DefIter = LastUseInst->GetFirstNonFlagsDef(); @@ -2626,7 +2626,7 @@ void SMPBasicBlock::MarkBranchSignedness(void) { // soon as we see an instruction other than a move, compare, or test. void SMPBasicBlock::PropagateBranchSignedness(STARS_ea_t DefAddr, const STARSOpndTypePtr &SearchOp, unsigned short SignMask) { SMPInstr *DefInst; - SMPBasicBlock *DefBlock = NULL; + SMPBasicBlock *DefBlock = nullptr; set<DefOrUse, LessDefUse>::iterator UseIter; set<DefOrUse, LessDefUse>::iterator DefIter; int DefHashValue, UseHashValue; @@ -5748,7 +5748,7 @@ bool SMPBasicBlock::IsBenignOverflowDEF(const STARSOpndTypePtr &DefOp, int DefSS } } - SMPInstr *SourceInst = NULL; + SMPInstr *SourceInst = nullptr; SourceInstAddr = STARS_BADADDR; UseSSANum = SMP_SSA_UNINIT; SpecialSourceFound = false; @@ -6304,7 +6304,7 @@ bool SMPBasicBlock::IsBenignTruncationDEF(const STARSOpndTypePtr &DefOp, int Def STARSOpndTypePtr UseOp = nullptr, SearchOp = nullptr, UseOp2 = nullptr; unsigned short SignMask; bool FoundTruncationDef = false; // Found apparent truncation move - SMPInstr *TruncationInst = NULL; + SMPInstr *TruncationInst = nullptr; size_t UseBitWidth = 0; // Bit width involved in truncation move size_t BytesMasked; bool FoundSubregUse = false; // Found next use of truncated DEF, which appears to make truncation benign @@ -6440,7 +6440,7 @@ bool SMPBasicBlock::IsBenignTruncationDEF(const STARSOpndTypePtr &DefOp, int Def SMPInstr *DefInst = this->GetFunc()->GetInstFromAddr(DefAddr); STARS_ea_t SourceInstAddr = STARS_BADADDR; - SMPInstr *SourceInst = NULL; + SMPInstr *SourceInst = nullptr; int DefUseSSANum = SMP_SSA_UNINIT; bool SpecialSourceFound = false; bool UseFP = this->GetFunc()->UsesFramePointer(); diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index f7cd9530ffaf245ab0884e364c4acccd19790636..fb4c1882321ffc56122a8131842c7f75b168816b 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -377,13 +377,13 @@ SMPFunction::~SMPFunction() { list<SMPInstr *>::iterator InstIter; for (InstIter = this->Instrs.begin(); InstIter != this->Instrs.end(); ++InstIter) { SMPInstr *CurrInst = (*InstIter); - if (NULL != CurrInst) delete CurrInst; + if (nullptr != CurrInst) delete CurrInst; } list<SMPBasicBlock *>::iterator BlockIter; for (BlockIter = this->Blocks.begin(); BlockIter != this->Blocks.end(); ++BlockIter) { SMPBasicBlock *CurrBlock = (*BlockIter); - if (NULL != CurrBlock) delete CurrBlock; + if (nullptr != CurrBlock) delete CurrBlock; } if (global_STARS_program->ShouldSTARSTranslateToSPARKAda()) { @@ -479,7 +479,7 @@ void SMPFunction::DestroyLoopExprs(void) { // Get a non-stale pointer to the STARS_Function_t info for the current function. STARS_Function_t *SMPFunction::GetFuncInfo(void) const { STARS_Function_t *myPtr = SMP_get_func(this->GetFirstFuncAddr()); - assert(NULL != myPtr); + assert(nullptr != myPtr); return myPtr; } @@ -1298,7 +1298,7 @@ void SMPFunction::IncrementJumpToFollowNodeCounter(STARS_ea_t InstAddr) { void SMPFunction::AddCallSource(STARS_ea_t addr) { // Convert call instruction address to beginning address of the caller. STARS_Function_t *FuncInfo = SMP_get_func(addr); - if (NULL == FuncInfo) { + if (nullptr == FuncInfo) { SMP_msg("SERIOUS WARNING: Call location %llx not in a function.\n", (unsigned long long) addr); return; } @@ -1805,7 +1805,7 @@ void SMPFunction::EraseInstRange(STARS_ea_t FirstAddr, STARS_ea_t LastAddr) { void SMPFunction::ComputeTempReachingDefs(const STARSOpndTypePtr &TempOp, STARS_ea_t UseAddr) { this->TempReachingDefs.clear(); SMPBasicBlock *CurrBlock = this->GetBlockFromInstAddr(UseAddr); - assert(NULL != CurrBlock); + assert(nullptr != CurrBlock); STARSDefinitionSet::iterator ReachesInIter; pair<set<STARS_ea_t, LessAddr>::iterator, bool> InsertResult; @@ -1898,7 +1898,7 @@ STARS_sval_t SMPFunction::GetStackAdjustmentForCallee(STARS_ea_t CallAddr) { STARS_sval_t CalleeAdjustment = 0; SMPBasicBlock *CallBlock = this->GetBlockFromInstAddr(CallAddr); - assert(NULL != CallBlock); + assert(nullptr != CallBlock); STARS_sval_t BlockAnalysisDelta = CallBlock->ComputeStackAdjustmentAfterCall(CallAddr); if (0 != BlockAnalysisDelta) { CalleeAdjustment = BlockAnalysisDelta; @@ -1951,7 +1951,7 @@ STARS_sval_t SMPFunction::ComputeGlobalStackAdjustment(void) { for (CallSiteIter = this->AllCallSites.begin(); CallSiteIter != this->AllCallSites.end(); ++CallSiteIter) { STARS_ea_t CallSiteAddr = (*CallSiteIter); STARS_Function_t *CurrFunc = SMP_get_func(CallSiteAddr); - assert(NULL != CurrFunc); + assert(nullptr != CurrFunc); STARS_ea_t CallerFirstAddr = CurrFunc->get_startEA(); SMPFunction *CallerFunc = this->GetProg()->FindFunction(CallerFirstAddr); assert(nullptr != CallerFunc); @@ -3208,7 +3208,7 @@ void SMPFunction::MDFindSavedRegs(void) { list<SMPInstr *>::iterator InstIter; int RegIndex; STARS_Function_t *CurrFunc = SMP_get_func(this->GetStartAddr()); - assert(NULL != CurrFunc); + assert(nullptr != CurrFunc); for (InstIter = this->Instrs.begin(); InstIter != this->Instrs.end(); ++InstIter) { SMPInstr *CurrInst = (*InstIter); @@ -3317,14 +3317,14 @@ void SMPFunction::MDFindIncomingTypes(void) { for (CallSiteIter = this->AllCallSites.begin(); CallSiteIter != this->AllCallSites.end(); ++CallSiteIter) { STARS_ea_t CallSiteAddr = (*CallSiteIter); STARS_Function_t *CurrFunc = SMP_get_func(CallSiteAddr); - assert(NULL != CurrFunc); + assert(nullptr != CurrFunc); STARS_ea_t CallerFirstAddr = CurrFunc->get_startEA(); SMPFunction *CallerFunc = this->GetProg()->FindFunction(CallerFirstAddr); if (nullptr == CallerFunc) { SMP_msg("FATAL ERROR: Program has no function at %llx which should be a caller of %llx\n", (unsigned long long) CallerFirstAddr, (unsigned long long) this->GetFirstFuncAddr()); } - assert(NULL != CallerFunc); + assert(nullptr != CallerFunc); SMPInstr *CallSiteInst = CallerFunc->GetInstFromAddr(CallSiteAddr); // Iterate through USE regs in our marker inst, match them to USEs in call inst. SMPInstr *MarkerInst = this->Instrs.front(); @@ -3378,10 +3378,10 @@ void SMPFunction::BuildLocalVarTable(void) { void SMPFunction::BuildStackAccessTables(void) { STARS_Function_t *FuncPtr = SMP_get_func(this->GetStartAddr()); - if (NULL == FuncPtr) { + if (nullptr == FuncPtr) { SMP_msg("FATAL ERROR in SMPFunction::SemiNaiveLocalVarID; no func ptr\n"); } - assert(NULL != FuncPtr); + assert(nullptr != FuncPtr); // If AnalyzedSP is false, that is all we can do. if (!this->AnalyzedSP) { @@ -3481,7 +3481,7 @@ void SMPFunction::BuildStackAccessTables(void) { STARS_sval_t AccessTableEntriesCount = this->MaxStackAccessLimit - this->MinStackAccessOffset; for (int i = this->MinStackAccessOffset; i < this->MaxStackAccessLimit; ++i) { struct StackFrameEntry TempEntry; - TempEntry.VarPtr = NULL; + TempEntry.VarPtr = nullptr; TempEntry.offset = (long) i; TempEntry.Read = false; TempEntry.Written = false; @@ -6206,7 +6206,7 @@ void SMPFunction::SparseConditionalConstantPropagation(void) { bool FoundReDEF = false; while (InstIter != CurrBlock->GetLastInst()) { SMPInstr *CurrInst = (*InstIter); - assert(NULL != CurrInst); + assert(nullptr != CurrInst); set<DefOrUse, LessDefUse>::iterator UseIter = CurrInst->FindUse(DefOp); if (UseIter != CurrInst->GetLastUse()) { // operand is USEd; check SSANum int UseSSANum = UseIter->GetSSANum(); @@ -6527,7 +6527,7 @@ bool SMPFunction::HasIntErrorCallSink(const STARSOpndTypePtr &DefOp, int DefSSAN this->ResetProcessedBlocks(); // prepare for recursion through blocks SinkString.clear(); SMPBasicBlock *CurrBlock = this->GetBlockFromInstAddr(DefAddr); - assert(CurrBlock != NULL); + assert(CurrBlock != nullptr); bool FoundSink = CurrBlock->IsCriticalSink(DefOp, DefSSANum, SinkString, FoundAnyCall); @@ -7218,7 +7218,7 @@ void SMPFunction::DetectLoopInvariantDEFs(void) { DefAddrIter != this->LoopInvariantDEFs[LoopNum].cend(); ++DefAddrIter) { STARS_ea_t CurrDefAddr = (*DefAddrIter); SMPBasicBlock *CurrBlock = this->GetBlockFromInstAddr(CurrDefAddr); - assert(NULL != CurrBlock); + assert(nullptr != CurrBlock); if (CurrBlock->GetNumber() != CurrentBlockNum) { // cached LoopList is stale CurrentBlockNum = CurrBlock->GetNumber(); LoopList.clear(); @@ -7422,7 +7422,7 @@ void SMPFunction::DetectLoopInductionVars(void) { // Last chance to detect BIV: Is SecondOp a USE of a loop-invariant DEF? // Note that block-local names are loop-variant and are already excluded. SMPBasicBlock *InsideDefBlock = this->GetBlockByNum((size_t)PhiUseDefBlockNum1); - assert(NULL != InsideDefBlock); + assert(nullptr != InsideDefBlock); STARS_ea_t SecondOpDefAddr = InsideDefBlock->GetDefAddrFromUseAddr(SearchOp, InsideDefAddr, SecondOpUseIter->GetSSANum(), false); assert(STARS_BADADDR != SecondOpDefAddr); int SecondOpDefBlockNum = SMP_BLOCKNUM_UNINIT; @@ -10564,14 +10564,14 @@ void SMPFunction::FindSwitchIDom(struct SwitchTableInfo &TableInfo) { else { // Find the blocks that jump to the default block. Mark the jumps while computing the IDom over all of them. SMPBasicBlock *DefaultCaseBlock = this->GetBlockByNum((size_t) TableInfo.DefaultCaseBlockNum); - assert(NULL != DefaultCaseBlock); + assert(nullptr != DefaultCaseBlock); list<SMPBasicBlock *>::iterator PredIter = DefaultCaseBlock->GetFirstPred(); assert(PredIter != DefaultCaseBlock->GetLastPred()); int IDom = (int) this->RPOBlocks.size(); // Find lowest RPO number, init to max while (PredIter != DefaultCaseBlock->GetLastPred()) { SMPBasicBlock *PredBlock = (*PredIter); SMPInstr *LastInst = (*(--PredBlock->GetLastInst())); - assert(NULL != LastInst); + assert(nullptr != LastInst); SMPitype FlowType = LastInst->GetDataFlowType(); if ((COND_BRANCH == FlowType) || (JUMP == FlowType)) { this->SetControlFlowType(LastInst->GetAddr(), JUMP_TO_DEFAULT_CASE); @@ -10687,7 +10687,7 @@ bool SMPFunction::FindSwitchStatementFollowBlock(struct SwitchTableInfo &TableIn // every time we see such an entry. #if 0 // indirection, or not? DefaultJumpAddr seems to be the first inst in the default case. SMPInstr *DefJumpInst = this->GetInstFromAddr(TableInfo.DefaultJumpAddr); - assert(NULL != DefJumpInst); + assert(nullptr != DefJumpInst); STARS_ea_t DefaultCaseAddr = DefJumpInst->GetJumpTarget(); #else STARS_ea_t DefaultCaseAddr = TableInfo.DefaultJumpAddr; @@ -10696,7 +10696,7 @@ bool SMPFunction::FindSwitchStatementFollowBlock(struct SwitchTableInfo &TableIn DefaultBlockNum = TableInfo.DefaultCaseBlockNum; assert(SMP_BLOCKNUM_UNINIT != DefaultBlockNum); SMPBasicBlock *DefaultBlock = this->GetBlockByNum(DefaultBlockNum); - assert(NULL != DefaultBlock); + assert(nullptr != DefaultBlock); DefaultBlock->SetSwitchDefaultCase(); for (size_t CaseIndex = 0; CaseIndex < TableInfo.CaseBlockNums.size(); ++CaseIndex) { if (TableInfo.CaseBlockNums[CaseIndex] == DefaultBlockNum) { @@ -10765,7 +10765,7 @@ int SMPFunction::FindCaseFollowBlock(int CaseBlockNum, int HeaderBlockNum, std:: // If one of our successors finds a follow block and the others all return -2, return the follow block number. // If we reach a block not dominated by HeaderBlockNum before finding a follow block or a visited block, return -1. SMPBasicBlock *CaseBlock = this->GetBlockByNum(CaseBlockNum); - assert(NULL != CaseBlock); + assert(nullptr != CaseBlock); CaseBlock->SetProcessed(true); // visited for (list<SMPBasicBlock *>::iterator SuccIter = CaseBlock->GetFirstSucc(); SuccIter != CaseBlock->GetLastSucc(); ++SuccIter) { SMPBasicBlock *SuccBlock = (*SuccIter); @@ -11169,7 +11169,7 @@ bool SMPFunction::AnalyzeConditionalStatements(void) { // Insert mappping from COND_BRANCH to follow block. int ElsifBlockNum = UnresolvedBranchBlocks[ElsifIndex]; SMPBasicBlock *ElsifBlock = this->GetBlockByNum(ElsifBlockNum); - assert(NULL != ElsifBlock); + assert(nullptr != ElsifBlock); STARS_ea_t ElsifAddr = ElsifBlock->GetLastAddr(); assert(STARS_BADADDR != ElsifAddr); pair<STARS_ea_t, int> MapItem(ElsifAddr, FollowNodeNum); @@ -11197,7 +11197,7 @@ bool SMPFunction::AnalyzeConditionalStatements(void) { else { // Found a good follow node. assert((0 <= FollowNodeNum) && (FollowNodeNum < (int) this->RPOBlocks.size())); SMPBasicBlock *FollowBlock = this->GetBlockByNum((size_t) FollowNodeNum); - assert(NULL != FollowBlock); + assert(nullptr != FollowBlock); bool IfThenCase = FollowBlock->IsBlockPred(HeadBlockNum); if (IfThenCase) { this->SetControlFlowType(LastAddr, BRANCH_IF_THEN); @@ -11233,7 +11233,7 @@ bool SMPFunction::AnalyzeConditionalStatements(void) { // Insert mappping from COND_BRANCH to follow block. int ElsifBlockNum = UnresolvedBranchBlocks[ElsifIndex]; SMPBasicBlock *ElsifBlock = this->GetBlockByNum(ElsifBlockNum); - assert(NULL != ElsifBlock); + assert(nullptr != ElsifBlock); STARS_ea_t ElsifAddr = ElsifBlock->GetLastAddr(); assert(STARS_BADADDR != ElsifAddr); pair<STARS_ea_t, int> MapItem(ElsifAddr, FollowNodeNum); @@ -12163,7 +12163,7 @@ void SMPFunction::RemoveBlock(SMPBasicBlock *CurrBlock, list<SMPBasicBlock *>::i // It cannot hurt to add INSTR BELONGTO annotations to the main annotations file. STARS_ea_t FuncAddr = this->GetFirstFuncAddr(); FILE *AnnotFile = global_STARS_program->GetAnnotFile(); - assert(NULL != AnnotFile); + assert(nullptr != AnnotFile); for (vector<SMPInstr *>::iterator InstIter = CurrBlock->GetFirstInst(); InstIter != CurrBlock->GetLastInst(); ++InstIter) { SMPInstr *CurrInst = (*InstIter); STARS_ea_t InstAddr = CurrInst->GetAddr(); @@ -12214,7 +12214,7 @@ void SMPFunction::RemoveCallingBlocks(void) const { } else { SMPBasicBlock *CallingBlock = CallingFunc->GetBlockFromInstAddr(CallInstAddr); - assert(NULL != CallingBlock); + assert(nullptr != CallingBlock); this->GetProg()->AddBlockToRemovalList(CallingBlock); } } @@ -12426,7 +12426,7 @@ void SMPFunction::SetLinks(void) { while (InstIter != CurrBlock->GetLastInst()) { SMPInstr *DeadInst = (*InstIter); ++InstIter; - if (NULL != DeadInst) delete DeadInst; + if (nullptr != DeadInst) delete DeadInst; } delete CurrBlock; #endif @@ -13530,7 +13530,7 @@ void SMPFunction::AnalyzeLoopIterations(void) { SMPoperator BranchOperator = SMP_NULL_OPERATOR; STARS_ea_t DecrementAddr = STARS_BADADDR; SMPInstr *CompareOrTestInst = TestBlock->FindBranchCompareOrTest(BranchOperator, DecrementAddr); - if (NULL != CompareOrTestInst) { + if (nullptr != CompareOrTestInst) { CompareOrTestInst->GetCompareOrTestExpr(CurrentLoopComparisonExpr); CurrentLoopComparisonExpr.CompareOperator = BranchOperator; CurrentLoopComparisonExpr.CompareAddr = CompareOrTestInst->GetAddr(); @@ -13752,24 +13752,36 @@ void SMPFunction::AnalyzeLoopIterations(void) { SMP_msg("ERROR: LOOP: Failure to create IterationCountExpr for loop %zu in function at %llx\n", LoopIndex, (uint64_t) this->GetFirstFuncAddr()); this->LoopAnalysisProblems[LoopIndex] = true; + if (nullptr != InitExpr) + delete InitExpr; + if (nullptr != LimitExpr) + delete LimitExpr; } } else { SMP_msg("ERROR: LOOP: Failure on ExpandExpr() for LimitExpr in AnalyzeLoopIterations() for loop %zu in function at %llx\n", LoopIndex, (uint64_t) this->GetFirstFuncAddr()); this->LoopAnalysisProblems[LoopIndex] = true; + if (nullptr != InitExpr) + delete InitExpr; + if (nullptr != LimitExpr) + delete LimitExpr; } } else { SMP_msg("ERROR: LOOP: Failure to create LimitExpr for loop %zu in function at %llx\n", LoopIndex, (uint64_t) this->GetFirstFuncAddr()); this->LoopAnalysisProblems[LoopIndex] = true; + if (nullptr != InitExpr) + delete InitExpr; } } else { SMP_msg("ERROR: LOOP: Failure on ExpandExpr() for InitExpr in AnalyzeLoopIterations() for loop %zu in function at %llx\n", LoopIndex, (uint64_t) this->GetFirstFuncAddr()); this->LoopAnalysisProblems[LoopIndex] = true; + if (nullptr != InitExpr) + delete InitExpr; } } } @@ -14802,7 +14814,7 @@ void SMPFunction::AnalyzeSystemCalls(void) { if (!UnresolvedCallee) { // We have an instruction addr in EAXDefAddr. SMPInstr *EAXDefInst = this->GetInstFromAddr(EAXDefAddr); - if (EAXDefInst == NULL) + if (EAXDefInst == nullptr) UnresolvedCallee = true; STARSDefUseIter UseIter; @@ -14815,8 +14827,8 @@ void SMPFunction::AnalyzeSystemCalls(void) { SMP_msg("INFO: System call set of EAX. Use found. at: %llx\n", (unsigned long long) EAXDefAddr); STARSOpndTypePtr UseOp = UseIter->GetOp(); - // if UseOp is NULL or not an immediate, callee cannot be resolved. - if (UseOp == NULL) + // if UseOp is nullptr or not an immediate, callee cannot be resolved. + if (UseOp == nullptr) UnresolvedCallee = true; else UnresolvedCallee = (!UseOp->IsImmedOp()); @@ -14858,7 +14870,7 @@ void SMPFunction::DetectUninitializedVars(void) { bool UseFP = this->UsesFramePointer(); bool Binary32 = (global_STARS_program->GetSTARS_ISA_Bitwidth() <= 32); FILE *WarningsFile = global_STARS_program->GetUninitVarFile(); - assert(NULL != WarningsFile); + assert(nullptr != WarningsFile); // Look at stack vars with negative offsets in the SSA Marker inst list<SMPInstr *>::iterator InstIter = this->GetFirstInstIter(); SMPInstr *MarkerInst = (*InstIter); @@ -15511,7 +15523,7 @@ bool SMPFunction::CounterVarHelper(const STARSOpndTypePtr &DefOp, int DefSSANum, // 3. Within the single-block loop, Phi DEF is used in a counter-style operation, with new DEF becoming a Phi USE at top of block. // We will expand this to loops that are not in a single block later. SMPBasicBlock *CurrBlock = this->GetBlockByNum((std::size_t) BlockNum); - assert(NULL != CurrBlock); + assert(nullptr != CurrBlock); STARS_ea_t DefAddr = CounterSSANums.front().second; if (CurrBlock->DoesDefReachBlockEnd(DefAddr, DefOp, DefSSANum, NonEscapingRegisterHashes)) { NonEscapingRegisterHashes.clear(); // Not memoizing for this use of DoesDefReachBlockEnd() @@ -16305,7 +16317,7 @@ void SMPFunction::TraceInArgPointers(void) { // Mark the InArgs that are code or data pointers. vector<SMPInstr *>::iterator FirstInstIter = this->RPOBlocks[0]->GetFirstInst(); SMPInstr *FirstInst = (*FirstInstIter); - assert(NULL != FirstInst); + assert(nullptr != FirstInst); assert(FirstInst->IsMarkerInst()); for (size_t index = 0; index < this->NumGlobalNames(); ++index) { set<STARS_ea_t> EmptySet; @@ -16336,7 +16348,7 @@ void SMPFunction::TraceInArgPointers(void) { // NOTE: Extend to more complicated cases with phi functions, etc., iterating until no more changes in the future. !!!!****!!!! for (size_t BlockIndex = 0; BlockIndex < this->RPOBlocks.size(); ++BlockIndex) { SMPBasicBlock *CurrBlock = this->RPOBlocks[BlockIndex]; - assert(NULL != CurrBlock); + assert(nullptr != CurrBlock); // Iterate through instructions in the current block and find the simple copy RTLs. for (vector<SMPInstr *>::iterator InstIter = CurrBlock->GetFirstInst(); InstIter != CurrBlock->GetLastInst(); ++InstIter) { SMPInstr *CurrInst = (*InstIter); @@ -16716,7 +16728,7 @@ bool SMPFunction::FindShadowingPoint2(const ShadowPoint CriticalOp, const bool T } else { // must be an instruction address SMPInstr *CurrInst = this->GetInstFromAddr(CurrShadowAddr); - assert(NULL != CurrInst); + assert(nullptr != CurrInst); if (DEFAULT != CurrInst->GetDataFlowType()) { ValidShadowing = false; break; // cannot follow chain any higher, but previous chain info is still valid. @@ -17045,14 +17057,14 @@ bool SMPFunction::ComputeReturnTargets(bool FirstIteration) { if (0 <= CallBlockNum) { // CallAddr is in the current function. SMPInstr *CallInst = this->RPOBlocks[CallBlockNum]->FindInstr(CallAddr); - assert(NULL != CallInst); + assert(nullptr != CallInst); if (CallInst->IsJumpOrBranchInstr()) { continue; // internal jump or branch recursion; no return points } } // Get Func info of the caller. STARS_Function_t *FuncInfo = SMP_get_func(CallAddr); - if (NULL == FuncInfo) { + if (nullptr == FuncInfo) { SMP_msg("SERIOUS WARNING: ComputeReturnTargets: Call location %llx not in a function.\n", (unsigned long long) CallAddr); this->SetIsCalledFromOrphanedCode(); @@ -17359,13 +17371,13 @@ void SMPFunction::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { // Free memory for the memory-constrained reduced analysis case. for (InstIter = this->Instrs.begin(); InstIter != this->Instrs.end(); ++InstIter) { SMPInstr *CurrInst = (*InstIter); - if (NULL != CurrInst) delete CurrInst; + if (nullptr != CurrInst) delete CurrInst; } list<SMPBasicBlock *>::iterator BlockIter; for (BlockIter = this->Blocks.begin(); BlockIter != this->Blocks.end(); ++BlockIter) { SMPBasicBlock *CurrBlock = (*BlockIter); - if (NULL != CurrBlock) delete CurrBlock; + if (nullptr != CurrBlock) delete CurrBlock; } this->Instrs.clear(); @@ -17775,7 +17787,7 @@ bool SMPFunction::IsDefUsedInUnsafeMemWrite(STARSOpndTypePtr DefOp, int DefSSANu if (InsertResult.second) { // not previously in the AlreadySearchedSet // Find DefBlock and get the recursion started. SMPBasicBlock *DefBlock = this->GetBlockFromInstAddr(DefAddr); - assert(NULL != DefBlock); + assert(nullptr != DefBlock); this->ResetProcessedBlocks(); FoundMemWriteUse = DefBlock->IsDefUsedInUnsafeMemWrite(DefWorkList, DefOp, DefSSANum, DefAddr); } @@ -17840,7 +17852,7 @@ bool SMPFunction::IsAddressRegSafe(const STARSOpndTypePtr &UseOp, STARS_ea_t Use } else if (!(PhiDef || BadDefAddr || LiveIntoBlock)) { SMPInstr *DefInst = this->GetInstFromAddr(DefAddr); - assert(NULL != DefInst); + assert(nullptr != DefInst); bool StackPtrCopy = DefInst->MDIsStackPointerCopy(this->UsesFramePointer()); if (StackPtrCopy) { // Safe unless we have "lea reg,[esp+ecx]" so search for index reg @@ -17907,10 +17919,10 @@ void SMPFunction::MarkFunctionSafe() { } STARS_Function_t *FuncPtr = SMP_get_func(this->GetStartAddr()); - if (NULL == FuncPtr) { + if (nullptr == FuncPtr) { SMP_msg("FATAL ERROR in SMPFunction::MarkFunctionSafe; no func ptr\n"); } - assert(NULL != FuncPtr); + assert(nullptr != FuncPtr); bool TargetSuccess = FuncPtr->AnalyzeInstAsCallTarget(this, IsIndirectCallTarget, IsTailCallTarget); STARS_ea_t FirstAddr = this->GetFirstFuncAddr(); @@ -20518,9 +20530,9 @@ void SMPFunction::EmitSPARKSavedArgs(FILE *BodyFile) const { // Emit loop function args, as Signature to HeaderFile or proc call to BodyFile. void SMPFunction::EmitSPARKArgs(FILE *BodyFile, FILE *HeaderFile, bool Signature, size_t LoopIndex) const { if (Signature) - assert(NULL != HeaderFile); + assert(nullptr != HeaderFile); else - assert(NULL != BodyFile); + assert(nullptr != BodyFile); char HexAddr[12]; SMP_snprintf(HexAddr, 11, "_%x", this->GetFirstFuncAddr()); @@ -20622,7 +20634,7 @@ string SMPFunction::EmitSPARKProcForLoopHeaderBlock(int LoopIndex, int HeaderBlo if (HasArgs) { SMP_fprintf(BodyFile, "procedure %s(", ProcName.c_str()); // Make EmitSPARKArgs write the signature to the BodyFile, not HeaderFile. - this->EmitSPARKArgs(NULL, BodyFile, true, LoopNum); + this->EmitSPARKArgs(nullptr, BodyFile, true, LoopNum); SMP_fprintf(BodyFile, ")\nis\n"); } else { @@ -20655,7 +20667,7 @@ string SMPFunction::EmitSPARKProcForLoopHeaderBlock(int LoopIndex, int HeaderBlo this->EmitAnalysisProblemWarnings(HeaderFile, LoopIndex); if (HasArgs) { SMP_fprintf(HeaderFile, "procedure %s(", ProcName.c_str()); - this->EmitSPARKArgs(NULL, HeaderFile, true, LoopNum); + this->EmitSPARKArgs(nullptr, HeaderFile, true, LoopNum); SMP_fprintf(HeaderFile, ") with\n"); } else { @@ -21353,7 +21365,7 @@ void SMPFunction::EmitSPARKAdaForBlock(int CurrBlockNum, int FollowBlockNum, FIL size_t NumSuccessors = CurrBlock->GetNumSuccessors(); if (1 == NumSuccessors) { SMPBasicBlock *FallThroughSucc = (*(CurrBlock->GetFirstSucc())); - assert(NULL != FallThroughSucc); + assert(nullptr != FallThroughSucc); ResumeBlockNum = FallThroughSucc->GetNumber(); } else { @@ -21529,7 +21541,7 @@ void SMPFunction::EmitSPARKAdaForLoop(int HeaderBlockNum, int FollowBlockNum, FI size_t NumSuccessors = CurrBlock->GetNumSuccessors(); if (1 == NumSuccessors) { SMPBasicBlock *FallThroughSucc = (*(CurrBlock->GetFirstSucc())); - assert(NULL != FallThroughSucc); + assert(nullptr != FallThroughSucc); ResumeBlockNum = FallThroughSucc->GetNumber(); } else { @@ -21562,7 +21574,7 @@ void SMPFunction::EmitSPARKAdaForSwitch(int HeaderBlockNum, int FollowBlockNum, SwitchIndex = this->FindSwitchIndexForDefaultCaseAddr(DefaultCaseAddr); // Switch the HeaderBlock to the INDIR_JUMP block. HeaderBlock = this->GetBlockByNum(this->SwitchInfoArray[SwitchIndex].IndirJumpBlockNum); - assert(NULL != HeaderBlock); + assert(nullptr != HeaderBlock); LastInst = (*(--(HeaderBlock->GetLastInst()))); } else { @@ -21698,9 +21710,9 @@ void SMPFunction::EmitSPARKAdaForConditional(int HeaderBlockNum, int FollowBlock // Find the fall-through and non-fall-through block numbers. if (ShortCircuitCase) { STARSCFGBlock *HeaderCFGBlock = this->ShadowCFGBlocks[HeaderBlockNum]; - assert(NULL != HeaderCFGBlock); + assert(nullptr != HeaderCFGBlock); STARSCondExpr *HeaderExpr = HeaderCFGBlock->GetExpr(); - assert(NULL != HeaderExpr); + assert(nullptr != HeaderExpr); FallThroughBlockNum = HeaderExpr->GetFallThroughBlockNum(); DistantBlockNum = HeaderExpr->GetNonFallThroughBlockNum(); IfThenCase = (DistantBlockNum == FollowBlockNum); // treat ShortCircuitCase as IfThenCase from now on @@ -21785,7 +21797,7 @@ void SMPFunction::EmitSPARKAdaLoopCall(STARS_ea_t LoopAddr, size_t LoopIndex, FI PrintSPARKIndentTabs(SPARKBodyFile); if (this->LoopMemRangeInArgRegsBitmap[LoopIndex].any()) { SMP_fprintf(SPARKBodyFile, "%s(", ProcName.c_str()); - this->EmitSPARKArgs(SPARKBodyFile, NULL, false, LoopIndex); + this->EmitSPARKArgs(SPARKBodyFile, nullptr, false, LoopIndex); SMP_fprintf(SPARKBodyFile, ");\n"); } else { diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp index df8331ba816771f99e64b913b120a03c32adb777..a10ed420bc9dfe19cc17f18a43c3c95b49bddfc6 100644 --- a/src/base/SMPInstr.cpp +++ b/src/base/SMPInstr.cpp @@ -1216,7 +1216,7 @@ void SMPGuard::Dump(void) const { // ***************************************************************** // Constructors SMPRegTransfer::SMPRegTransfer(void) { - this->Guard = NULL; + this->Guard = nullptr; this->LeftOperand = nullptr; this->RightOperand = nullptr; this->RTop.oper = SMP_NULL_OPERATOR; @@ -1224,8 +1224,8 @@ SMPRegTransfer::SMPRegTransfer(void) { #if SMP_TRACK_NONSPEC_OPER_TYPE this->RTop.NonSpeculativeType = UNINIT; #endif - this->RightRT = NULL; - this->ParentInst = NULL; + this->RightRT = nullptr; + this->ParentInst = nullptr; this->booleans1 = 0; return; } @@ -1235,9 +1235,9 @@ SMPRegTransfer::~SMPRegTransfer() { #if 0 SMP_msg("Destroying SMPRegTransfer.\n"); #endif - if (NULL != this->RightRT) + if (nullptr != this->RightRT) delete this->RightRT; - if (NULL != this->Guard) + if (nullptr != this->Guard) delete this->Guard; return; } @@ -1577,7 +1577,7 @@ struct STARS_SCCP_Const_Struct SMPRegTransfer::SCCPEvaluateRTLConsts(list<pair<i break; // Only looking to update registers now } bool NewValueAvailable; - if (NULL != this->GetGuard()) { // TODO: Evaluate guard expressions. + if (nullptr != this->GetGuard()) { // TODO: Evaluate guard expressions. ReturnConstStruct.ConstType = STARS_CONST_BOTTOM; // Don't know value until we can evaluate guards } else if (this->HasRightSubTree()) { @@ -1792,6 +1792,7 @@ size_t SMPRegTransfer::MDSignExtend64RightOpIfNeeded(void) { ExtendedRT->SetLeftOperand(this->RightOperand); ExtendedRT->SetRightOperand(this->ParentInst->MakeVoidOpnd()); ExtendedRT->SetParentInst(this->ParentInst); + this->SetRightOperand(this->ParentInst->MakeVoidOpnd()); // free shared_ptr this->SetRightTree(ExtendedRT); FinalByteWidth = 8; SMP_msg("INFO: Sign-extending right RTL operand to 64 bits at %llx\n", @@ -1807,7 +1808,7 @@ bool SMPRegTransfer::RightTreeNeedsWidthCast(FILE *OutFile, std::size_t LeftBitW if (!this->HasRightSubTree()) return false; SMPRegTransfer *RightRT = this->GetRightTree(); - assert(NULL != RightRT); + assert(nullptr != RightRT); // Initial cases: zero-extension and sign-extension; add more cases as required if (SMP_ZERO_EXTEND == RightRT->GetOperator()) { const STARSOpndTypePtr RightLeftOp = RightRT->GetConstLeftOperandNoNorm(); @@ -1850,7 +1851,7 @@ bool SMPRegTransfer::IsSPARKAdaNop(void) const { // Debug print void SMPRegTransfer::Dump(void) const { - if (NULL != this->Guard) + if (nullptr != this->Guard) this->Guard->Dump(); // Left operand if ((nullptr != this->LeftOperand) && (! this->LeftOperand->IsVoidOp())) @@ -2045,7 +2046,7 @@ SMPRTL::~SMPRTL() { // Get methods SMPRegTransfer *SMPRTL::GetRT(std::size_t index) const { if (index > this->RTCount) - return NULL; + return nullptr; else return this->RTvector[index]; } @@ -4860,7 +4861,7 @@ bool STARSExpression::UpdateImmedValue(STARS_uval_t OldValue, STARS_uval_t NewVa // Constructor for instruction. SMPInstr::SMPInstr(STARS_ea_t addr) : STARS_ID(addr) { this->STARS_ID.SetFileNum(global_STARS_program->GetCurrentFileNum()); - this->BasicBlock = NULL; + this->BasicBlock = nullptr; #if 0 // get these from STARSInstrPtr now this->SMPcmd.size = 0; this->features = 0; @@ -4950,7 +4951,7 @@ bool SMPInstr::IsBasicBlockTerminator() const { STARS_ea_t CallTarget = this->GetCallTarget(); if (STARS_BADADDR != CallTarget) { STARS_Function_t *CalleeFunc = global_stars_interface->get_func(CallTarget); - if (NULL != CalleeFunc) { + if (nullptr != CalleeFunc) { // Terminates basic block if it is a call to a non-returning func (e.g. abort(), exit()) return (!(CalleeFunc->HasReturnPoints())); } @@ -5058,7 +5059,7 @@ STARSOpndTypePtr SMPInstr::MDGetMemUseOp(void) const { // return original Lea instruction [pseudo-]memory operand. STARSOpndTypePtr SMPInstr::GetLeaMemUseOp(void) const { - if ((!this->MDIsLoadEffectiveAddressInstr()) || (this->BasicBlock == NULL)) { + if ((!this->MDIsLoadEffectiveAddressInstr()) || (this->BasicBlock == nullptr)) { return nullptr; } else { @@ -5253,7 +5254,7 @@ SMPoperator SMPInstr::GetCondBranchOperator(void) const { SMPoperator GuardOperator = SMP_NULL_OPERATOR; if (this->GetDataFlowType() == COND_BRANCH) { SMPGuard *GuardRT = this->RTL.GetRT(0)->GetGuard(); - assert(NULL != GuardRT); + assert(nullptr != GuardRT); GuardOperator = GuardRT->GetOperator(); } @@ -5323,7 +5324,7 @@ void SMPInstr::AnalyzeIndirectRefs(bool UseFP) { STARSOpndTypePtr rhs = nullptr; STARS_ea_t GlobalAddr = this->GetMemDef()->GetAddr(); SMPRegTransfer *CurrRT = this->RTL.GetRT(0); - if ((NULL != CurrRT) && (this->RTL.GetCount() == 1)) { + if ((nullptr != CurrRT) && (this->RTL.GetCount() == 1)) { bool Simple = ((!CurrRT->HasRightSubTree()) || this->IsRegUpperBitsClearIdiom()); if (Simple && (SMP_ASSIGN == CurrRT->GetOperator())) { bool SimpleCopyRTL = (DEFAULT == this->GetDataFlowType()); @@ -5352,7 +5353,7 @@ set<DefOrUse, LessDefUse>::iterator SMPInstr::GetPointerAddressReg(const STARSOp STARS_ea_t displacement; set<DefOrUse, LessDefUse>::iterator PtrIter; - if ((NULL == this->BasicBlock) || (NULL == this->BasicBlock->GetFunc())) { + if ((nullptr == this->BasicBlock) || (nullptr == this->BasicBlock->GetFunc())) { SMP_msg("ERROR: NULL member pointers in SMPInstr::GetPointerAddressReg() at %llx \n", (unsigned long long) this->GetAddr()); return this->GetLastUse(); @@ -5511,7 +5512,7 @@ void SMPInstr::Dump(void) const { } #if STARS_DUMP_FG_INFO SMP_msg("USEs: "); - if (NULL == this->GetBlock()) { // during early improvement of disasm + if (nullptr == this->GetBlock()) { // during early improvement of disasm this->Uses.Dump(); SMP_msg("DEFs: "); this->Defs.Dump(); @@ -6905,7 +6906,7 @@ void SMPInstr::EmitSPARKAda(FILE *OutFile) { else if ((SHORT_CIRCUIT_BRANCH == FuncControlFlowType) || (SHORT_CIRCUIT_LOOP_EXIT == FuncControlFlowType)) { // Multiple short circuit condition branches have been coalesced together. STARSCFGBlock *CurrCFGBlock = this->GetBlock()->GetFunc()->GetCFGBlockByNum((size_t) this->GetBlock()->GetNumber()); - assert(NULL != CurrCFGBlock); + assert(nullptr != CurrCFGBlock); if (!CurrCFGBlock->IsCoalesced()) { // must be header block of compound conditional; header block is where we emit output PrintSPARKIndentTabs(OutFile); if (SHORT_CIRCUIT_BRANCH == FuncControlFlowType) { @@ -7562,7 +7563,7 @@ bool SMPInstr::SubtractsFromItself(void) { std::size_t RTLCount = this->RTL.GetCount(); for (std::size_t index = 0; index < RTLCount; ++index) { SMPRegTransfer *CurrRT = this->RTL.GetRT(index); - if ((CurrRT != NULL) && (CurrRT->HasRightSubTree())) { + if ((CurrRT != nullptr) && (CurrRT->HasRightSubTree())) { CurrRT = CurrRT->GetRightTree(); SMPoperator CurrOp = CurrRT->GetOperator(); if ((SMP_SUBTRACT_BORROW == CurrOp) || (SMP_SUBTRACT == CurrOp)) { @@ -7595,7 +7596,7 @@ bool SMPInstr::MDComparesImmedASCII(void) { bool ComparesToASCII = false; if (this->GetIDAOpcode() == STARS_NN_cmp) { SMPRegTransfer *CurrRT = this->RTL.GetRT(0); - if ((CurrRT != NULL) && (CurrRT->HasRightSubTree())) { + if ((CurrRT != nullptr) && (CurrRT->HasRightSubTree())) { CurrRT = CurrRT->GetRightTree(); if (!(CurrRT->HasRightSubTree())) { STARSOpndTypePtr LeftOp = CurrRT->GetLeftOperand(); @@ -8827,7 +8828,7 @@ bool SMPInstr::IsBranchToFarChunk(void) { // instr branches or jumps to another function bool SMPInstr::IsBranchToOtherFunc(void) { - bool Safe = (NULL != this->GetBlock()); + bool Safe = (nullptr != this->GetBlock()); STARS_ea_t FarTarget = this->GetJumpTarget(); return (Safe && (STARS_BADADDR != FarTarget) && (!this->GetBlock()->GetFunc()->IsInstIDInFunc(FarTarget))); } @@ -9056,7 +9057,7 @@ void SMPInstr::Analyze(void) { if (this->GetDataFlowType() == INDIR_CALL) { if (this->MDIsSystemCall()) { this->CallTarget = STARS_BADADDR; - if (NULL != this->GetBlock()) { + if (nullptr != this->GetBlock()) { this->GetBlock()->GetFunc()->SetHasSystemCalls(); } } @@ -9843,7 +9844,7 @@ void SMPInstr::BuildSMPDefUseLists(void) { } // end for (OpNum = 0; ...) SMPRegTransfer *CurrRT = this->RTL.GetRT(0); - if ((NULL != CurrRT) && CurrRT->IsSubregMove()) { // we built a subreg := imm or subreg := subreg RT + if ((nullptr != CurrRT) && CurrRT->IsSubregMove()) { // we built a subreg := imm or subreg := subreg RT // Upper bits of full reg are USEd, unchanged. this->Uses.SetRef(CurrRT->GetLeftOperand(), NUMERIC); // GetLeftOperand() normalizes to full reg } @@ -9947,7 +9948,7 @@ void SMPInstr::SetTailCall(void) { // record original Lea instruction [pseudo-]memory operand. void SMPInstr::SetLeaMemUseOp(STARSOpndTypePtr NewLeaOperand) { - if (NULL != this->BasicBlock) { + if (nullptr != this->BasicBlock) { this->GetBlock()->GetFunc()->AddLeaOperand(this->GetAddr(), NewLeaOperand); } return; @@ -10016,8 +10017,8 @@ void SMPInstr::MDFixupDefUseLists(void) { #if SMP_BASEREG_POINTER_TYPE // Some instructions are analyzed outside of any function or block when fixing up - // the IDB, so we have to assume the block and func pointers might be NULL. - if ((NULL != this->BasicBlock) && (NULL != this->BasicBlock->GetFunc())) + // the IDB, so we have to assume the block and func pointers might be nullptr. + if ((nullptr != this->BasicBlock) && (nullptr != this->BasicBlock->GetFunc())) UseFP = this->BasicBlock->GetFunc()->UsesFramePointer(); #endif @@ -10143,7 +10144,7 @@ void SMPInstr::MDFixupDefUseLists(void) { } // Because we don't know what is going on with callees in external modules, we have to be conservative and // assume that callee-saved registers might be LiveIn to them. - if (NULL != this->GetBlock()) { + if (nullptr != this->GetBlock()) { STARS_ea_t CalledFuncAddr = this->GetCallTarget(); if ((STARS_BADADDR == CalledFuncAddr) && BranchOutsideFunc) { CalledFuncAddr = this->GetJumpTarget(); @@ -10351,7 +10352,7 @@ bool SMPInstr::MDFixupCallDefUseLists(void) { #endif if ((this->type == CALL) || (this->type == INDIR_CALL) || this->IsTailCall()) { // We want to add the caller-saved registers to the USEs and DEFs lists - if ((NULL != this->GetBlock()) && (!this->IsInterruptCall())) { + if ((nullptr != this->GetBlock()) && (!this->IsInterruptCall())) { STARS_ea_t CalledFuncAddr = this->GetCallTarget(); SMPFunction *CalleeFunc = this->GetBlock()->GetFunc()->GetProg()->FindFunction(CalledFuncAddr); if ((nullptr != CalleeFunc) && (!CalleeFunc->IsLinkerStub())) { @@ -10744,7 +10745,7 @@ bool SMPInstr::IsOpSourceSmallPositiveConstant(const STARSOpndTypePtr &UseOp, in std::size_t BlockNum = STARS_GetBlockNumFromPseudoID(UseDefAddr); assert(!LocalName); SMPBasicBlock *PhiDefBlock = this->GetBlock()->GetFunc()->GetBlockByNum(BlockNum); - assert(NULL != PhiDefBlock); + assert(nullptr != PhiDefBlock); if (!PhiDefBlock->IsProcessed()) { // Prevent infinite recursion set<SMPPhiFunction, LessPhi>::iterator DefPhiIter = PhiDefBlock->FindPhi(UseOp); assert(DefPhiIter != PhiDefBlock->GetLastPhi()); @@ -10822,7 +10823,7 @@ bool SMPInstr::IsOpSourceBitwiseNot(const STARSOpndTypePtr &UseOp, int UseSSANum std::size_t BlockNum = STARS_GetBlockNumFromPseudoID(UseDefAddr); assert(!LocalName); SMPBasicBlock *PhiDefBlock = this->GetBlock()->GetFunc()->GetBlockByNum(BlockNum); - assert(NULL != PhiDefBlock); + assert(nullptr != PhiDefBlock); if (!PhiDefBlock->IsProcessed()) { // Prevent infinite recursion set<SMPPhiFunction, LessPhi>::iterator DefPhiIter = PhiDefBlock->FindPhi(UseOp); assert(DefPhiIter != PhiDefBlock->GetLastPhi()); @@ -10902,7 +10903,7 @@ bool SMPInstr::IsOpSourceConditionCode(const STARSOpndTypePtr &UseOp, int UseSSA std::size_t BlockNum = STARS_GetBlockNumFromPseudoID(UseDefAddr); assert(!LocalName); SMPBasicBlock *PhiDefBlock = this->GetBlock()->GetFunc()->GetBlockByNum(BlockNum); - assert(NULL != PhiDefBlock); + assert(nullptr != PhiDefBlock); if (!PhiDefBlock->IsProcessed()) { // Prevent infinite recursion set<SMPPhiFunction, LessPhi>::iterator DefPhiIter = PhiDefBlock->FindPhi(UseOp); assert(DefPhiIter != PhiDefBlock->GetLastPhi()); @@ -10982,7 +10983,7 @@ bool SMPInstr::IsOpSourceLeftShift(const STARSOpndTypePtr &UseOp, int UseSSANum, std::size_t BlockNum = STARS_GetBlockNumFromPseudoID(UseDefAddr); assert(!LocalName); SMPBasicBlock *PhiDefBlock = this->GetBlock()->GetFunc()->GetBlockByNum(BlockNum); - assert(NULL != PhiDefBlock); + assert(nullptr != PhiDefBlock); if (!PhiDefBlock->IsProcessed()) { // Prevent infinite recursion set<SMPPhiFunction, LessPhi>::iterator DefPhiIter = PhiDefBlock->FindPhi(UseOp); assert(DefPhiIter != PhiDefBlock->GetLastPhi()); @@ -11064,7 +11065,7 @@ bool SMPInstr::IsOpSourceZeroExtendedMove(const STARSOpndTypePtr &UseOp, int Use std::size_t BlockNum = STARS_GetBlockNumFromPseudoID(UseDefAddr); assert(!LocalName); SMPBasicBlock *PhiDefBlock = this->GetBlock()->GetFunc()->GetBlockByNum(BlockNum); - assert(NULL != PhiDefBlock); + assert(nullptr != PhiDefBlock); if (!PhiDefBlock->IsProcessed()) { // Prevent infinite recursion set<SMPPhiFunction, LessPhi>::iterator DefPhiIter = PhiDefBlock->FindPhi(UseOp); assert(DefPhiIter != PhiDefBlock->GetLastPhi()); @@ -11162,7 +11163,7 @@ bool SMPInstr::IsOpSourceZeroExtendedMoveShiftRightOrConditionCode(const STARSOp std::size_t BlockNum = STARS_GetBlockNumFromPseudoID(UseDefAddr); assert(!LocalName); SMPBasicBlock *PhiDefBlock = this->GetBlock()->GetFunc()->GetBlockByNum(BlockNum); - assert(NULL != PhiDefBlock); + assert(nullptr != PhiDefBlock); if (!PhiDefBlock->IsProcessed()) { // Prevent infinite recursion set<SMPPhiFunction, LessPhi>::iterator DefPhiIter = PhiDefBlock->FindPhi(UseOp); assert(DefPhiIter != PhiDefBlock->GetLastPhi()); @@ -11264,7 +11265,7 @@ bool SMPInstr::IsOpSourceSpecial(const STARSOpndTypePtr &UseOp, int UseSSANum, b std::size_t BlockNum = STARS_GetBlockNumFromPseudoID(UseDefAddr); assert(!LocalName); SMPBasicBlock *PhiDefBlock = this->GetBlock()->GetFunc()->GetBlockByNum(BlockNum); - assert(NULL != PhiDefBlock); + assert(nullptr != PhiDefBlock); if (!PhiDefBlock->IsProcessed()) { // Prevent infinite recursion set<SMPPhiFunction, LessPhi>::iterator DefPhiIter = PhiDefBlock->FindPhi(UseOp); assert(DefPhiIter != PhiDefBlock->GetLastPhi()); @@ -11381,7 +11382,7 @@ bool SMPInstr::IsOpSourceByteSwap(const STARSOpndTypePtr &UseOp, int UseSSANum, std::size_t BlockNum = STARS_GetBlockNumFromPseudoID(UseDefAddr); assert(!LocalName); SMPBasicBlock *PhiDefBlock = this->GetBlock()->GetFunc()->GetBlockByNum(BlockNum); - assert(NULL != PhiDefBlock); + assert(nullptr != PhiDefBlock); if (!PhiDefBlock->IsProcessed()) { // Prevent infinite recursion set<SMPPhiFunction, LessPhi>::iterator DefPhiIter = PhiDefBlock->FindPhi(UseOp); assert(DefPhiIter != PhiDefBlock->GetLastPhi()); @@ -11541,7 +11542,7 @@ bool SMPInstr::ShiftMakesUpperBitsLower(std::size_t HalfBitWidth, bool MustBeHal if (!MustBeHalfRegWidth || (MD_NORMAL_MACHINE_BITWIDTH == (HalfBitWidth * 2))) { SMPRegTransfer *CurrRT = this->RTL.GetRT(0); - if ((NULL != CurrRT) && (CurrRT->HasRightSubTree())) { + if ((nullptr != CurrRT) && (CurrRT->HasRightSubTree())) { CurrRT = CurrRT->GetRightTree(); SMPoperator CurrOper = CurrRT->GetOperator(); bool LeftRotate = (SMP_ROTATE_LEFT == CurrOper); @@ -11768,7 +11769,7 @@ bool SMPInstr::MDIsSystemCall(void) { if (!SystemCall && this->IsInterruptCall()) { // If interrupt call is int 0x80 then it is a system call SMPRegTransfer *CurrRT = this->RTL.GetRT(0); - assert(NULL != CurrRT); + assert(nullptr != CurrRT); if (!CurrRT->HasRightSubTree()) { if (CurrRT->GetConstRightOperandNoNorm()->IsImmedOp()) { SystemCall = (0x80 == CurrRT->GetConstRightOperandNoNorm()->GetImmedValue()); @@ -11888,7 +11889,7 @@ bool SMPInstr::MDIsSimpleAssignment(bool &ValueFound, STARS_uval_t &ConstValue) bool SMPInstr::IsSimpleCopy(STARSOpndTypePtr &rhs) const { bool SimpleCopyRTL = false; SMPRegTransfer *CurrRT = this->RTL.GetRT(0); - if ((NULL != CurrRT) && (this->RTL.GetCount() == 1) && (NULL == CurrRT->GetGuard())) { // skip conditional moves + if ((nullptr != CurrRT) && (this->RTL.GetCount() == 1) && (nullptr == CurrRT->GetGuard())) { // skip conditional moves bool Simple = ((!CurrRT->HasRightSubTree()) || this->IsRegUpperBitsClearIdiom()); if (Simple && (SMP_ASSIGN == CurrRT->GetOperator())) { SimpleCopyRTL = (DEFAULT == this->GetDataFlowType()); @@ -11913,7 +11914,7 @@ bool SMPInstr::IsSimpleCopy(STARSOpndTypePtr &rhs) const { bool SMPInstr::IsSimpleCopyNoNorm(STARSOpndTypePtr &rhs) const { bool SimpleCopyRTL = false; SMPRegTransfer *CurrRT = this->RTL.GetRT(0); - if ((NULL != CurrRT) && (this->RTL.GetCount() == 1) && (NULL == CurrRT->GetGuard())) { // skip conditional moves + if ((nullptr != CurrRT) && (this->RTL.GetCount() == 1) && (nullptr == CurrRT->GetGuard())) { // skip conditional moves if (!CurrRT->HasRightSubTree() && (SMP_ASSIGN == CurrRT->GetOperator())) { SimpleCopyRTL = (DEFAULT == this->GetDataFlowType()); if (SimpleCopyRTL) @@ -11928,7 +11929,7 @@ bool SMPInstr::IsSimpleCopyNoNorm(STARSOpndTypePtr &rhs) const { bool SMPInstr::IsSimpleOrExtendedCopy(STARSOpndTypePtr &rhs) const { bool SimpleCopyRTL = false; SMPRegTransfer *CurrRT = this->RTL.GetRT(0); - if ((NULL != CurrRT) && (this->RTL.GetCount() == 1) && (NULL == CurrRT->GetGuard())) { // skip conditional moves + if ((nullptr != CurrRT) && (this->RTL.GetCount() == 1) && (nullptr == CurrRT->GetGuard())) { // skip conditional moves bool Simple = ((!CurrRT->HasRightSubTree()) || this->IsRegUpperBitsClearIdiom()); if (Simple && (SMP_ASSIGN == CurrRT->GetOperator())) { SimpleCopyRTL = (DEFAULT == this->GetDataFlowType()); @@ -12195,7 +12196,7 @@ void SMPInstr::MDSetWidthSignInfo(bool UseFP) { string FuncName = this->GetTrimmedCalledFunctionName(); // See if we are throwing an exception. - if (0 == strcmp("cxa_throw", FuncName.c_str()) && (NULL != this->GetBlock())) { + if (0 == strcmp("cxa_throw", FuncName.c_str()) && (nullptr != this->GetBlock())) { this->GetBlock()->GetFunc()->GetProg()->SetProgramThrowsExceptions(); } @@ -12909,7 +12910,7 @@ void SMPInstr::SCCPEvaluateCondBranch(enum STARSBranchConst &BranchEval) { // We evaluate the Guard RT to see if it is always true or always false. SMPRegTransfer *CurrRT = this->RTL.GetRT(0); SMPGuard *BranchCondition = CurrRT->GetGuard(); - assert(NULL != BranchCondition); + assert(nullptr != BranchCondition); STARSOpndTypePtr LeftOp = CloneIfSubwordReg(BranchCondition->GetConstLeftOperand()); CanonicalizeOpnd(LeftOp); STARSOpndTypePtr RightOp = CloneIfSubwordReg(BranchCondition->GetConstRightOperand()); @@ -13164,7 +13165,7 @@ void SMPInstr::SCCPFetchConstUseValue(const STARSOpndTypePtr &UseOp, STARS_SCCP_ #endif if (GoodAddr) { STARS_Segment_t *MemSeg = global_stars_interface->getseg(MemAddr); - if (NULL != MemSeg) { + if (nullptr != MemSeg) { if (MemSeg->IsWriteableSegment()) { ConstStruct.ConstType = STARS_CONST_BOTTOM; // cannot know writable memory value without alias analysis, etc. } @@ -13645,7 +13646,7 @@ bool SMPInstr::InferTypes(void) { } ++CallUseIter; } - } // end if (NULL != CalleeFunc) + } // end if (nullptr != CalleeFunc) } // end if (CallInst and CODEPTR USE) ++CurrUse; } // end while all USEs @@ -15908,15 +15909,15 @@ void SMPInstr::EmitFastReturnStatus(unsigned short FastReturnStatus) { void SMPInstr::EmitCallReturnStatus(SMPProgram *CurrProg) { SMPitype FlowType = this->GetDataFlowType(); char *disasm = DisAsmText.GetDisAsm(this->GetAddr()); - bool ValidFunc = ((NULL != this->GetBlock()) && (NULL != this->GetBlock()->GetFunc())); + bool ValidFunc = ((nullptr != this->GetBlock()) && (nullptr != this->GetBlock()->GetFunc())); if (CALL == FlowType) { STARS_ea_t CalleeAddr = this->GetCallTarget(); - SMPFunction *CalleeFunc = NULL; + SMPFunction *CalleeFunc = nullptr; if (ValidFunc) { CalleeFunc = this->GetBlock()->GetFunc()->GetProg()->FindFunction(CalleeAddr); } - else if (NULL != CurrProg) { + else if (nullptr != CurrProg) { CalleeFunc = CurrProg->FindFunction(CalleeAddr); } if (nullptr == CalleeFunc) { @@ -15948,11 +15949,11 @@ void SMPInstr::EmitCallReturnStatus(SMPProgram *CurrProg) { this->EmitFastReturnStatus(DummyReturnStatus); } else { - SMPFunction *CalleeFunc = NULL; + SMPFunction *CalleeFunc = nullptr; if (ValidFunc) { CalleeFunc = this->GetBlock()->GetFunc()->GetProg()->FindFunction(CalleeAddr); } - else if (NULL != CurrProg) { + else if (nullptr != CurrProg) { CalleeFunc = CurrProg->FindFunction(CalleeAddr); } if (nullptr == CalleeFunc) { @@ -16025,7 +16026,7 @@ void SMPInstr::EmitAnnotations(bool UseFP, bool AllocSeen, bool NeedsFrame, FILE bool CallInst = ((CALL == DataFlowType) || this->IsTailCall() || this->IsCondTailCall()); #endif bool IndirJumpInst = (INDIR_JUMP == DataFlowType); - bool IndirJumpAnalyzed = IndirJumpInst && (NULL != this->GetBlock()) && (!this->GetBlock()->GetFunc()->HasUnresolvedIndirectJumps()); + bool IndirJumpAnalyzed = IndirJumpInst && (nullptr != this->GetBlock()) && (!this->GetBlock()->GetFunc()->HasUnresolvedIndirectJumps()); bool MemDest = this->HasDestMemoryOperand(); bool MemSrc = this->HasSourceMemoryOperand(); bool SecondSrcOperandImmNum = this->IsSecondSrcOperandNumeric(); // assumes 2nd source is Imm or not-numeric?! @@ -16033,8 +16034,8 @@ void SMPInstr::EmitAnnotations(bool UseFP, bool AllocSeen, bool NeedsFrame, FILE char *disasm = DisAsmText.GetDisAsm(this->GetAddr()); #if SMP_CHILDACCESS_ALL_CODE - bool OrphanCode = (NULL == this->BasicBlock); - ProfilerInformation *ProfInfo = NULL; + bool OrphanCode = (nullptr == this->BasicBlock); + ProfilerInformation *ProfInfo = nullptr; if (!OrphanCode) ProfInfo = this->BasicBlock->GetFunc()->GetProg()->GetProfInfo(); #endif @@ -16077,7 +16078,7 @@ void SMPInstr::EmitAnnotations(bool UseFP, bool AllocSeen, bool NeedsFrame, FILE ZST_SysCallType FuncCallType = global_STARS_program->GetCallTypeFromFuncName(FuncName); ZST_Policy FuncCallPolicy = global_STARS_program->GetPolicyFromCallType(FuncCallType); if (ZST_DISALLOW == FuncCallPolicy) { - if ((NULL != this->GetBlock()) && (NULL != this->GetBlock()->GetFunc())) { + if ((nullptr != this->GetBlock()) && (nullptr != this->GetBlock()->GetFunc())) { SMP_fprintf(global_STARS_program->GetAlarmFile(), "ALARM: Call to %s will be disallowed at %llx in %s\n", FuncName.c_str(), (unsigned long long) this->GetAddr(), this->GetBlock()->GetFunc()->GetFuncName()); } @@ -16696,7 +16697,7 @@ void SMPInstr::EmitDeadRegsAnnotation(FILE *AnnotFile, bool IndirJumpAnalyzed, c return; // reached the debugging limit } - if (this->DeadRegsBitmap.any() && (NULL != this->GetBlock()) && (!this->GetBlock()->GetFunc()->IsMultiEntry())) { + if (this->DeadRegsBitmap.any() && (nullptr != this->GetBlock()) && (!this->GetBlock()->GetFunc()->IsMultiEntry())) { // See if we are debugging DEADREGS annotations using a limit on which regs to use. bitset<1 + STARS_MAX_REGNUM_FOR_BITSETS> TempBitset(this->DeadRegsBitmap); const bitset<1 + STARS_MAX_REGNUM_FOR_BITSETS> &DebugBitset = global_STARS_program->GetDeadregsBitset(); @@ -18565,7 +18566,7 @@ bool SMPInstr::BuildUnaryRTL(SMPoperator UnaryOp) { bool DestFound = false; bool WidthDoubler = this->MDDoublesWidth(); unsigned short opcode = this->GetIDAOpcode(); - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; STARSOpndTypePtr VoidOp = this->STARSInstPtr->MakeVoidOpnd(); STARSOpndTypePtr FPRegOp = this->STARSInstPtr->MakeFloatingPointRegOpnd(MD_FIRST_FP_STACK_REG); @@ -18680,7 +18681,7 @@ bool SMPInstr::BuildUnaryTwoOperandRTL(SMPoperator UnaryOp) { bool DestFound = false; bool SrcFound = false; STARSOpndTypePtr DestOp = nullptr, SrcOp = nullptr; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; STARSOpndTypePtr VoidOp = this->STARSInstPtr->MakeVoidOpnd(); @@ -18916,7 +18917,7 @@ bool SMPInstr::BuildBinary3OpndRTL(SMPoperator BinaryOp) { bool Source2Found = false; bool MemSrc = this->HasSourceMemoryOperand(); bool MemDest = this->HasDestMemoryOperand(); - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; SMPRegTransfer *RightRT = new SMPRegTransfer; RightRT->SetParentInst(this); @@ -18976,8 +18977,8 @@ bool SMPInstr::BuildBinary3OpndRTL(SMPoperator BinaryOp) { } // end for (OpNum = 0; ...) if (!DestFound || !Source1Found || !Source2Found) { - assert(NULL != RightRT); - if (DestFound && (NULL != TempRT)) + assert(nullptr != RightRT); + if (DestFound && (nullptr != TempRT)) delete TempRT; else delete RightRT; @@ -19009,7 +19010,7 @@ bool SMPInstr::BuildMultAddOrSub4OpndRTL(SMPoperator BinaryOp1, SMPoperator Bina // RTL shape will be dest := (src3 SMP_ADD (src1 * src2)) or (src3 SMP_NEGATE_AND_ADD (src1 * src2)) // where the first operator is whatever is in BinaryOp2 and * is whatever is in BinaryOp1. // The SMP_NEGATE_AND_ADD is needed because the RTL shape must grow with right tree and no left trees. - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; SMPRegTransfer *RightRT = new SMPRegTransfer; SMPRegTransfer *RightRightRT = new SMPRegTransfer; RightRT->SetParentInst(this); @@ -19065,8 +19066,8 @@ bool SMPInstr::BuildMultAddOrSub4OpndRTL(SMPoperator BinaryOp1, SMPoperator Bina } // end for (OpNum = 0; ...) if (!DestFound || !Source1Found || !Source2Found || !Source3Found) { - assert(NULL != RightRT); - if (DestFound && (NULL != TempRT)) + assert(nullptr != RightRT); + if (DestFound && (nullptr != TempRT)) delete TempRT; else delete RightRT; @@ -19094,7 +19095,7 @@ bool SMPInstr::BuildGuardedSignalRTL(SMPoperator SignalOp) { std::size_t OpNum; bool Source1Found = false; bool Source2Found = false; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; SMPGuard *Guard1 = new SMPGuard; STARSOpndTypePtr VoidOp = this->STARSInstPtr->MakeVoidOpnd(); @@ -19137,7 +19138,7 @@ bool SMPInstr::BuildGuardedSignalRTL(SMPoperator SignalOp) { } // end for (OpNum = 0; ...) if (!Source1Found || !Source2Found) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL if (!Source1Found) { @@ -19175,7 +19176,7 @@ bool SMPInstr::BuildBinaryPlusImmedRTL(SMPoperator BinaryOp, SMPoperator ImmedOp bool ImmedFound = false; bool MemSrc = this->HasSourceMemoryOperand(); bool MemDest = this->HasDestMemoryOperand(); - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; SMPRegTransfer *RightRT = new SMPRegTransfer; SMPRegTransfer *ImmedRT = new SMPRegTransfer; RightRT->SetParentInst(this); @@ -19240,8 +19241,8 @@ bool SMPInstr::BuildBinaryPlusImmedRTL(SMPoperator BinaryOp, SMPoperator ImmedOp } // end for (OpNum = 0; ...) if (!DestFound || !SourceFound || !ImmedFound) { - assert(NULL != RightRT); - if (DestFound && (NULL != TempRT)) + assert(nullptr != RightRT); + if (DestFound && (nullptr != TempRT)) delete TempRT; else { delete RightRT; @@ -19284,7 +19285,7 @@ bool SMPInstr::BuildBinaryIgnoreImmedRTL(SMPoperator BinaryOp) { bool ECXDest = ((STARS_NN_pcmpestri == opcode) || (STARS_NN_pcmpistri == opcode)); bool XMM0Dest = ((STARS_NN_pcmpestrm == opcode) || (STARS_NN_pcmpistrm == opcode)); bool SrcIsReallyDest = (ECXDest || XMM0Dest); // Dest is implicit, so ASM only has source operand - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; SMPRegTransfer *RightRT = new SMPRegTransfer; RightRT->SetParentInst(this); @@ -19355,8 +19356,8 @@ bool SMPInstr::BuildBinaryIgnoreImmedRTL(SMPoperator BinaryOp) { } // end for (OpNum = 0; ...) if (!DestFound || !SourceFound || !ImmedFound) { - assert(NULL != RightRT); - if (DestFound && (NULL != TempRT)) + assert(nullptr != RightRT); + if (DestFound && (nullptr != TempRT)) delete TempRT; else delete RightRT; @@ -19391,7 +19392,7 @@ bool SMPInstr::BuildLeaRTL(void) { bool EIPRelativeAddr = false; STARSOpndTypePtr DefOp = nullptr; STARSOpndTypePtr UseOp = nullptr; - SMPRegTransfer *AssignRT = NULL; + SMPRegTransfer *AssignRT = nullptr; int BaseReg; int IndexReg; uint16_t ScaleFactor; @@ -19608,7 +19609,7 @@ bool SMPInstr::BuildDoubleShiftRTL(SMPoperator BinaryOp) { bool DestFound = false; bool SourceFound = false; bool CountFound = false; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; SMPRegTransfer *RightRT = new SMPRegTransfer; RightRT->SetParentInst(this); SMPRegTransfer *LowerRightRT = new SMPRegTransfer; @@ -19668,7 +19669,7 @@ bool SMPInstr::BuildDoubleShiftRTL(SMPoperator BinaryOp) { } // end for (OpNum = 0; ...) if (!DestFound || !SourceFound || !CountFound) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find double-shift operand at %llx for %s\n", @@ -19693,7 +19694,7 @@ bool SMPInstr::BuildMultiplyDivideRTL(SMPoperator BinaryOp) { bool DivisionCase = ((BinaryOp == SMP_S_DIVIDE) || (BinaryOp == SMP_U_DIVIDE)); bool ImplicitDEFs = false; bool InvisibleOperand = false; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; SMPRegTransfer *RightRT = new SMPRegTransfer; RightRT->SetParentInst(this); @@ -19764,8 +19765,8 @@ bool SMPInstr::BuildMultiplyDivideRTL(SMPoperator BinaryOp) { } // end for (OpNum = 0; ...) if (!FinishedOperands) { - assert(NULL != RightRT); - if (DestFound && (NULL != TempRT)) + assert(nullptr != RightRT); + if (DestFound && (nullptr != TempRT)) delete TempRT; else delete RightRT; @@ -19830,7 +19831,7 @@ bool SMPInstr::BuildBinaryPlusFlagsRTL(SMPoperator BinaryOp) { std::size_t OpNum; bool DestFound = false; bool SourceFound = false; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; STARSOpndTypePtr FlagsOp = this->STARSInstPtr->MakeRegOpnd(X86_FLAGS_REG); @@ -19911,9 +19912,9 @@ bool SMPInstr::BuildSetFlagIntoRegRTL(SMPoperator GuardOp, SMPoperator InvertedG } // end for (OpNum = 0; ...) if (!DestFound) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; - if (NULL != InvertedRT) + if (nullptr != InvertedRT) delete InvertedRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find SETcc destination operand at %llx for %s\n", @@ -20060,7 +20061,7 @@ bool SMPInstr::BuildUnary2OpndRTL(SMPoperator UnaryOp) { if (!DestFound || !SourceFound) { if (!DestFound) delete RightRT; // never linked in to TempRT - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find unary operand at %llx for %s at line %s:%d\n", @@ -20212,9 +20213,9 @@ bool SMPInstr::BuildLoopRTL(SMPoperator GuardOp) { } // end for (OpNum = 0; ...) if (!SourceFound) { - if (NULL != LoopRT) + if (nullptr != LoopRT) delete LoopRT; - if (NULL != DecCounterRT) + if (nullptr != DecCounterRT) delete DecCounterRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find loop operand at %llx for %s\n", @@ -20427,7 +20428,7 @@ bool SMPInstr::BuildMoveRTL(SMPoperator GuardOp) { } // end for (OpNum = 0; ...) if (!DestFound || !SourceFound) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find move operand at %llx for %s\n", @@ -20655,7 +20656,7 @@ bool SMPInstr::BuildCompareStringRTL(void) { } // end for (OpNum = 0; ...) if (!Src1Found || !Src2Found) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find CMPS operand at %llx for %s\n", @@ -20728,7 +20729,7 @@ bool SMPInstr::BuildExchangeRTL(void) { } // end for (OpNum = 0; ...) if (!Src1Found || !Src2Found) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find XCHG operand at %llx for %s\n", @@ -20792,7 +20793,7 @@ bool SMPInstr::BuildExchangeAddRTL(void) { } // end for (OpNum = 0; ...) if (!Src1Found || !Src2Found) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find XADD operand at %llx for %s\n", @@ -20856,7 +20857,7 @@ bool SMPInstr::BuildCompareExchangeRTL(void) { } // end for (OpNum = 0; ...) if (!DestFound || !SourceFound) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find CMPXCHG operand at %llx for %s\n", @@ -20897,7 +20898,7 @@ bool SMPInstr::BuildPackShiftRTL(SMPoperator PackOp, SMPoperator ShiftOp) { bool DestFound = false; bool SourceFound = false; bool CountFound = false; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; SMPRegTransfer *ShiftRT = new SMPRegTransfer; ShiftRT->SetParentInst(this); SMPRegTransfer *PackRT = new SMPRegTransfer; @@ -20939,7 +20940,7 @@ bool SMPInstr::BuildPackShiftRTL(SMPoperator PackOp, SMPoperator ShiftOp) { } // end for (OpNum = 0; ...) if (!DestFound || !SourceFound || !CountFound) { - if (NULL != TempRT) + if (nullptr != TempRT) delete TempRT; #if SMP_DEBUG_BUILD_RTL SMP_msg("ERROR: Could not find MMX/XMM pack and shift operand at %llx for %s\n", @@ -21086,7 +21087,7 @@ bool SMPInstr::BuildCallRTL(void) { bool ParameterlessCall = ((opcode == STARS_NN_syscall) || (opcode == STARS_NN_sysenter) || (opcode == STARS_NN_into) || (opcode == STARS_NN_int3)); STARSOpndTypePtr VoidOp = this->STARSInstPtr->MakeVoidOpnd(); - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; if (ParameterlessCall) { TempRT = new SMPRegTransfer; @@ -21273,7 +21274,7 @@ bool SMPInstr::BuildEnterRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(FramePointerOp); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // Add second effect: ebp := esp - wordsize TempRT = new SMPRegTransfer; @@ -21287,8 +21288,8 @@ bool SMPInstr::BuildEnterRTL(void) { RightRT->SetRightOperand(ImmedWordSizeOp); TempRT->SetRightTree(RightRT); this->RTL.push_back(TempRT); - TempRT = NULL; - RightRT = NULL; + TempRT = nullptr; + RightRT = nullptr; // Add final effect on stack pointer AllocBytes += (global_STARS_program->GetSTARS_ISA_Bytewidth() * (NestingLevel + 1)); @@ -21327,8 +21328,8 @@ bool SMPInstr::BuildLeaveRTL(void) { RightRT->SetRightOperand(ImmedWordSizeOp); TempRT->SetRightTree(RightRT); this->RTL.push_back(TempRT); - TempRT = NULL; - RightRT = NULL; + TempRT = nullptr; + RightRT = nullptr; // Build second effect: EBP := [EBP+0] TempRT = new SMPRegTransfer; @@ -21337,7 +21338,7 @@ bool SMPInstr::BuildLeaveRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(SavedEBP); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; return true; } // end of SMPInstr::BuildLeaveRTL() @@ -21370,8 +21371,8 @@ bool SMPInstr::BuildOptType8RTL(void) { this->RTL.push_back(TempRT); // Create the effect on EAX. - TempRT = NULL; - RightRT = NULL; + TempRT = nullptr; + RightRT = nullptr; TempRT = new SMPRegTransfer; TempRT->SetParentInst(this); TempRT->SetLeftOperand(DestOp2); @@ -21390,7 +21391,7 @@ bool SMPInstr::BuildOptType8RTL(void) { // Build the RTL for a direct or indirect jump instruction bool SMPInstr::BuildJumpRTL(SMPoperator CondBranchOp) { bool TargetFound = false; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; STARSOpndTypePtr EIPOp = this->STARSInstPtr->MakeRegOpnd(MD_INSTRUCTION_POINTER_REG); STARSOpndTypePtr CountOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_cx); STARSOpndTypePtr FlagsOp = this->STARSInstPtr->MakeRegOpnd(X86_FLAGS_REG); @@ -21515,7 +21516,7 @@ void SMPInstr::SubFromStackPointer(STARS_uval_t delta) { bool SMPInstr::BuildPopRTL(void) { std::size_t OpNum, OpSize; bool DestFound = false; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; // Handle special cases first. if ((SMP_FIRST_POP_FLAGS <= this->GetIDAOpcode()) && (SMP_LAST_POP_FLAGS >= this->GetIDAOpcode())) { @@ -21527,7 +21528,7 @@ bool SMPInstr::BuildPopRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(StackOp); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // Now create the stack pointer increment effect. this->AddToStackPointer(global_STARS_program->GetSTARS_ISA_Bytewidth()); return true; @@ -21548,7 +21549,7 @@ bool SMPInstr::BuildPopRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(StackOp0); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // ESI comes from [ESP+4 or 8] STARSOpndTypePtr ESIOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_si, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21560,7 +21561,7 @@ bool SMPInstr::BuildPopRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(StackOp1); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // EBP comes from [ESP+8 or 16] STARSOpndTypePtr EBPOp = this->STARSInstPtr->MakeRegOpnd(MD_FRAME_POINTER_REG, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21572,7 +21573,7 @@ bool SMPInstr::BuildPopRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(StackOp2); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // Skip over saved ESP at [ESP+12 or 24] @@ -21586,7 +21587,7 @@ bool SMPInstr::BuildPopRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(StackOp4); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // EDX comes from [ESP+20 or 40] STARSOpndTypePtr EDXOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_dx, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21598,7 +21599,7 @@ bool SMPInstr::BuildPopRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(StackOp5); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // ECX comes from [ESP+24 or 48] STARSOpndTypePtr ECXOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_cx, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21610,7 +21611,7 @@ bool SMPInstr::BuildPopRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(StackOp6); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // EAX comes from [ESP+28 or 56] STARSOpndTypePtr EAXOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_ax, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21622,7 +21623,7 @@ bool SMPInstr::BuildPopRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetRightOperand(StackOp7); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // Now create the stack pointer increment effect. this->AddToStackPointer(8*global_STARS_program->GetSTARS_ISA_Bytewidth()); @@ -21668,7 +21669,7 @@ bool SMPInstr::BuildPopRTL(void) { bool SMPInstr::BuildPushRTL(void) { std::size_t OpNum, OpSize; bool SourceFound = false; - SMPRegTransfer *TempRT = NULL; + SMPRegTransfer *TempRT = nullptr; // Handle special cases first. if ((SMP_FIRST_PUSH_FLAGS <= this->GetIDAOpcode()) && (SMP_LAST_PUSH_FLAGS >= this->GetIDAOpcode())) { @@ -21697,7 +21698,7 @@ bool SMPInstr::BuildPushRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetLeftOperand(StackOp8); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // ESI goes to [ESP-28 or 56] STARSOpndTypePtr ESIOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_si, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21709,7 +21710,7 @@ bool SMPInstr::BuildPushRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetLeftOperand(StackOp7); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // EBP goes to [ESP-24 or 48] STARSOpndTypePtr EBPOp = this->STARSInstPtr->MakeRegOpnd(MD_FRAME_POINTER_REG, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21721,7 +21722,7 @@ bool SMPInstr::BuildPushRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetLeftOperand(StackOp6); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // ESP goes to [ESP-20 or 40] STARSOpndTypePtr ESPOp = this->STARSInstPtr->MakeRegOpnd(MD_STACK_POINTER_REG, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21733,7 +21734,7 @@ bool SMPInstr::BuildPushRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetLeftOperand(StackOp5); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // EBX goes to [ESP-16 or 32] STARSOpndTypePtr EBXOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_bx, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21745,7 +21746,7 @@ bool SMPInstr::BuildPushRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetLeftOperand(StackOp4); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // EDX goes to [ESP-12 or 24] STARSOpndTypePtr EDXOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_dx, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21757,7 +21758,7 @@ bool SMPInstr::BuildPushRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetLeftOperand(StackOp3); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // ECX goes to [ESP-8 or 16] STARSOpndTypePtr ECXOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_cx, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21769,7 +21770,7 @@ bool SMPInstr::BuildPushRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetLeftOperand(StackOp2); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // EAX goes to [ESP-4] STARSOpndTypePtr EAXOp = this->STARSInstPtr->MakeRegOpnd(STARS_x86_R_ax, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); @@ -21781,7 +21782,7 @@ bool SMPInstr::BuildPushRTL(void) { TempRT->SetOperator(SMP_ASSIGN); TempRT->SetLeftOperand(StackOp1); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // Now create the stack pointer increment effect. this->SubFromStackPointer((STARS_uval_t) 8 * global_STARS_program->GetSTARS_ISA_Bytewidth()); @@ -21807,7 +21808,7 @@ bool SMPInstr::BuildPushRTL(void) { StackOp->SetByteWidth(OpSize); TempRT->SetLeftOperand(StackOp); this->RTL.push_back(TempRT); - TempRT = NULL; + TempRT = nullptr; // Now create the stack pointer increment effect. this->SubFromStackPointer((STARS_uval_t) OpSize); #if 0 @@ -21857,7 +21858,7 @@ bool SMPInstr::BuildARM64RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; } @@ -22765,7 +22766,7 @@ bool SMPInstr::BuildARM64RTL(void) bool SMPInstr::BuildX86RTL(void) { STARSOpndTypePtr FlagsOp = this->STARSInstPtr->MakeRegOpnd(X86_FLAGS_REG, (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64)); - SMPRegTransfer *NopRT = NULL; // no-op register transfer + SMPRegTransfer *NopRT = nullptr; // no-op register transfer // We don't want to explicitly represent the various no-ops except as NULL operations. // E.g. mov esi,esi should not generate DEF and USE of esi, because esi does not change. @@ -22774,7 +22775,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; } @@ -22841,7 +22842,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_cmc: // Complement Carry Flag @@ -22881,7 +22882,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_idiv: // Signed Divide @@ -23044,7 +23045,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_lods: // Load String @@ -23093,7 +23094,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_not: // One's Complement Negation @@ -23291,7 +23292,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_stos: // Store String @@ -23314,7 +23315,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; if (STARS_NN_wait != this->GetIDAOpcode()) this->RTL.ExtraKills.push_back(FlagsOp); return true; @@ -23350,7 +23351,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; // @@ -23379,7 +23380,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; @@ -23477,7 +23478,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_fild: // Load Integer @@ -23535,7 +23536,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_fptan: // Partial tangent @@ -23564,7 +23565,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_fldcw: // Load Control Word @@ -23582,7 +23583,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_fstenv: // Store Environment @@ -23602,7 +23603,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_fnop: // No Operation @@ -23610,7 +23611,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_feni: // (8087 only) @@ -23638,7 +23639,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; @@ -23667,7 +23668,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; break; @@ -23861,7 +23862,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; break; @@ -23872,7 +23873,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; // Pentium III instructions @@ -24055,7 +24056,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; // Pentium III Pseudo instructions @@ -24160,7 +24161,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; @@ -24187,7 +24188,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; break; @@ -24245,7 +24246,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_maskmovdqu: // Store Selected Bytes of Double Quadword @@ -24262,7 +24263,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_minpd: // Return Minimum Packed Double-Precision Floating-Point Values @@ -24310,7 +24311,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; case STARS_NN_pmuludq: // Multiply Packed Unsigned Doubleword Integers @@ -24414,7 +24415,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; break; @@ -24494,7 +24495,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; // Added with x86-64 @@ -25406,7 +25407,7 @@ bool SMPInstr::BuildX86RTL(void) NopRT->SetParentInst(this); NopRT->SetOperator(SMP_NULL_OPERATOR); this->RTL.push_back(NopRT); - NopRT = NULL; + NopRT = nullptr; return true; // Transactional Synchronization Extensions @@ -26501,7 +26502,7 @@ void SMPInstr::SyncRTLDefUse(SMPRegTransfer *CurrRT, bool UseFP, STARS_sval_t FP // Guard operands can only be USEs. SMPGuard *GuardExpr = CurrRT->GetGuard(); - if (NULL != GuardExpr) { + if (nullptr != GuardExpr) { LeftOp = GuardExpr->GetLeftOperand(); if ((!((nullptr == LeftOp) || LeftOp->IsVoidOp())) && (!LeftOp->IsImmedOp())) { LeftOp->CleanOpndEncoding(); diff --git a/src/base/SMPProgram.cpp b/src/base/SMPProgram.cpp index 3d4d6a202f0a49753d7392cf215a4515a9000e8b..182deff1cf7c223e6b1854c8bbd63ad28cf3d539 100644 --- a/src/base/SMPProgram.cpp +++ b/src/base/SMPProgram.cpp @@ -90,7 +90,7 @@ static const char *DataTypes[] = { "VOID", "NUMHEX", "NUMDEC", "CHAR", bool IsDataAddress(STARS_ea_t Address) { bool DataFound = false; segment_t *seg = SMP_getseg(Address); - if (NULL != seg) { + if (nullptr != seg) { if ((seg->type == SEG_DATA) || (seg->type == SEG_BSS) || (seg->type == SEG_COMM)) { DataFound = true; } @@ -108,9 +108,9 @@ SMPProgram::SMPProgram(void) { this->ProfilerGranularityComplete = false; this->ThrowsExceptions = false; this->FoundMutuallyRecursiveFuncs = false; - this->ProfInfo = NULL; - this->AnnotationFile = NULL; - this->InfoAnnotationFile = NULL; + this->ProfInfo = nullptr; + this->AnnotationFile = nullptr; + this->InfoAnnotationFile = nullptr; this->FuncMap.clear(); this->TempFuncMap.clear(); this->FuncList.clear(); @@ -144,7 +144,7 @@ SMPProgram::SMPProgram(void) { SMPProgram::~SMPProgram(void) { map<STARS_ea_t, SMPFunction *>::iterator FuncIter; for (FuncIter = this->FuncMap.begin(); FuncIter != this->FuncMap.end(); ++FuncIter) { - if (NULL != FuncIter->second) + if (nullptr != FuncIter->second) delete (FuncIter->second); } this->FuncMap.clear(); @@ -185,9 +185,9 @@ bool SMPProgram::FindGlobalMaxValue(const STARS_ea_t GlobalAddr, STARS_uval_t &M } // end of SMPProgram::FindGlobalMaxValue() // Return SMPFunction pointer from FuncMap for FirstAddr if it exists -// in the FuncMap, else return NULL. +// in the FuncMap, else return nullptr. SMPFunction *SMPProgram::FindFunction(STARS_ea_t FirstAddr) const { - SMPFunction *FuncPtr = NULL; + SMPFunction *FuncPtr = nullptr; map<STARS_ea_t, SMPFunction *>::const_iterator FuncMapIter = this->FuncMap.find(FirstAddr); if (this->FuncMap.cend() != FuncMapIter) { FuncPtr = FuncMapIter->second; @@ -197,7 +197,7 @@ SMPFunction *SMPProgram::FindFunction(STARS_ea_t FirstAddr) const { // get function for any instruction ID, not just first ID SMPFunction* SMPProgram::FindFunctionAndBlockFromInstID(const STARS_ea_t AnyInstID, int &BlockNum) const { - SMPFunction *FuncPtr = NULL; + SMPFunction *FuncPtr = nullptr; for (map<STARS_ea_t, SMPFunction *>::const_iterator FuncMapIter = this->FuncMap.cbegin(); FuncMapIter != this->FuncMap.cend(); ++FuncMapIter) { FuncPtr = FuncMapIter->second; BlockNum = FuncPtr->GetBlockNumFromInstAddr(AnyInstID); @@ -250,7 +250,7 @@ void SMPProgram::SetFuncAddrCalledFromOrphanedCode(STARS_ea_t TargetAddr) { // Add unreachable block and its instructions to containers void SMPProgram::AddUnreachableBlock(SMPBasicBlock *DeadBlock) { - assert(NULL != DeadBlock); + assert(nullptr != DeadBlock); this->UnreachableBlocks.push_back(DeadBlock); @@ -335,7 +335,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn long TotalUntypedPhiDefs = 0; long TotalSafeFuncs = 0; size_t TotalInstructions = 0; - time_t StartTime = time(NULL), EndTime, Time1, Time2, Time3, Time4, Time5, Time6; + time_t StartTime = time(nullptr), EndTime, Time1, Time2, Time3, Time4, Time5, Time6; double Analysis1, Analysis2, Analysis3, Analysis4, Analysis5; this->ProfInfo = pi; @@ -354,7 +354,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn // Loop through all segments. STARS_ea_t RecentAddr = STARS_BADADDR; unsigned long long STARS_TotalCodeSize = 0; - for (STARS_Segment_t *seg = SMP_get_first_seg(); NULL != seg; seg = SMP_get_next_seg(RecentAddr)) { + for (STARS_Segment_t *seg = SMP_get_first_seg(); nullptr != seg; seg = SMP_get_next_seg(RecentAddr)) { char SegName[STARS_MAXSTR]; STARS_ssize_t SegNameSize = SMP_get_segm_name(seg, SegName, STARS_MAXSTR - 1); STARS_ea_t startEA = seg->get_startEA(); @@ -390,10 +390,12 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn SMP_msg("INFO: Performing reduced STARS analyses due to code size.\n"); } + SMP_msg("INFO: VMEM: Before Phase 1: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); + for (size_t FuncIndex = 0; FuncIndex < NumFuncs; ++FuncIndex) { STARS_Function_t *FuncInfo = SMP_getn_func(FuncIndex); - if (NULL == FuncInfo) { + if (nullptr == FuncInfo) { SMP_msg("ERROR: NULL FuncInfo for FuncIndex %zu \n", FuncIndex); continue; } @@ -401,7 +403,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn #if 1 // IRDB functions might not map to segments, might return NULL seg. // Might want an XTRN attribute for Functions instead of segments. STARS_Segment_t *seg = SMP_getseg(FuncInfo->get_startEA()); - if ((NULL != seg) && seg->IsXternSegment() /* ->type == SEG_XTRN */) { + if ((nullptr != seg) && seg->IsXternSegment() /* ->type == SEG_XTRN */) { SMP_msg("Skipping SEG_XTRN func: FuncIndex %zu, FuncEA=%llx\n", FuncIndex, FuncInfo->get_startEA()); continue; } @@ -416,7 +418,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn #endif // Create a function object. CurrFunc = new SMPFunction(FuncInfo, this); - assert(NULL != CurrFunc); + assert(nullptr != CurrFunc); // Get try/catch info to reveal code blocks that are only reachable // via exception handlers. @@ -446,11 +448,11 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn while (MapIter != this->FuncMap.end()) { ++NextMapIter; CurrFunc = MapIter->second; - if ((NULL != CurrFunc) && CurrFunc->IsFuncEmpty()) { + if ((nullptr != CurrFunc) && CurrFunc->IsFuncEmpty()) { delete CurrFunc; - CurrFunc = NULL; + CurrFunc = nullptr; } - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { this->FuncMap.erase(MapIter); } #if STARS_INTEGRATE_UNSHARED_FRAGMENTS @@ -474,11 +476,11 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn SMP_msg("INFO: Number of functions in FuncMap: %zu\n", this->FuncMap.size()); #endif - EndTime = time(NULL); + EndTime = time(nullptr); double TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 1: AnalyzeFunc: %7.2f\n", TimeDiff); SMP_msg("INFO: VMEM: Phase 1: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); - StartTime = time(NULL); + StartTime = time(nullptr); if (global_STARS_program->ShouldSTARSPerformReducedAnalysis()) { this->EmitDataAnnotations(AnnotFile, InfoAnnotFile); @@ -507,7 +509,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn ProgramChanged = false; for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -518,18 +520,18 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } CurrFunc->AdvancedAnalysis3(); } // end for all funcs - EndTime = time(NULL); + EndTime = time(nullptr); TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 2: AdvancedAnalysis: %7.2f\n", TimeDiff); SMP_msg("INFO: VMEM: Phase 2: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); - StartTime = time(NULL); + StartTime = time(nullptr); // In order to reduce memory consumption, emit the global data annotations now, // and then release the memory for the global data. Note that this means we @@ -540,11 +542,11 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn this->GlobalVarTable.clear(); this->GlobalNameMap.clear(); - EndTime = time(NULL); + EndTime = time(nullptr); TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 3: EmitDataAnnotations: %7.2f\n", TimeDiff); SMP_msg("INFO: VMEM: Phase 3: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); - StartTime = time(NULL); + StartTime = time(nullptr); #ifndef SMP_REDUCED_ANALYSIS @@ -554,7 +556,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn SMP_msg("INFO: Maximum basic block count in one function: %lu\n", STARS_MaxBlockCount); for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -568,7 +570,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn Analysis1 = Analysis2 = Analysis3 = Analysis4 = Analysis5 = 0.0; for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -585,9 +587,9 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn CurrFunc->LiveVariableAnalysis(false); #endif if (DebugFlag) SMP_msg("Computing SSA.\n"); - Time1 = time(NULL); + Time1 = time(nullptr); CurrFunc->ComputeSSA(); - Time2 = time(NULL); + Time2 = time(nullptr); Analysis1 += difftime(Time2, Time1); if (DebugFlag) SMP_msg("Finished SSA.\n"); if (global_STARS_program->ShouldSTARSPerformConstantPropagation()) { @@ -599,14 +601,14 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn #endif } } - Time3 = time(NULL); + Time3 = time(nullptr); double SCCPTime2 = difftime(Time3, Time2); Analysis2 += SCCPTime2; if (SCCPTime2 >= 5.0) { SMP_msg("INFO: SCCP Processing time of %8.2f seconds for %s\n", SCCPTime2, CurrFunc->GetFuncName()); } CurrFunc->AliasAnalysis2(); - Time4 = time(NULL); + Time4 = time(nullptr); double AliasTime2 = difftime(Time4, Time3); Analysis3 += AliasTime2; if (AliasTime2 >= 5.0) { @@ -614,21 +616,22 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn } } // end if StackPtrAnalysisSucceeed, GoodRTLs, no unresolved indirect jumps => do SSA, SCCP, AliasAnalysis - Time5 = time(NULL); + Time5 = time(nullptr); Analysis4 += difftime(Time5, Time4); CurrFunc->MarkFunctionSafe(); - Time6 = time(NULL); + Time6 = time(nullptr); Analysis5 += difftime(Time6, Time5); if (DebugFlag) SMP_msg("Finished MarkFunctionSafe.\n"); CurrFunc->FreeUnusedMemory3(); // free memory } // end for all functions, STEP 2 - EndTime = time(NULL); + EndTime = time(nullptr); TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 4: SSA+SCCP+FuncSafe+AliasAnalysis: %7.2f SSA: %7.2f SCCP: %7.2f AliasAnalysis: %7.2f FuncSafe: %7.2f\n", TimeDiff, Analysis1, Analysis2, Analysis3, Analysis5); SMP_msg("INFO: VMEM: Phase 4: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); + StartTime = time(nullptr); #if 0 // need to debug // Remove any basic blocks that had a direct indication of being unreachable, e.g. "call 0" instruction. @@ -643,7 +646,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn FuncTypeChanged = false; for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -659,7 +662,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn // Any functions still dependent on their callees are SAFE functions in a mutually recursive state. for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -669,21 +672,21 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn } // end of step 3 - EndTime = time(NULL); + EndTime = time(nullptr); TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 5: RetAddrStatus: %7.2f\n", TimeDiff); SMP_msg("INFO: VMEM: Phase 5: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); - StartTime = time(NULL); + StartTime = time(nullptr); Analysis1 = Analysis2 = Analysis3 = Analysis4 = Analysis5 = 0.0; - Time1 = time(NULL); + Time1 = time(nullptr); if (global_STARS_program->ShouldSTARSTranslateToSPARKAda()) { bool RegsChanged; do { RegsChanged = false; for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -703,19 +706,19 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn } // end for all funcs } while (RegsChanged); } - Time2 = time(NULL); + Time2 = time(nullptr); Analysis1 = difftime(Time2, Time1); for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } bool UnsafeCallees = false; bool UnsafeSpecCallees = false; size_t NumCallTargets = CurrFunc->GetNumCallTargets(); - Time2 = time(NULL); + Time2 = time(nullptr); for (size_t i = 0; i < NumCallTargets; ++i) { STARS_ea_t CallAddr = CurrFunc->GetCallTargetAddr(i); SMPFunction *ChildInstance = this->FindFunction(CallAddr); @@ -731,7 +734,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn UnsafeCallees |= (!ChildInstance->IsSafeCallee()); UnsafeSpecCallees |= (!ChildInstance->IsSpecSafeCallee()); } - Time3 = time(NULL); + Time3 = time(nullptr); Analysis2 += difftime(Time3, Time2); #if SMP_USE_SWITCH_TABLE_INFO @@ -745,7 +748,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn CurrFunc->AnalyzeMetadataLiveness(); if (DebugFlag) SMP_msg("Finished analyzing metadata.\n"); } - Time4 = time(NULL); + Time4 = time(nullptr); Analysis3 += difftime(Time4, Time3); // If callees are unsafe, we need mmStrata to allocate a memory referent for our frame. @@ -771,7 +774,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn #endif CurrFunc->InferTypes(true); CurrFunc->FindRedundantMetadata(); - Time5 = time(NULL); + Time5 = time(nullptr); Analysis4 += difftime(Time5, Time4); // Apply profiler information. @@ -789,7 +792,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn ++TotalSafeFuncs; // Infer fine-grained info (signedness, bit widths, etc.) CurrFunc->InferFGInfo(); - Time6 = time(NULL); + Time6 = time(nullptr); Analysis5 += difftime(Time6, Time5); #if SMP_DEBUG_OPTIMIZATIONS_VERBOSE @@ -803,14 +806,14 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn STARS_BasicBlockCount += CurrFunc->GetNumBlocks(); } // end for all functions - EndTime = time(NULL); + EndTime = time(nullptr); TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 6: MetaData+InferTypes+InferFG: %7.2f InOutRegs: %7.2f UnsafeCallees: %7.2f Metadata: %7.2f InferTypes: %7.2f InferFG: %7.2f\n", TimeDiff, Analysis1, Analysis2, Analysis3, Analysis4, Analysis5); SMP_msg("INFO: VMEM: Phase 6: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); // STEP 4A: Interprocedural CFG return target analysis. - StartTime = time(NULL); + StartTime = time(nullptr); SMP_msg("Performing interprocedural CFG return target analysis.\n"); bool changed; size_t IterationCounter = 0; @@ -820,7 +823,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn ++IterationCounter; for (RevFuncListIter = this->PrioritizedFuncList.rbegin(); RevFuncListIter != this->PrioritizedFuncList.rend(); ++RevFuncListIter) { CurrFunc = (*RevFuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -840,7 +843,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn ++IterationCounter; for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -862,7 +865,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { continue; } #if SMP_USE_SWITCH_TABLE_INFO @@ -881,17 +884,17 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn #endif - EndTime = time(NULL); + EndTime = time(nullptr); TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 7: ReturnTargets + InterproceduralTypes + InArgTypes + TraceInArgs: %7.2f\n", TimeDiff); SMP_msg("INFO: VMEM: Phase 7: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); // Loop 7B: Loop iteration and memory access analysis. - Time4 = time(NULL); + Time4 = time(nullptr); for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } @@ -902,24 +905,24 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn } } } - Time5 = time(NULL); + Time5 = time(nullptr); TimeDiff = difftime(Time5, Time4); SMP_msg("INFO: TIME: Phase 7B: LoopIter: %7.2f \n", TimeDiff); SMP_msg("INFO: VMEM: Phase 7B: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); - StartTime = time(NULL); + StartTime = time(nullptr); if (global_STARS_program->ShouldSTARSPerformConstantPropagation()) { - StartTime = time(NULL); + StartTime = time(nullptr); // Step 7C: Analyze buffers of constant size and their use in vulnerable library funcs. for (FuncListIter = this->PrioritizedFuncList.begin(); FuncListIter != this->PrioritizedFuncList.end(); ++FuncListIter) { CurrFunc = (*FuncListIter); - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in PrioritizedFuncList\n"); continue; } CurrFunc->AnalyzeBufferUses(); } - EndTime = time(NULL); + EndTime = time(nullptr); TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 7C: AnalyzeBufferUses: %7.2f\n", TimeDiff); SMP_msg("INFO: VMEM: Phase 7C: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); @@ -977,7 +980,7 @@ void SMPProgram::Analyze(ProfilerInformation *pi, FILE *AnnotFile, FILE *InfoAnn // If so, return true and add ChunkAddr to UnsharedFragments set. bool SMPProgram::IsChunkUnshared(STARS_ea_t ChunkAddr, STARS_ea_t FuncHeadStart, STARS_ea_t FuncHeadEnd) { STARS_Function_t *CurrFunc = SMP_get_func(ChunkAddr); - assert(NULL != CurrFunc); + assert(nullptr != CurrFunc); bool Unshared = CurrFunc->IsChunkUnshared(ChunkAddr, FuncHeadStart, FuncHeadEnd); if (Unshared) { @@ -1101,7 +1104,7 @@ bool SMPProgram::EmitProgramSPARKAda(void) { map<STARS_ea_t, SMPFunction *>::iterator FuncIter; for (FuncIter = this->FuncMap.begin(); FuncIter != this->FuncMap.end(); ++FuncIter) { SMPFunction *TempFunc = FuncIter->second; - if (TempFunc == NULL) continue; + if (TempFunc == nullptr) continue; if (TempFunc->HasStructuredControlFlow()) { TempFunc->PreProcessForSPARKAdaTranslation(); } @@ -1133,7 +1136,7 @@ bool SMPProgram::EmitProgramSPARKAda(void) { // Loop through all functions and emit SPARK Ada for each. for (FuncIter = this->FuncMap.begin(); FuncIter != this->FuncMap.end(); ++FuncIter) { SMPFunction *TempFunc = FuncIter->second; - if (TempFunc == NULL) continue; + if (TempFunc == nullptr) continue; if (TempFunc->HasStructuredControlFlow()) { TempFunc->EmitFuncSPARKAda(); } @@ -1167,7 +1170,7 @@ bool SMPProgram::EmitProgramSPARKAda(void) { void SMPProgram::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { long TotalSafeBlocks = 0; // basic blocks with no unsafe writes long TotalUnsafeBlocks = 0; // basic blocks with unsafe writes - time_t StartTime = time(NULL), EndTime; + time_t StartTime = time(nullptr), EndTime; // Mark exception-handling functions as unsafe for fast returns. if (this->ProgramThrowsExceptions()) { @@ -1178,7 +1181,7 @@ void SMPProgram::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { map<STARS_ea_t, SMPFunction *>::iterator FuncIter; for (FuncIter = this->FuncMap.begin(); FuncIter != this->FuncMap.end(); ++FuncIter) { SMPFunction *TempFunc = FuncIter->second; - if (TempFunc == NULL) continue; + if (TempFunc == nullptr) continue; TempFunc->EmitAnnotations(AnnotFile, InfoAnnotFile); TotalSafeBlocks += TempFunc->GetSafeBlocks(); TotalUnsafeBlocks += TempFunc->GetUnsafeBlocks(); @@ -1188,7 +1191,7 @@ void SMPProgram::EmitAnnotations(FILE *AnnotFile, FILE *InfoAnnotFile) { (void) this->EmitProgramSPARKAda(); } - EndTime = time(NULL); + EndTime = time(nullptr); double TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 8: EmitAnnotations: %7.2f\n", TimeDiff); SMP_msg("INFO: VMEM: Phase 8: Maximum resident memory usage in MB: %ld \n", global_stars_interface->GetMemoryInUse()); @@ -1348,7 +1351,7 @@ void SMPProgram::ProcessExceptionHandlingFileSections(void) { bool mode64 = (global_STARS_program->GetSTARS_ISA_Bitwidth() == 64); FILE *EHAddrsFile = SMP_fopen(EHFileName.c_str(), "r"); - if (EHAddrsFile == NULL) { + if (EHAddrsFile == nullptr) { SMP_msg("ERROR: Cannot open %s for reading exception handling func addrs.\n", EHFileName.c_str()); return; } @@ -1363,7 +1366,7 @@ void SMPProgram::ProcessExceptionHandlingFileSections(void) { if (1 == ReadCount) { // success SMPFunction *EHFunc = this->FindFunction(ExceptionFuncAddr); - if (NULL == EHFunc) { + if (nullptr == EHFunc) { SMP_msg("SERIOUS WARNING: Could not find function at eh_frame address %llx\n", (unsigned long long) ExceptionFuncAddr); } else { @@ -1384,7 +1387,7 @@ void SMPProgram::ResetFuncsProcessed(void) { SMPFunction *CurrFunc; for (MapIter = this->FuncMap.begin(); MapIter != this->FuncMap.end(); ++MapIter) { CurrFunc = MapIter->second; - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in FuncMap for %llx\n", (unsigned long long) MapIter->first); continue; } @@ -1404,7 +1407,7 @@ void SMPProgram::PrioritizeCallGraph(void) { MapIter = this->TempFuncMap.begin(); while (MapIter != this->TempFuncMap.end()) { CurrFunc = MapIter->second; - if (NULL == CurrFunc) { + if (nullptr == CurrFunc) { SMP_msg("ERROR: NULL Func ptr in TempFuncMap for %llx\n", (uint64_t) MapIter->first); ++MapIter; continue; @@ -1498,7 +1501,7 @@ bool SMPProgram::IsInstAddrStillInFunction(STARS_ea_t InstAddr, STARS_ea_t &Firs // First question: Does IDA Pro think it is inside a function? STARS_Function_t *CurrFunc = SMP_get_func(InstAddr); - if (NULL != CurrFunc) { + if (nullptr != CurrFunc) { // InstAddr was initially in a function. See if it was removed as unreachable code. map<STARS_ea_t, SMPBasicBlock *>::iterator MapIter = this->UnreachableInstBlockMap.find(InstAddr); // If we did not find the InstAddr in the unreachable code, then it is still in a function somewhere, @@ -1517,9 +1520,9 @@ void SMPProgram::ProcessBlocksPendingRemoval(void) { list<SMPBasicBlock *>::iterator PendingIter = this->BlocksPendingRemoval.begin(); while (PendingIter != this->BlocksPendingRemoval.end()) { SMPBasicBlock *CurrBlock = (*PendingIter); - assert(NULL != CurrBlock); + assert(nullptr != CurrBlock); SMPFunction *CurrFunc = CurrBlock->GetFunc(); - assert(NULL != CurrFunc); + assert(nullptr != CurrFunc); list<SMPBasicBlock *>::iterator BlockIter = CurrFunc->GetBlockIter(CurrBlock); if (BlockIter != CurrFunc->GetLastBlock()) { CurrFunc->RemoveBlock(CurrBlock, BlockIter); diff --git a/src/drivers/idapro/SMPStaticAnalyzer.cpp b/src/drivers/idapro/SMPStaticAnalyzer.cpp index 6b9911f8aaed3dc4063ae174d90baf03df93b4ce..33f4eb1d8e015f663e3e4c93271a55ee9624292d 100644 --- a/src/drivers/idapro/SMPStaticAnalyzer.cpp +++ b/src/drivers/idapro/SMPStaticAnalyzer.cpp @@ -95,9 +95,9 @@ int FuncsProcessed = 0; typedef op_t STARSOpndType; -static SMPProgram *CurrProg = NULL; -STARS_Interface_t* global_stars_interface = NULL; -STARS_Program_t *global_STARS_program = NULL; +static SMPProgram *CurrProg = nullptr; +STARS_Interface_t* global_stars_interface = nullptr; +STARS_Program_t *global_STARS_program = nullptr; set<STARS_ea_t> CodeOrphans; @@ -305,7 +305,7 @@ int IDAP_init(void) { #if 0 // We are now calling from the SMP.idc script. // Skip this plugin if it was not specified by the user on the // command line. - if (get_plugin_options("SMPStaticAnalyzer") == NULL) { + if (get_plugin_options("SMPStaticAnalyzer") == nullptr) { SMP_msg("IDAP_init point 2.\n"); return PLUGIN_SKIP; } @@ -318,23 +318,23 @@ int IDAP_init(void) { } #if (IDA_SDK_VERSION < 700) - bool hooked = hook_to_notification_point(HT_IDP, idp_callback, NULL); + bool hooked = hook_to_notification_point(HT_IDP, idp_callback, nullptr); #else // auto_empty_finally is now hooked to HT_IDB instead of HT_IDP - bool hooked = hook_to_notification_point(HT_IDB, idp_callback, NULL); + bool hooked = hook_to_notification_point(HT_IDB, idp_callback, nullptr); #endif #ifdef STARS_IRDB_INTERFACE - SMPLogFile = NULL; + SMPLogFile = nullptr; #endif return PLUGIN_KEEP; } // end of IDAP_init void IDAP_term(void) { #if (IDA_SDK_VERSION < 700) - unhook_from_notification_point(HT_IDP, idp_callback, NULL); + unhook_from_notification_point(HT_IDP, idp_callback, nullptr); #else // auto_empty_finally is now hooked to HT_IDB instead of HT_IDP - unhook_from_notification_point(HT_IDB, idp_callback, NULL); + unhook_from_notification_point(HT_IDB, idp_callback, nullptr); #endif return; } @@ -344,8 +344,8 @@ void IDAP_run(int arg) { #else bool IDAP_run(size_t arg) { #endif - FILE *AnnotFile = NULL; - FILE *InfoAnnotFile = NULL; + FILE *AnnotFile = nullptr; + FILE *InfoAnnotFile = nullptr; FILE *AsmFile; FILE *DifFile; @@ -472,17 +472,17 @@ bool IDAP_run(size_t arg) { #endif } - time_t StartTime = time(NULL); + time_t StartTime = time(nullptr); time_t EndTime, Time1, Time2; CurrProg->AnalyzeData(); // Analyze static data in the executable - Time1 = time(NULL); + Time1 = time(nullptr); global_STARS_program->FindCodeAddressesTaken(CurrProg); // find code addresses in read-only data segments - Time2 = time(NULL); + Time2 = time(nullptr); // Note: ProfilerInformation must come after the call above to AnalyzeData(). ProfilerInformation *prof_info = new ProfilerInformation(global_STARS_program->GetAnnotFileName().c_str(), CurrProg); - EndTime = time(NULL); + EndTime = time(nullptr); double TimeDiff = difftime(EndTime, StartTime); SMP_msg("INFO: TIME: Phase 0: Data, CodeAddressesTaken, ProfileInfo: %7.2f\n", TimeDiff); TimeDiff = difftime(Time1, StartTime); @@ -527,7 +527,7 @@ bool IDAP_run(size_t arg) { #if SMP_DEBUG_CODE_ORPHANS CodeOrphans.clear(); RecentAddr = STARS_BADADDR; - for (STARS_Segment_t *seg = SMP_get_first_seg(); NULL != seg; seg = SMP_get_next_seg(RecentAddr)) { + for (STARS_Segment_t *seg = SMP_get_first_seg(); nullptr != seg; seg = SMP_get_next_seg(RecentAddr)) { RecentAddr = seg->get_startEA(); if (seg->IsCodeSegment()) Debug_FindOrphanedCode(seg, true); @@ -574,7 +574,7 @@ bool IDAP_run(size_t arg) { CurrProg->ProfGranularityFinished(global_STARS_program->GetAnnotFile(), global_STARS_program->GetInfoAnnotFile()); RecentAddr = STARS_BADADDR; - for (STARS_Segment_t *seg = SMP_get_first_seg(); NULL != seg; seg = SMP_get_next_seg(RecentAddr)) { + for (STARS_Segment_t *seg = SMP_get_first_seg(); nullptr != seg; seg = SMP_get_next_seg(RecentAddr)) { RecentAddr = seg->get_startEA(); if (seg->IsCodeSegment()) FindLinksFromOrphanedCode(seg); @@ -589,7 +589,7 @@ bool IDAP_run(size_t arg) { // alignment purposes). #if SMP_DEBUG_CODE_ORPHANS RecentAddr = STARS_BADADDR; - for (STARS_Segment_t *seg = SMP_get_first_seg(); NULL != seg; seg = SMP_get_next_seg(RecentAddr)) { + for (STARS_Segment_t *seg = SMP_get_first_seg(); nullptr != seg; seg = SMP_get_next_seg(RecentAddr)) { RecentAddr = seg->get_startEA(); if (seg->IsCodeSegment()) Debug_FindOrphanedCode(seg, true); @@ -598,7 +598,7 @@ bool IDAP_run(size_t arg) { #if SMP_FIND_ORPHANS RecentAddr = STARS_BADADDR; - for (STARS_Segment_t *seg = SMP_get_first_seg(); NULL != seg; seg = SMP_get_next_seg(RecentAddr)) { + for (STARS_Segment_t *seg = SMP_get_first_seg(); nullptr != seg; seg = SMP_get_next_seg(RecentAddr)) { RecentAddr = seg->get_startEA(); if (seg->IsCodeSegment()) FindOrphanedCode(seg, global_STARS_program->GetAnnotFile(), global_STARS_program->GetInfoAnnotFile()); @@ -617,7 +617,7 @@ bool IDAP_run(size_t arg) { if (!global_STARS_program->ShouldSTARSPerformReducedAnalysis()) { if (GenAsmFlag) { AsmFile = SMP_fopen(AsmFileName.c_str(), "w"); - if (NULL == AsmFile) { + if (nullptr == AsmFile) { error("FATAL ERROR: Cannot open ASM file %s\n", AsmFileName.c_str()); } else { @@ -630,7 +630,7 @@ bool IDAP_run(size_t arg) { } #if STARS_GENERATE_DIF_FILE DifFile = SMP_fopen(DifFileName.c_str(), "w"); - if (NULL == DifFile) { + if (nullptr == DifFile) { error("FATAL ERROR: Cannot open DIF file %s\n", DifFileName.c_str()); } else { @@ -662,11 +662,11 @@ bool IDAP_run(size_t arg) { } catch (std::bad_alloc) { SMP_msg("FATAL ERROR: Memory exhausted.\n"); - if (NULL != InfoAnnotFile) { + if (nullptr != InfoAnnotFile) { SMP_fprintf(InfoAnnotFile, " 8000000 2 ERROR MEMORYEXHAUSTED\n"); SMP_fclose(InfoAnnotFile); } - if (NULL != AnnotFile) { + if (nullptr != AnnotFile) { SMP_fclose(AnnotFile); } delete CurrProg; @@ -708,7 +708,7 @@ void FindCodeAddresses(void) { string FileSuffix(".SMPobjdump"); DisasmFileName += FileSuffix; FILE *DisasmFile = SMP_fopen(DisasmFileName.c_str(), "r"); - if (NULL == DisasmFile) { + if (nullptr == DisasmFile) { error("FATAL: Cannot open input file %s\n", DisasmFileName.c_str()); return; } @@ -743,7 +743,7 @@ void FindCodeAddresses(void) { // Find all the code locs in the IDA Pro database. As we find // them, store them in IDAProLocs. STARS_ea_t RecentAddr = STARS_BADADDR; - for (STARS_Segment_t *seg = SMP_get_first_seg(); NULL != seg; seg = SMP_get_next_seg(RecentAddr)) { + for (STARS_Segment_t *seg = SMP_get_first_seg(); nullptr != seg; seg = SMP_get_next_seg(RecentAddr)) { RecentAddr = seg->get_startEA(); if (!seg->IsCodeSegment()) continue; @@ -881,7 +881,7 @@ void FindDataInCode(void) { uint32 LocalFeatures; STARS_ea_t RecentAddr = STARS_BADADDR; - for (STARS_Segment_t *seg = SMP_get_first_seg(); NULL != seg; seg = SMP_get_next_seg(RecentAddr)) { + for (STARS_Segment_t *seg = SMP_get_first_seg(); nullptr != seg; seg = SMP_get_next_seg(RecentAddr)) { RecentAddr = seg->get_startEA(); if (!seg->IsCodeSegment()) continue; @@ -1664,7 +1664,7 @@ void FindLinksFromOrphanedCode(STARS_Segment_t *CurrSeg) { if (SMP_isHead(InstrFlags) && SMP_isCode(InstrFlags)) { // Does IDA Pro think addr is inside a function? func_t* CurrIDAFunc = ::get_func(addr); - if (NULL == CurrIDAFunc) { + if (nullptr == CurrIDAFunc) { SMPInstr CurrInst(addr); CurrInst.Analyze(); if (CurrInst.IsAnalyzeable()) { @@ -1678,7 +1678,7 @@ void FindLinksFromOrphanedCode(STARS_Segment_t *CurrSeg) { if (STARS_BADADDR != TargetAddr) { // See if TargetAddr is inside a function. func_t* TargetFunc = ::get_func(TargetAddr); - if (NULL != TargetFunc) { + if (nullptr != TargetFunc) { #if (IDA_SDK_VERSION < 700) STARS_ea_t FirstAddrInFunc = TargetFunc->startEA; #else @@ -1695,7 +1695,7 @@ void FindLinksFromOrphanedCode(STARS_Segment_t *CurrSeg) { } } } - } // end if (NULL == CurrFunc) + } // end if (nullptr == CurrFunc) } // end if addr is code and isHead } // end for (ea_t addr = CurrSeg->startEA; ...) return; @@ -1711,7 +1711,7 @@ void Debug_FindOrphanedCode(STARS_Segment_t *CurrSeg, bool FirstRun) { flags_t InstrFlags = SMP_getFlags(addr); if (SMP_isHead(InstrFlags) && SMP_isCode(InstrFlags)) { STARS_Function_t *CurrFunc = SMP_get_func(addr); - if (NULL == CurrFunc) { // Code not in a func; orphaned + if (nullptr == CurrFunc) { // Code not in a func; orphaned pair<set<STARS_ea_t>::iterator, bool> pairib; pairib = CodeOrphans.insert(addr); if (DebugAddr == addr) { diff --git a/src/interfaces/idapro/STARSIDAProgram.cpp b/src/interfaces/idapro/STARSIDAProgram.cpp index 682dfd362b492296b5e96ee3a7f774fb8abf2614..efc2883d67b386b771d38e5c2068b5cde390d10f 100644 --- a/src/interfaces/idapro/STARSIDAProgram.cpp +++ b/src/interfaces/idapro/STARSIDAProgram.cpp @@ -16,11 +16,13 @@ #include "base/SMPProgram.h" +// IDA Pro headers +#include <bytes.hpp> // for get_flags(), is_code(), is_data(), is_unknown() + #if 0 #include <pro.h> #include <fpro.h> #include <ua.hpp> -#include <bytes.hpp> #include <funcs.hpp> // for func_t type #include <kernwin.hpp> #include <nalt.hpp> // for get_root_filename() @@ -457,32 +459,36 @@ void STARS_IDA_Program_t::ComputeGlobalFieldOffsets(struct GlobalVar &CurrGlobal // print code with addresses in the instruction, eliding control flow instructions. void STARS_IDA_Program_t::PrintAllAddressTakenXrefs(STARS_ea_t InstAddr, std::size_t InstSize) { - auto xrefs=SMP_xref_t(); - // SMP_msg("dumping address-taken xrefs for addr/id=%llx\n", InstAddr); - for (auto ok = xrefs.SMP_first_from(InstAddr, XREF_DATA); ok; ok = xrefs.SMP_next_from()) + auto xrefs = SMP_xref_t(); + // SMP_msg("dumping address-taken xrefs for addr/id=%llx\n", InstAddr); + for (auto ok = xrefs.SMP_first_from(InstAddr, XREF_DATA); ok; ok = xrefs.SMP_next_from()) { - // SMP_msg("xref from=%llx to=%llx type=%d iscode=%d\n", xrefs.GetFrom(), xrefs.GetTo(), xrefs.GetType(), xrefs.GetIscode()); + // SMP_msg("xref from=%llx to=%llx type=%d iscode=%d\n", xrefs.GetFrom(), xrefs.GetTo(), xrefs.GetType(), xrefs.GetIscode()); + + + const auto to_addr = xrefs.GetTo(); + // skip empty To fields. + if (to_addr == 0) continue; - const auto to_addr=xrefs.GetTo(); /* auto addr=STARS_InstructionID_t(to_addr); const auto is_to_code=addr.HasCorrespondingInstructionIR(); this doesn't work because we may not _yet_ have the IR for the instruction. instead, ask ida for code/data disambig. */ - const auto flags=get_flags(to_addr); - const auto is_to_code=is_code(flags); - - // skip empty To fields. - if ( to_addr == 0 ) continue; - - // should be OK to print - global_STARS_program->PrintAddressInCode(InstAddr, to_addr, InstSize, is_to_code); - } - - + const auto flags = ::get_flags(to_addr); + const bool is_to_code = ::is_code(flags); + const bool is_to_data = ::is_data(flags); + const bool is_to_unknown = ::is_unknown(flags); + + if (!is_to_unknown) { + // should be OK to print + global_STARS_program->PrintAddressInCode(InstAddr, to_addr, InstSize, is_to_code); + } + } + return; } // end of STARS_IDA_Program_t::PrintAllAddressTakenXrefs() @@ -498,7 +504,7 @@ void STARS_IDA_Program_t::PrintAllCodeToCodeXrefs(STARS_ea_t InstAddr, std::size TypeCode = ZST_INDIRCALL; } for (bool ok = xrefs.SMP_first_from(InstAddr, XREF_ALL); ok; ok = xrefs.SMP_next_from()) { - // SMP_msg("code2codeXref from=%llx to=%llx type=%d iscode=%d\n", xrefs.GetFrom(), xrefs.GetTo(), xrefs.GetType(), xrefs.GetIscode()); + // SMP_msg("code2codeXref from=%llx to=%llx type=%d iscode=%d\n", xrefs.GetFrom(), xrefs.GetTo(), xrefs.GetType(), xrefs.GetIscode()); if (xrefs.GetTo() != 0) { // Exclude the ordinary fall-through control flow type, fl_F if (xrefs.GetIscode() && (xrefs.GetType() != fl_F)) {