Go to the documentation of this file.
16 void PhiValues::PhiValuesCallbackVH::deleted() {
17 PV->invalidateValue(getValPtr());
20 void PhiValues::PhiValuesCallbackVH::allUsesReplacedWith(
Value *) {
23 PV->invalidateValue(getValPtr());
49 void PhiValues::processPhi(
const PHINode *Phi,
52 assert(DepthMap.lookup(Phi) == 0);
53 assert(NextDepthNumber != UINT_MAX);
54 unsigned int RootDepthNumber = ++NextDepthNumber;
55 DepthMap[Phi] = RootDepthNumber;
58 TrackedValues.insert(PhiValuesCallbackVH(
const_cast<PHINode *
>(Phi),
this));
60 if (
PHINode *PhiPhiOp = dyn_cast<PHINode>(PhiOp)) {
62 unsigned int OpDepthNumber = DepthMap.lookup(PhiPhiOp);
63 if (OpDepthNumber == 0) {
64 processPhi(PhiPhiOp, Stack);
65 OpDepthNumber = DepthMap.lookup(PhiPhiOp);
66 assert(OpDepthNumber != 0);
70 if (!ReachableMap.count(OpDepthNumber))
71 DepthMap[Phi] =
std::min(DepthMap[Phi], OpDepthNumber);
73 TrackedValues.insert(PhiValuesCallbackVH(PhiOp,
this));
82 if (DepthMap[Phi] == RootDepthNumber) {
86 ConstValueSet &Reachable = ReachableMap[RootDepthNumber];
89 Reachable.insert(ComponentPhi);
92 if (
PHINode *PhiOp = dyn_cast<PHINode>(
Op)) {
97 unsigned int OpDepthNumber = DepthMap[PhiOp];
98 if (OpDepthNumber != RootDepthNumber) {
99 auto It = ReachableMap.find(OpDepthNumber);
100 if (It != ReachableMap.end())
101 Reachable.insert(It->second.begin(), It->second.end());
104 Reachable.insert(
Op);
110 unsigned int &ComponentDepthNumber = DepthMap[
Stack.back()];
111 if (ComponentDepthNumber < RootDepthNumber)
114 ComponentDepthNumber = RootDepthNumber;
118 ValueSet &NonPhi = NonPhiReachableMap[RootDepthNumber];
119 for (
const Value *V : Reachable)
120 if (!isa<PHINode>(V))
121 NonPhi.insert(
const_cast<Value *
>(V));
126 unsigned int DepthNumber = DepthMap.lookup(PN);
127 if (DepthNumber == 0) {
129 processPhi(PN, Stack);
130 DepthNumber = DepthMap.lookup(PN);
134 return NonPhiReachableMap[DepthNumber];
140 for (
auto &Pair : ReachableMap)
141 if (Pair.second.count(V))
142 InvalidComponents.push_back(Pair.first);
144 for (
unsigned int N : InvalidComponents) {
145 for (
const Value *V : ReachableMap[
N])
146 if (
const PHINode *PN = dyn_cast<PHINode>(V))
148 NonPhiReachableMap.erase(
N);
149 ReachableMap.erase(
N);
152 auto It = TrackedValues.find_as(V);
153 if (It != TrackedValues.end())
154 TrackedValues.erase(It);
159 NonPhiReachableMap.clear();
160 ReachableMap.clear();
169 PN.printAsOperand(OS,
false);
170 OS <<
" has values:\n";
171 unsigned int N = DepthMap.lookup(&PN);
172 auto It = NonPhiReachableMap.find(
N);
173 if (It == NonPhiReachableMap.end())
175 else if (It->second.empty())
178 for (
Value *V : It->second)
185 OS <<
" " << *V <<
"\n";
197 OS <<
"PHI Values for function: " <<
F.getName() <<
"\n";
216 Result->releaseMemory();
A set of analyses that are preserved following a run of a transformation pass.
bool invalidate(Function &, const PreservedAnalyses &, FunctionAnalysisManager::Invalidator &)
Handle invalidation events in the new pass manager.
This is an optimization pass for GlobalISel generic memory operations.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
op_range incoming_values()
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
SmallSetVector< Value *, 4 > ValueSet
void print(raw_ostream &OS) const
Print out the values currently in the cache.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
Wrapper pass for the legacy pass manager.
void initializePhiValuesWrapperPassPass(PassRegistry &)
LLVM Basic Block Representation.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
PhiValues run(Function &F, FunctionAnalysisManager &)
bool runOnFunction(Function &F) override
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
void releaseMemory()
Free the memory used by this class.
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Represent the analysis usage information of a pass.
This class implements an extremely fast bulk output stream that can only output to a stream.
API to communicate dependencies between analyses during invalidation.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
const ValueSet & getValuesForPhi(const PHINode *PN)
Get the underlying values of a phi.
A special type used by analysis passes to provide an address that identifies that particular analysis...
The analysis pass which yields a PhiValues.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Expected< ExpressionValue > min(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
void setPreservesAll()
Set by analyses that do not transform their input at all.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void invalidateValue(const Value *V)
Notify PhiValues that the cached information using V is no longer valid.
Class for calculating and caching the underlying values of phis in a function.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
A SetVector that performs no allocations if smaller than a certain size.
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
LLVM Value Representation.