Skip to content
Snippets Groups Projects
Commit 71af0441 authored by clc5q's avatar clc5q
Browse files

Fixes for induction var analysis; code cleanup for cGC.

Former-commit-id: 0fb0ae8c5cc0841458a435d70e534a1dcd00a9b0
parent 536986e5
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment