mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 20:23:59 +00:00
Only recalculate DFS Numbers if invalid. Invalidate DFS numbers on reset. Add unit test to verify recalculation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234933 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -243,6 +243,8 @@ protected:
|
|||||||
this->Roots.clear();
|
this->Roots.clear();
|
||||||
Vertex.clear();
|
Vertex.clear();
|
||||||
RootNode = nullptr;
|
RootNode = nullptr;
|
||||||
|
DFSInfoValid = false;
|
||||||
|
SlowQueries = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewBB is split and now it has one successor. Update dominator tree to
|
// NewBB is split and now it has one successor. Update dominator tree to
|
||||||
@ -663,6 +665,12 @@ public:
|
|||||||
/// updateDFSNumbers - Assign In and Out numbers to the nodes while walking
|
/// updateDFSNumbers - Assign In and Out numbers to the nodes while walking
|
||||||
/// dominator tree in dfs order.
|
/// dominator tree in dfs order.
|
||||||
void updateDFSNumbers() const {
|
void updateDFSNumbers() const {
|
||||||
|
|
||||||
|
if (DFSInfoValid) {
|
||||||
|
SlowQueries = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned DFSNum = 0;
|
unsigned DFSNum = 0;
|
||||||
|
|
||||||
SmallVector<std::pair<const DomTreeNodeBase<NodeT> *,
|
SmallVector<std::pair<const DomTreeNodeBase<NodeT> *,
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "llvm/IR/Dominators.h"
|
#include "llvm/IR/Dominators.h"
|
||||||
#include "llvm/Analysis/PostDominators.h"
|
#include "llvm/Analysis/PostDominators.h"
|
||||||
#include "llvm/AsmParser/Parser.h"
|
#include "llvm/AsmParser/Parser.h"
|
||||||
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/Instructions.h"
|
#include "llvm/IR/Instructions.h"
|
||||||
#include "llvm/IR/LLVMContext.h"
|
#include "llvm/IR/LLVMContext.h"
|
||||||
#include "llvm/IR/Module.h"
|
#include "llvm/IR/Module.h"
|
||||||
@ -174,6 +175,33 @@ namespace llvm {
|
|||||||
EXPECT_EQ(DominatedBBs.size(), 0UL);
|
EXPECT_EQ(DominatedBBs.size(), 0UL);
|
||||||
EXPECT_EQ(PostDominatedBBs.size(), 0UL);
|
EXPECT_EQ(PostDominatedBBs.size(), 0UL);
|
||||||
|
|
||||||
|
// Check DFS Numbers before
|
||||||
|
EXPECT_EQ(DT->getNode(BB0)->getDFSNumIn(), 0UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB0)->getDFSNumOut(), 7UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB1)->getDFSNumIn(), 1UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB1)->getDFSNumOut(), 2UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB2)->getDFSNumIn(), 5UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB2)->getDFSNumOut(), 6UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB4)->getDFSNumIn(), 3UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB4)->getDFSNumOut(), 4UL);
|
||||||
|
|
||||||
|
// Reattach block 3 to block 1 and recalculate
|
||||||
|
BB1->getTerminator()->eraseFromParent();
|
||||||
|
BranchInst::Create(BB4, BB3, ConstantInt::getTrue(F.getContext()), BB1);
|
||||||
|
DT->recalculate(F);
|
||||||
|
|
||||||
|
// Check DFS Numbers after
|
||||||
|
EXPECT_EQ(DT->getNode(BB0)->getDFSNumIn(), 0UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB0)->getDFSNumOut(), 9UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB1)->getDFSNumIn(), 1UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB1)->getDFSNumOut(), 4UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB2)->getDFSNumIn(), 7UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB2)->getDFSNumOut(), 8UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB3)->getDFSNumIn(), 2UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB3)->getDFSNumOut(), 3UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB4)->getDFSNumIn(), 5UL);
|
||||||
|
EXPECT_EQ(DT->getNode(BB4)->getDFSNumOut(), 6UL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
void getAnalysisUsage(AnalysisUsage &AU) const override {
|
||||||
|
Reference in New Issue
Block a user