diff --git a/src/base/SMPFunction.cpp b/src/base/SMPFunction.cpp index 4e8e22772b19567dacacafe55c12dc3203fb9e4c..3f0b9060d66c8cbef7de1ef86fcb62829d7ed6cd 100644 --- a/src/base/SMPFunction.cpp +++ b/src/base/SMPFunction.cpp @@ -3978,13 +3978,13 @@ void SMPFunction::AnalyzeFunc(void) { CurrInst->SetBlock(CurrBlock->GetThisBlock()); -// jdh hack: redo syscall analysis as block may not be set -// when syscall analysis was done first time. -if (CurrInst->GetDataFlowType() == INDIR_CALL) { - if (CurrInst->MDIsSystemCall()) { - this->SetHasSystemCalls(); - } -} + // jdh hack: redo syscall analysis as block may not be set + // when syscall analysis was done first time. + if (CurrInst->GetDataFlowType() == INDIR_CALL) { + if (CurrInst->MDIsSystemCall()) { + this->SetHasSystemCalls(); + } + } SMPitype InstDataFlowType = CurrInst->GetDataFlowType(); if ((CALL == InstDataFlowType) || (INDIR_CALL == InstDataFlowType)) { @@ -5992,6 +5992,7 @@ void SMPFunction::DetectLoopInductionVars(void) { int SecondOpSSANum = SMP_SSA_UNINIT; if (!BIVarFound && MDIsDataFlowOpnd(SecondOp, UseFP) && this->IsGlobalName(SecondOp)) { STARSOpndTypePtr SearchOp = CloneIfNecessary(SecondOp, UseFP); + CanonicalizeOpnd(SearchOp); STARSDefUseIter SecondOpUseIter = InsideDefInst->FindUse(SearchOp); assert(SecondOpUseIter != InsideDefInst->GetLastUse()); SecondOpSSANum = SecondOpUseIter->GetSSANum(); @@ -6000,7 +6001,7 @@ void SMPFunction::DetectLoopInductionVars(void) { // Note that block-local names are loop-variant and are already excluded. SMPBasicBlock *InsideDefBlock = this->GetBlockByNum((size_t) PhiUseDefBlockNum1); assert(NULL != InsideDefBlock); - STARS_ea_t SecondOpDefAddr = InsideDefBlock->GetDefAddrFromUseAddr(SecondOp, InsideDefAddr, UseIter->GetSSANum(), false); + STARS_ea_t SecondOpDefAddr = InsideDefBlock->GetDefAddrFromUseAddr(SearchOp, InsideDefAddr, SecondOpUseIter->GetSSANum(), false); assert(STARS_BADADDR != SecondOpDefAddr); int SecondOpDefBlockNum = SMP_BLOCKNUM_UNINIT; bool SecondOpDEFIsInst = false; @@ -8702,16 +8703,6 @@ void SMPFunction::AnalyzeSystemCalls(void) { if (!UnresolvedCallee) { // We have an instruction addr in EAXDefAddr. SMPInstr *EAXDefInst = this->GetInstFromAddr(EAXDefAddr); -#if 0 - STARSDefUseIter DefIter = EAXDefInst->FindDef(EAXOpnd); - assert(DefIter != EAXDefInst->GetLastDef()); - STARSOpndTypePtr DefOp = DefIter->GetOp(); - UnresolvedCallee = (!DefOp->IsImmedOp()); - if (!UnresolvedCallee) { - SysCallNumber = DefOp->GetImmedValue(); - SMP_msg("INFO: System call number %u found at %llx\n", (unsigned int)SysCallNumber, (unsigned long long) EAXDefAddr); - } -#else if (EAXDefInst == NULL) UnresolvedCallee = true; @@ -8745,7 +8736,6 @@ void SMPFunction::AnalyzeSystemCalls(void) { SMP_msg("INFO: System call set of EAX determined solid. number: %u at: %llx\n", (unsigned int) SysCallNumber, (unsigned long long) EAXDefAddr); } -#endif } if (!UnresolvedCallee) { // we have a good SysCallNumber #define CGC_RECEIVE_SYSCALL 3 diff --git a/src/base/SMPInstr.cpp b/src/base/SMPInstr.cpp index 3568ec28bd190b1a707a4ca27883a23942ca0eec..9ea2c8daf7f5a4113801d14eb7660b1915946bdb 100644 --- a/src/base/SMPInstr.cpp +++ b/src/base/SMPInstr.cpp @@ -3969,13 +3969,22 @@ bool SMPInstr::IsDependentInductionVarArithmetic(STARSOpndTypePtr &Mult1, STARSO STARS_ea_t offset; LeaOpnd->MDExtractAddressFields(BaseReg, IndexReg, Scale, offset); if (STARS_x86_R_none == IndexReg) { - // Simple case: Lhs := BaseReg + offset - STARS_uval_t ImmedValue = (STARS_uval_t) offset; - Add1 = this->MakeRegOpnd((STARS_regnum_t) BaseReg); - Add2 = this->MakeImmediateOpnd(ImmedValue); - Mult1 = nullptr; - Mult2 = nullptr; - DIVOperation = true; + if (STARS_x86_R_none != BaseReg) { + // Simple case: Lhs := BaseReg + offset + STARS_uval_t ImmedValue = (STARS_uval_t)offset; + Add1 = this->MakeRegOpnd((STARS_regnum_t)BaseReg); + Add2 = this->MakeImmediateOpnd(ImmedValue); + Mult1 = nullptr; + Mult2 = nullptr; + DIVOperation = true; + } + else { // both regs are null, e.g. PC-relative expression + Add1 = nullptr; + Add2 = nullptr; + Mult1 = nullptr; + Mult2 = nullptr; + DIVOperation = false; + } } else { STARS_uval_t ImmedValue = (STARS_uval_t) offset;