-
Notifications
You must be signed in to change notification settings - Fork 155
Expand file tree
/
Copy pathBasicBlockOrdering.cpp
More file actions
41 lines (32 loc) · 1020 Bytes
/
BasicBlockOrdering.cpp
File metadata and controls
41 lines (32 loc) · 1020 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include "phasar/PhasarLLVM/Utils/BasicBlockOrdering.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instruction.h"
#include <array>
namespace psr {
llvm::DominatorTree &
DefaultDominatorTreeAnalysis::operator()(const llvm::Function *F) {
auto &Ret = Dom[F];
if (!Ret) {
Ret = std::make_unique<llvm::DominatorTree>(
*const_cast<llvm::Function *> // NOLINT - ugly, FIXME when llvm fixes it
(F));
}
return *Ret;
}
bool BasicBlockOrdering::mustComeBefore(const llvm::Instruction *LHS,
const llvm::Instruction *RHS) {
assert(LHS);
assert(RHS);
if (LHS->getFunction() != RHS->getFunction()) {
// We don't want the complexity of computing a dominator tree over the
// call-graph...
return false;
}
if (LHS->getParent() == RHS->getParent()) {
return LHS->comesBefore(RHS);
}
return getDom(LHS->getFunction()).dominates(LHS, RHS);
}
} // namespace psr