Change Projection to support signed indices.

Change ProjectionIndex for ref_tail_addr to std::numeric_limits<int>::max();
This is necessary to disambiguate the tail elements from
ref_element_addr field zero.
This commit is contained in:
Andrew Trick
2020-04-05 18:51:43 -07:00
parent 7774f06f10
commit 2767b51d61
5 changed files with 52 additions and 52 deletions

View File

@@ -63,7 +63,7 @@ public:
/// Do not form a path with an IndexAddrInst because we have no way to
/// distinguish between indexing and subelement access. The same index could
/// either refer to the next element (indexed) or a subelement.
static SILValue getAccessPath(SILValue V, SmallVectorImpl<unsigned>& Path) {
static SILValue getAccessPath(SILValue V, SmallVectorImpl<int> &Path) {
V = stripCasts(V);
if (auto *IA = dyn_cast<IndexAddrInst>(V)) {
// Don't include index_addr projections in the access path. We could if
@@ -89,7 +89,7 @@ public:
VisitedSet Visited;
/// Collect all uses of the value at the given address.
void collectUses(ValueBase *V, ArrayRef<unsigned> AccessPath) {
void collectUses(ValueBase *V, ArrayRef<int> AccessPath) {
// Save our old indent and increment.
// Collect all users of the address and loads.
collectAddressUses(V, AccessPath, nullptr);
@@ -142,7 +142,7 @@ protected:
/// StructVal is invalid, then the value is the address of the Struct. If
/// StructVal is valid, the value is the address of an element within the
/// Struct.
void collectAddressUses(ValueBase *V, ArrayRef<unsigned> AccessPathSuffix,
void collectAddressUses(ValueBase *V, ArrayRef<int> AccessPathSuffix,
Operand *StructVal) {
for (auto *UI : V->getUses()) {
// Keep the operand, not the instruction in the visited set. The same