зеркало из https://github.com/github/codeql.git
C++: Optimize SubBasicBlock::getNumberOfNodes()
This commit is contained in:
Родитель
c276d0b8ac
Коммит
be24c6418b
|
@ -76,7 +76,6 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
||||||
*/
|
*/
|
||||||
int getPosInBasicBlock(BasicBlock bb) {
|
int getPosInBasicBlock(BasicBlock bb) {
|
||||||
exists(int nodePos, int rnk |
|
exists(int nodePos, int rnk |
|
||||||
bb = this.(ControlFlowNode).getBasicBlock() and
|
|
||||||
this = bb.getNode(nodePos) and
|
this = bb.getNode(nodePos) and
|
||||||
nodePos = rank[rnk](int i | exists(SubBasicBlock n | n = bb.getNode(i))) and
|
nodePos = rank[rnk](int i | exists(SubBasicBlock n | n = bb.getNode(i))) and
|
||||||
result = rnk - 1
|
result = rnk - 1
|
||||||
|
@ -147,14 +146,20 @@ class SubBasicBlock extends ControlFlowNodeBase {
|
||||||
* Gets the number of control-flow nodes in this `SubBasicBlock`. There is
|
* Gets the number of control-flow nodes in this `SubBasicBlock`. There is
|
||||||
* always at least one.
|
* always at least one.
|
||||||
*/
|
*/
|
||||||
|
pragma[noopt]
|
||||||
int getNumberOfNodes() {
|
int getNumberOfNodes() {
|
||||||
exists(BasicBlock bb | bb = this.getBasicBlock() |
|
exists(BasicBlock bb | bb = this.getBasicBlock() |
|
||||||
exists(int thisPos | this = bb.getNode(thisPos) |
|
exists(int thisPos | this = bb.getNode(thisPos) |
|
||||||
|
exists(int bbLength |
|
||||||
this.lastInBB() and
|
this.lastInBB() and
|
||||||
result = bb.length() - thisPos
|
bbLength = bb.length() and
|
||||||
|
result = bbLength - thisPos
|
||||||
|
)
|
||||||
or
|
or
|
||||||
exists(SubBasicBlock succ, int succPos |
|
exists(SubBasicBlock succ, int succPos, int thisRank, int succRank |
|
||||||
succ.getPosInBasicBlock(bb) = this.getPosInBasicBlock(bb) + 1 and
|
thisRank = this.getPosInBasicBlock(bb) and
|
||||||
|
succRank = thisRank + 1 and
|
||||||
|
succRank = succ.getPosInBasicBlock(bb) and
|
||||||
bb.getNode(succPos) = succ and
|
bb.getNode(succPos) = succ and
|
||||||
result = succPos - thisPos
|
result = succPos - thisPos
|
||||||
)
|
)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче