-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP][TA] Analyze out-of-BT func with tainted parameters #47
base: main
Are you sure you want to change the base?
Changes from 2 commits
1268452
7ea35b2
987712b
fe3565a
2bd22b9
10a9db9
231fed5
4eda5c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,7 +31,7 @@ void TaintDataFlowGraph::addEdge(std::shared_ptr<Node> src, | |
adjacencies[src.get()].push_back({dest.get(), e_type}); | ||
} | ||
|
||
void TaintDataFlowGraph::updateLastTaintedNode(TaintInfo Op, | ||
void TaintDataFlowGraph::updateLastTaintedNode(const MachineOperand *Op, | ||
std::shared_ptr<Node> N) { | ||
lastTaintedNode[Op] = N; | ||
} | ||
|
@@ -134,13 +134,19 @@ void TaintDataFlowGraph::findBlameFunction(Node *v) { | |
if (a->MI->getParent() == adjNode->MI->getParent() && | ||
!a->CallMI && !adjNode->CallMI) { | ||
if (MDT->dominates(adjNode->MI, a->MI)) { | ||
// Do not erase potential blame nodes. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why didn't you terminate in the begining of the loop (line 134) after? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree, I will move this condition to the beginning of the iteration. |
||
if (a->TaintOp.DerefLevel == 0 && a->IsContant) | ||
break; | ||
BlameNodes.erase(BlameNodes.begin() + i); | ||
break; | ||
} | ||
} else if (a->CallMI && !adjNode->CallMI) { | ||
MDT = dominators[a->CallMI->getMF()]; | ||
if (a->CallMI->getParent() == adjNode->MI->getParent()) { | ||
if (MDT->dominates(adjNode->MI, a->CallMI)) { | ||
// Do not erase potential blame nodes. | ||
if (a->TaintOp.DerefLevel == 0 && a->IsContant) | ||
break; | ||
BlameNodes.erase(BlameNodes.begin() + i); | ||
break; | ||
} | ||
|
@@ -149,6 +155,9 @@ void TaintDataFlowGraph::findBlameFunction(Node *v) { | |
MDT = dominators[adjNode->CallMI->getMF()]; | ||
if (a->MI->getParent() == adjNode->CallMI->getParent()) { | ||
if (MDT->dominates(adjNode->CallMI, a->MI)) { | ||
// Do not erase potential blame nodes. | ||
if (a->TaintOp.DerefLevel == 0 && a->IsContant) | ||
break; | ||
BlameNodes.erase(BlameNodes.begin() + i); | ||
break; | ||
} | ||
|
@@ -159,6 +168,9 @@ void TaintDataFlowGraph::findBlameFunction(Node *v) { | |
a->CallMI->getParent() == adjNode->CallMI->getParent()) { | ||
MDT = dominators[adjNode->CallMI->getMF()]; | ||
if (MDT->dominates(adjNode->CallMI, a->CallMI)) { | ||
// Do not erase potential blame nodes. | ||
if (a->TaintOp.DerefLevel == 0 && a->IsContant) | ||
break; | ||
BlameNodes.erase(BlameNodes.begin() + i); | ||
break; | ||
} | ||
|
@@ -196,12 +208,26 @@ bool TaintDataFlowGraph::printBlameFunction( | |
|
||
StringRef BlameFn = ""; | ||
const MachineFunction *MF = nullptr; | ||
auto &BlameNodes = blameNodes[MaxLevel]; | ||
auto &SortBlameNodes = blameNodes[MaxLevel]; | ||
llvm::SmallVector<StringRef, 8> BlameFns; | ||
llvm::SmallVector<MachineFunction *, 8> MFs; | ||
|
||
unsigned BlameLine = 0; | ||
unsigned BlameColumn = 0; | ||
// Sort blame Nodes by depth - descending. | ||
std::sort(SortBlameNodes.begin(), SortBlameNodes.end(), | ||
[](Node *n1, Node *n2) { return n1->Depth > n2->Depth; }); | ||
unsigned DepthLevel = 0; | ||
llvm::SmallVector<Node *, 8> BlameNodes; | ||
// Filter leaf nodes - consider zero DerefLevel and max depth. | ||
for (auto &n : SortBlameNodes) { | ||
if (n->TaintOp.DerefLevel != 0) | ||
continue; | ||
if (n->Depth < DepthLevel) | ||
break; | ||
DepthLevel = n->Depth; | ||
BlameNodes.push_back(n); | ||
} | ||
|
||
for (auto &a : BlameNodes) { | ||
// Only consider Node if it's DerefLevel is zero. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better return a reference to map instead of copying the entire map; no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Definitely, I missed this, thanks!