Lines 57-63
bool IsEntryBlock(const BasicBlock *BB) {
Link Here
|
57 |
} |
57 |
} |
58 |
|
58 |
|
59 |
void DxilValueCache::MarkUnreachable(BasicBlock *BB) { |
59 |
void DxilValueCache::MarkUnreachable(BasicBlock *BB) { |
60 |
ValueMap.Set(BB, ConstantInt::get(Type::getInt1Ty(BB->getContext()), 0)); |
60 |
Map.Set(BB, ConstantInt::get(Type::getInt1Ty(BB->getContext()), 0)); |
61 |
} |
61 |
} |
62 |
|
62 |
|
63 |
bool DxilValueCache::MayBranchTo(BasicBlock *A, BasicBlock *B) { |
63 |
bool DxilValueCache::MayBranchTo(BasicBlock *A, BasicBlock *B) { |
Lines 93-99
bool DxilValueCache::MayBranchTo(BasicBlock *A, BasicBlock *B) {
Link Here
|
93 |
} |
93 |
} |
94 |
|
94 |
|
95 |
bool DxilValueCache::IsUnreachable_(BasicBlock *BB) { |
95 |
bool DxilValueCache::IsUnreachable_(BasicBlock *BB) { |
96 |
if (Value *V = ValueMap.Get(BB)) |
96 |
if (Value *V = Map.Get(BB)) |
97 |
if (IsConstantFalse(V)) |
97 |
if (IsConstantFalse(V)) |
98 |
return true; |
98 |
return true; |
99 |
return false; |
99 |
return false; |
Lines 155-161
Value *DxilValueCache::ProcessAndSimplify_PHI(Instruction *I, DominatorTree *DT)
Link Here
|
155 |
// that were computed previously. |
155 |
// that were computed previously. |
156 |
if (!Simplified) { |
156 |
if (!Simplified) { |
157 |
if (SimplifiedNotDominating) |
157 |
if (SimplifiedNotDominating) |
158 |
if (Value *CachedV = ValueMap.Get(SimplifiedNotDominating)) |
158 |
if (Value *CachedV = Map.Get(SimplifiedNotDominating)) |
159 |
Simplified = CachedV; |
159 |
Simplified = CachedV; |
160 |
} |
160 |
} |
161 |
|
161 |
|
Lines 379-385
Value *DxilValueCache::SimplifyAndCacheResult(Instruction *I, DominatorTree *DT)
Link Here
|
379 |
} |
379 |
} |
380 |
|
380 |
|
381 |
if (Simplified && isa<Constant>(Simplified)) |
381 |
if (Simplified && isa<Constant>(Simplified)) |
382 |
ValueMap.Set(I, Simplified); |
382 |
Map.Set(I, Simplified); |
383 |
|
383 |
|
384 |
return Simplified; |
384 |
return Simplified; |
385 |
} |
385 |
} |
Lines 500-506
void DxilValueCache::WeakValueMap::Set(Value *Key, Value *V) {
Link Here
|
500 |
// If there's a cached value, return it. Otherwise, return |
500 |
// If there's a cached value, return it. Otherwise, return |
501 |
// the value itself. |
501 |
// the value itself. |
502 |
Value *DxilValueCache::TryGetCachedValue(Value *V) { |
502 |
Value *DxilValueCache::TryGetCachedValue(Value *V) { |
503 |
if (Value *Simplified = ValueMap.Get(V)) |
503 |
if (Value *Simplified = Map.Get(V)) |
504 |
return Simplified; |
504 |
return Simplified; |
505 |
return V; |
505 |
return V; |
506 |
} |
506 |
} |
Lines 516-522
StringRef DxilValueCache::getPassName() const {
Link Here
|
516 |
Value *DxilValueCache::GetValue(Value *V, DominatorTree *DT) { |
516 |
Value *DxilValueCache::GetValue(Value *V, DominatorTree *DT) { |
517 |
if (dyn_cast<Constant>(V)) |
517 |
if (dyn_cast<Constant>(V)) |
518 |
return V; |
518 |
return V; |
519 |
if (Value *NewV = ValueMap.Get(V)) |
519 |
if (Value *NewV = Map.Get(V)) |
520 |
return NewV; |
520 |
return NewV; |
521 |
|
521 |
|
522 |
return ProcessValue(V, DT); |
522 |
return ProcessValue(V, DT); |
Lines 541-547
bool DxilValueCache::IsUnreachable(BasicBlock *BB, DominatorTree *DT) {
Link Here
|
541 |
|
541 |
|
542 |
LLVM_DUMP_METHOD |
542 |
LLVM_DUMP_METHOD |
543 |
void DxilValueCache::dump() const { |
543 |
void DxilValueCache::dump() const { |
544 |
ValueMap.dump(); |
544 |
Map.dump(); |
545 |
} |
545 |
} |
546 |
|
546 |
|
547 |
void DxilValueCache::getAnalysisUsage(AnalysisUsage &AU) const { |
547 |
void DxilValueCache::getAnalysisUsage(AnalysisUsage &AU) const { |
Lines 580-594
Value *DxilValueCache::ProcessValue(Value *NewV, DominatorTree *DT) {
Link Here
|
580 |
|
580 |
|
581 |
// If we haven't seen this value, go in and push things it depends on |
581 |
// If we haven't seen this value, go in and push things it depends on |
582 |
// into the worklist. |
582 |
// into the worklist. |
583 |
if (!ValueMap.Seen(V)) { |
583 |
if (!Map.Seen(V)) { |
584 |
ValueMap.SetSentinel(V); |
584 |
Map.SetSentinel(V); |
585 |
if (Instruction *I = dyn_cast<Instruction>(V)) { |
585 |
if (Instruction *I = dyn_cast<Instruction>(V)) { |
586 |
|
586 |
|
587 |
for (Use &U : I->operands()) { |
587 |
for (Use &U : I->operands()) { |
588 |
Instruction *UseI = dyn_cast<Instruction>(U.get()); |
588 |
Instruction *UseI = dyn_cast<Instruction>(U.get()); |
589 |
if (!UseI) |
589 |
if (!UseI) |
590 |
continue; |
590 |
continue; |
591 |
if (!ValueMap.Seen(UseI)) |
591 |
if (!Map.Seen(UseI)) |
592 |
WorkList.push_back(UseI); |
592 |
WorkList.push_back(UseI); |
593 |
} |
593 |
} |
594 |
|
594 |
|
Lines 596-604
Value *DxilValueCache::ProcessValue(Value *NewV, DominatorTree *DT) {
Link Here
|
596 |
for (unsigned i = 0; i < PN->getNumIncomingValues(); i++) { |
596 |
for (unsigned i = 0; i < PN->getNumIncomingValues(); i++) { |
597 |
BasicBlock *BB = PN->getIncomingBlock(i); |
597 |
BasicBlock *BB = PN->getIncomingBlock(i); |
598 |
TerminatorInst *Term = BB->getTerminator(); |
598 |
TerminatorInst *Term = BB->getTerminator(); |
599 |
if (!ValueMap.Seen(Term)) |
599 |
if (!Map.Seen(Term)) |
600 |
WorkList.push_back(Term); |
600 |
WorkList.push_back(Term); |
601 |
if (!ValueMap.Seen(BB)) |
601 |
if (!Map.Seen(BB)) |
602 |
WorkList.push_back(BB); |
602 |
WorkList.push_back(BB); |
603 |
} |
603 |
} |
604 |
} |
604 |
} |
Lines 607-615
Value *DxilValueCache::ProcessValue(Value *NewV, DominatorTree *DT) {
Link Here
|
607 |
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; PI++) { |
607 |
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; PI++) { |
608 |
BasicBlock *PredBB = *PI; |
608 |
BasicBlock *PredBB = *PI; |
609 |
TerminatorInst *Term = PredBB->getTerminator(); |
609 |
TerminatorInst *Term = PredBB->getTerminator(); |
610 |
if (!ValueMap.Seen(Term)) |
610 |
if (!Map.Seen(Term)) |
611 |
WorkList.push_back(Term); |
611 |
WorkList.push_back(Term); |
612 |
if (!ValueMap.Seen(PredBB)) |
612 |
if (!Map.Seen(PredBB)) |
613 |
WorkList.push_back(PredBB); |
613 |
WorkList.push_back(PredBB); |
614 |
} |
614 |
} |
615 |
} |
615 |
} |