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
56dc7fc6
Commit
56dc7fc6
authored
7 years ago
by
clc5q
Browse files
Options
Downloads
Patches
Plain Diff
Fix constant tracing for func ptrs and handle conditional move tracing.
Former-commit-id: 8b168e63aac8ff541f7a3e3899be1800087469d4
parent
cf0f5d4f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/base/SMPFunction.cpp
+47
-2
47 additions, 2 deletions
src/base/SMPFunction.cpp
with
47 additions
and
2 deletions
src/base/SMPFunction.cpp
+
47
−
2
View file @
56dc7fc6
...
...
@@ -13528,7 +13528,52 @@ bool SMPFunction::FindShadowingPoint2(const ShadowPoint CriticalOp, const bool T
break; // cannot follow chain any higher, but previous chain info is still valid.
}
STARSOpndTypePtr NewUseOp = nullptr;
if (!CurrInst->IsSimpleCopy(NewUseOp)) {
// If we have a conditional move instruction, then there will be two USEs. One is the
// operand that will be copied to the DEF if the condition is true, and the other is
// the operand that represents the unchanged DEF if the copy does not happen, e.g.
// if (guard) RDX5 := RAX3; will have USEs RAX3 and RDX4, where RDX4 is the value
// that becomes RDX5 when the guard is not true. We need to treat this instruction as
// a Phi DEF with two Phi USEs and trace both USEs.
if (CurrInst->MDIsConditionalMoveInstr()) {
// For each USE other than the flags register, recurse.
ShadowSet TempShadowAddrSet; // only union these into ShadowAddrSet if all Phi USE recursions succeed.
for (STARSDefUseIter UseIter = CurrInst->GetFirstUse(); UseIter != CurrInst->GetLastUse(); ++UseIter) {
int UseSSANum = UseIter->GetSSANum();
if (0 > UseSSANum) {
SMP_msg("ERROR: FindShadowingPoint2() cannot trace uninitialized CondMove USE at CurrShadowAddr %p in func at %p\n",
CurrShadowAddr, this->GetFirstFuncAddr());
ValidShadowing = false;
break;
}
STARSOpndTypePtr CondMoveUseOp = UseIter->GetOp()->clone();
bool FlagsReg = (CondMoveUseOp->IsRegOp() && (CondMoveUseOp->MatchesReg(MD_FLAGS_REG)));
if (!FlagsReg) {
this->TempShadowList.SetRef(CondMoveUseOp, UseIter->GetType(), UseSSANum);
ShadowPoint UsePoint(CurrShadowAddr, this->TempShadowList.GetSize() - 1);
ValidShadowing = this->FindShadowingPoint2(UsePoint, TracingMemWrite, TempShadowAddrSet, MemUnsafe, NewCriticalOps, NonConstSourceFound, ConstValues);
if (!ValidShadowing) {
break; // we must succeed on all conditional move USEs
}
}
}
if (ValidShadowing) { // All USEs succeeded
// Remove current CriticalOp from ShadowAddrSet (if present); let the UseOps logically take its place
ShadowSet::iterator OldIter = ShadowAddrSet.find(CriticalOp);
if (OldIter != ShadowAddrSet.end()) { // found it
OldIter = ShadowAddrSet.erase(OldIter);
}
// Insert the shadow points for all the USEs now that all USE recursions succeeded.
#if 0
ShadowAddrSet.insert(TempShadowAddrSet.begin(), TempShadowAddrSet.end());
#else
for (ShadowSet::const_iterator TempIter = TempShadowAddrSet.cbegin(); TempIter != TempShadowAddrSet.cend(); ++TempIter) {
pair<ShadowSet::iterator, bool> InsertResult = ShadowAddrSet.insert(*TempIter);
}
#endif
}
break; // success if ValidShadowing is true, failure otherwise
}
else if (!CurrInst->IsSimpleCopy(NewUseOp)) {
NonConstSourceFound = true;
// We could have something like [rsp+32] := [rsp+32] + 8.
// The DEF is the DEF of our CriticalOp, and we cannot trace any farther for this shadowing index.
...
...
@@ -13689,7 +13734,7 @@ bool SMPFunction::FindShadowingPoint2(const ShadowPoint CriticalOp, const bool T
}
else {
// Save in the set of constant values we traced back to.
pair<set<STARS_uval_t>::iterator, bool> InsertResult = ConstValues.insert(
ShadowCheck
UseOp->GetImmedValue());
pair<set<STARS_uval_t>::iterator, bool> InsertResult = ConstValues.insert(
New
UseOp->GetImmedValue());
assert(InsertResult.first != ConstValues.end());
}
break;
...
...
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