|
28 | 28 |
|
29 | 29 | using namespace swift;
|
30 | 30 |
|
31 |
| -using SILValueSet = llvm::DenseSet<SILValue>; |
32 |
| -using SILValueList = llvm::SmallVector<SILValue, 8>; |
33 |
| - |
34 | 31 | //===----------------------------------------------------------------------===//
|
35 | 32 | // AA Debugging
|
36 | 33 | //===----------------------------------------------------------------------===//
|
@@ -102,80 +99,6 @@ llvm::raw_ostream &swift::operator<<(llvm::raw_ostream &OS,
|
102 | 99 | }
|
103 | 100 | }
|
104 | 101 |
|
105 |
| -/// Return true if the SILValue is the result of multiple SILValues, e.g. |
106 |
| -/// select_enum, silargument. |
107 |
| -static bool isMultiUnderlyingObjectValue(SILValue V) { |
108 |
| - if (isa<SelectEnumInst>(V)) |
109 |
| - return true; |
110 |
| - // We are only interested in basic block SILArguments as those are the |
111 |
| - // ones we can collect all the possible incoming values. |
112 |
| - if (auto *SA = dyn_cast<SILArgument>(V)) |
113 |
| - if (!SA->isFunctionArg()) |
114 |
| - return true; |
115 |
| - return false; |
116 |
| -} |
117 |
| - |
118 |
| -/// Get the first level underlying objects, e.g. in case of select_enum, |
119 |
| -/// look to the possible underlying objects from all the cases. |
120 |
| -static bool getFirstLevelUnderlyingObjects(SILValue V, SILValueSet &Cache, |
121 |
| - SILValueList &WorkList) { |
122 |
| - // Look through SILArgument. |
123 |
| - if (auto *SA = dyn_cast<SILArgument>(V)) { |
124 |
| - SILValueList Args; |
125 |
| - bool Succ = SA->getIncomingValues(Args); |
126 |
| - // Unable to get SILValue for every predecessor. |
127 |
| - if (!Succ) |
128 |
| - return false; |
129 |
| - for (auto &X : Args) { |
130 |
| - if (Cache.count(X)) |
131 |
| - continue; |
132 |
| - // We have not seen this SILValue before. |
133 |
| - Cache.insert(X); |
134 |
| - WorkList.push_back(X); |
135 |
| - } |
136 |
| - } |
137 |
| - |
138 |
| - // Look through SelectEnumInst. |
139 |
| - if (auto *SE = dyn_cast<SelectEnumInst>(V)) { |
140 |
| - unsigned CaseNum = SE->getNumCases(); |
141 |
| - for (unsigned i = 0; i < CaseNum; ++i) { |
142 |
| - SILValue C = SE->getCase(i).second; |
143 |
| - if (Cache.count(C)) |
144 |
| - continue; |
145 |
| - // We have not seen this SILValue before. |
146 |
| - Cache.insert(C); |
147 |
| - WorkList.push_back(C); |
148 |
| - } |
149 |
| - } |
150 |
| - return true; |
151 |
| -} |
152 |
| - |
153 |
| -/// Collect all the underlying objects for the given SILValue. Return false |
154 |
| -/// if fail to collect all possible underlying objects. |
155 |
| -static bool getTransistiveUnderlyingObjects(SILValue V, SILValueList &Objs) { |
156 |
| - // Cache keeps track of what has been processed, so that we do not collected |
157 |
| - // it again. |
158 |
| - SILValueSet Cache; |
159 |
| - SILValueList WorkList; |
160 |
| - |
161 |
| - // Start with the given SILValue. |
162 |
| - WorkList.push_back(V); |
163 |
| - while(!WorkList.empty()) { |
164 |
| - SILValue V = WorkList.pop_back_val(); |
165 |
| - if (isMultiUnderlyingObjectValue(V)) { |
166 |
| - if (getFirstLevelUnderlyingObjects(V, Cache, WorkList)) |
167 |
| - continue; |
168 |
| - // Failed to get all possible underlying value, bail out. |
169 |
| - return false; |
170 |
| - } |
171 |
| - |
172 |
| - // This is single base SILValue. |
173 |
| - Objs.push_back(V); |
174 |
| - Cache.insert(V); |
175 |
| - } |
176 |
| - return true; |
177 |
| -} |
178 |
| - |
179 | 102 | //===----------------------------------------------------------------------===//
|
180 | 103 | // Unequal Base Object AA
|
181 | 104 | //===----------------------------------------------------------------------===//
|
@@ -604,37 +527,6 @@ static bool typesMayAlias(SILType T1, SILType T2, SILType TBAA1Ty,
|
604 | 527 | // Entry Points
|
605 | 528 | //===----------------------------------------------------------------------===//
|
606 | 529 |
|
607 |
| -AliasAnalysis::AliasResult |
608 |
| -AliasAnalysis::handleMultiUnderlyingObjectAlias(SILValue V1, SILValue V2) { |
609 |
| - const unsigned AliasQueryLimit = 16; |
610 |
| - SmallVector<SILValue, 8> V1Base, V2Base; |
611 |
| - // Collect the transistive closure of all the SILValue V1 and V2 can |
612 |
| - // point to. If for some reason we can not collect all the possible |
613 |
| - // underlying objects, return MayAlias to be conservative. |
614 |
| - if (!getTransistiveUnderlyingObjects(V1, V1Base) || |
615 |
| - !getTransistiveUnderlyingObjects(V2, V2Base)) |
616 |
| - return AliasResult::MayAlias; |
617 |
| - |
618 |
| - // An mxn alias analysis query, bail out if this results in too many |
619 |
| - // alias queries. |
620 |
| - if (V1Base.size() * V2Base.size() > AliasQueryLimit) |
621 |
| - return AliasResult::MayAlias; |
622 |
| - |
623 |
| - // Return MayAlias if any pair does not have a NoAlias relation. |
624 |
| - for (auto &M : V1Base) { |
625 |
| - for (auto &N : V2Base) { |
626 |
| - AliasAnalysis::AliasResult R = aliasInner(M, N, findTypedAccessType(M), |
627 |
| - findTypedAccessType(N)); |
628 |
| - // Return MayAlias whenever we have 1 non-NoAlias pair. This is a |
629 |
| - // tradeoff between compilation time and being conservative. |
630 |
| - if (R != AliasResult::NoAlias) |
631 |
| - return AliasResult::MayAlias; |
632 |
| - } |
633 |
| - } |
634 |
| - |
635 |
| - return AliasResult::NoAlias; |
636 |
| -} |
637 |
| - |
638 | 530 | /// The main AA entry point. Performs various analyses on V1, V2 in an attempt
|
639 | 531 | /// to disambiguate the two values.
|
640 | 532 | AliasAnalysis::AliasResult AliasAnalysis::alias(SILValue V1, SILValue V2,
|
@@ -697,13 +589,8 @@ AliasAnalysis::AliasResult AliasAnalysis::aliasInner(SILValue V1, SILValue V2,
|
697 | 589 | }
|
698 | 590 | }
|
699 | 591 |
|
700 |
| - // Ok, we need to actually compute an Alias Analysis result for V1, V2. First |
701 |
| - // find whether V1, V2 potentially have multiple underlying objects. |
702 |
| - if (isMultiUnderlyingObjectValue(V1) || isMultiUnderlyingObjectValue(V2)) |
703 |
| - return handleMultiUnderlyingObjectAlias(V1, V2); |
704 |
| - |
705 |
| - // At this point, V1 and V2 are both single base SIlValues, begin by |
706 |
| - // finding the "base" of V1, V2 by stripping off all casts and GEPs. |
| 592 | + // Ok, we need to actually compute an Alias Analysis result for V1, V2. Begin |
| 593 | + // by finding the "base" of V1, V2 by stripping off all casts and GEPs. |
707 | 594 | SILValue O1 = getUnderlyingObject(V1);
|
708 | 595 | SILValue O2 = getUnderlyingObject(V2);
|
709 | 596 | DEBUG(llvm::dbgs() << " Underlying V1:" << *O1.getDef());
|
@@ -739,7 +626,6 @@ AliasAnalysis::AliasResult AliasAnalysis::aliasInner(SILValue V1, SILValue V2,
|
739 | 626 | return AliasResult::MayAlias;
|
740 | 627 | }
|
741 | 628 |
|
742 |
| - |
743 | 629 | /// Check if this is the address of a "let" member.
|
744 | 630 | /// Nobody can write into let members.
|
745 | 631 | bool swift::isLetPointer(SILValue V) {
|
|
0 commit comments