Skip to content
Snippets Groups Projects
Commit 8382f768 authored by Leon Weiss's avatar Leon Weiss
Browse files

Allow retrieval of sourceInstruction from TraceUltimateMoveSource

parent 533577ad
No related branches found
No related tags found
1 merge request!31Improve data source tracing
......@@ -1069,7 +1069,8 @@ public:
// Trace UseOp through register moves back to its stack location or immediate value source.
// Return true if we are passing an immediate or stack location back in UltSource.
bool TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSANum, STARSOpndTypePtr &UltSource, bool &FPRelative);
bool TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSANum, STARSOpndTypePtr &UltSource, bool &FPRelative);
bool TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSANum, STARSOpndTypePtr &UltSource, bool &FPRelative, SMPInstr* &SourceInstr);
bool HasNoCodeXrefs(void); // inst has no code xrefs
bool IsLoopExitStatement(bool &InvertedExit); // true => jump is used to exit a loop
inline bool AnalyzeSwitchInfo(struct SwitchTableInfo &TableInfo) { return STARSInstPtr->AnalyzeSwitchStatement(this, TableInfo); };
......
......@@ -14002,6 +14002,14 @@ void SMPInstr::SCCPFetchConstDefValue(const STARSOpndTypePtr &DefOp, STARS_SCCP_
// Trace UseOp through register moves back to its stack location or immediate value source.
// Return true if we are passing an immediate or stack location back in UltSource.
bool SMPInstr::TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSANum, STARSOpndTypePtr &UltSource, bool &FPRelative) {
SMPInstr *discard = nullptr;
return this->TraceUltimateMoveSource(UseOp, UseSSANum, UltSource, FPRelative, discard);
}
// Trace UseOp through register moves back to its stack location or immediate value source.
// Return true if we are passing an immediate or stack location back in UltSource.
// SourceInstr will contain the source instruction if we were able to find it. If not, it is set to nullptr
bool SMPInstr::TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSANum, STARSOpndTypePtr &UltSource, bool &FPRelative, SMPInstr* &SourceInstr) {
// If we hit an immediate value or a stack location, we are done.
bool UseFP = this->GetBlock()->GetFunc()->UsesFramePointer();
STARSOpndTypePtr DefOp = nullptr, ImmOp = nullptr;
......@@ -14011,18 +14019,21 @@ bool SMPInstr::TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSA
STARS_ea_t DefAddr;
SMPInstr *DefInst;
 
SourceInstr = nullptr;
UltSource = nullptr;
bool StackOp = MDIsDirectStackAccessOpnd(UseOp, UseFP);
bool RegisterOp = (UseOp->IsRegOp());
 
if (this->GetOptType() == 3) { // move instruction
if (UseOp->IsImmedOp()) {
SourceInstr = this;
UltSource = UseOp;
return true;
}
else if ((!RegisterOp) && (!StackOp)) {
// We only trace the move chain through registers or stack locations to an ultimate
// load-effective-address of a stack location, or a move of an immediate value.
SourceInstr = this;
return false;
}
}
......@@ -14074,6 +14085,7 @@ bool SMPInstr::TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSA
}
else if (DefInst->MDIsLoadEffectiveAddressInstr()) {
NewUseOp = DefInst->GetLeaMemUseOp();
SourceInstr = DefInst;
if (MDIsDirectStackAccessOpnd(NewUseOp, UseFP)) {
UltSource = NewUseOp;
FPRelative = DefInst->HasFPNormalizedToSP();
......@@ -14089,6 +14101,7 @@ bool SMPInstr::TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSA
// Case 1: A register is cleared. Same as assigning immediate value zero to the reg.
else if (DefInst->IsRegClearIdiom()) {
UltSource = this->STARSInstPtr->MakeImmediateOpnd(0);
SourceInstr = DefInst;
// why would we memset a zero byte region?
return true;
}
......@@ -14107,6 +14120,7 @@ bool SMPInstr::TraceUltimateMoveSource(const STARSOpndTypePtr &UseOp, int UseSSA
NewDefInst = DefInst->GetBlock()->GetFunc()->GetInstFromAddr(DefAddr);
if (NewDefInst->MDIsLoadEffectiveAddressInstr()) {
NewUseOp = NewDefInst->GetLeaMemUseOp()->clone();
SourceInstr = NewDefInst;
if (MDIsDirectStackAccessOpnd(NewUseOp, UseFP)) {
// We have the code sequence we were searching for when we first saw the
// addition of an immediate value to a register, e.g.:
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