Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
SMPStaticAnalyzer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Open Source Software
SMPStaticAnalyzer
Commits
8382f768
Commit
8382f768
authored
1 year ago
by
Leon Weiss
Browse files
Options
Downloads
Patches
Plain Diff
Allow retrieval of sourceInstruction from TraceUltimateMoveSource
parent
533577ad
No related branches found
No related tags found
1 merge request
!31
Improve data source tracing
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/base/SMPInstr.h
+2
-1
2 additions, 1 deletion
include/base/SMPInstr.h
src/base/SMPInstr.cpp
+14
-0
14 additions, 0 deletions
src/base/SMPInstr.cpp
with
16 additions
and
1 deletion
include/base/SMPInstr.h
+
2
−
1
View file @
8382f768
...
...
@@ -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
);
};
...
...
This diff is collapsed.
Click to expand it.
src/base/SMPInstr.cpp
+
14
−
0
View file @
8382f768
...
...
@@ -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.:
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment