RLE: better handling of ref_element/tail_addr [immutable]

Rerun RLE with cutting off the base address of loads at `ref_element/tail_addr [immutable]`. This increases the chance of catching loads of immutable COW class properties or elements.
This commit is contained in:
Erik Eckstein
2021-11-24 16:32:52 +01:00
parent b89f58de6d
commit f97876c9e7
7 changed files with 131 additions and 49 deletions

View File

@@ -379,21 +379,37 @@ public:
static void reduce(LSLocation Base, SILModule *Mod,
TypeExpansionContext context, LSLocationList &Locs);
/// Gets the base address for `v`.
/// If `stopAtImmutable` is true, the base address is only calculated up to
/// a `ref_element_addr [immutable]` or a `ref_tail_addr [immutable]`.
/// Return the base address and true if such an immutable class projection
/// is found.
static std::pair<SILValue, bool>
getBaseAddressOrObject(SILValue v, bool stopAtImmutable);
/// Enumerate the given Mem LSLocation.
static void enumerateLSLocation(TypeExpansionContext context, SILModule *M,
/// If `stopAtImmutable` is true, the base address is only calculated up to
/// a `ref_element_addr [immutable]` or a `ref_tail_addr [immutable]`.
/// Returns true if it's an immutable location.
static bool enumerateLSLocation(TypeExpansionContext context, SILModule *M,
SILValue Mem,
std::vector<LSLocation> &LSLocationVault,
LSLocationIndexMap &LocToBit,
LSLocationBaseMap &BaseToLoc,
TypeExpansionAnalysis *TE);
TypeExpansionAnalysis *TE,
bool stopAtImmutable);
/// Enumerate all the locations in the function.
/// If `stopAtImmutable` is true, the base addresses are only calculated up to
/// a `ref_element_addr [immutable]` or a `ref_tail_addr [immutable]`.
static void enumerateLSLocations(SILFunction &F,
std::vector<LSLocation> &LSLocationVault,
LSLocationIndexMap &LocToBit,
LSLocationBaseMap &BaseToLoc,
TypeExpansionAnalysis *TE,
std::pair<int, int> &LSCount);
bool stopAtImmutable,
int &numLoads, int &numStores,
bool &immutableLoadsFound);
};
static inline llvm::hash_code hash_value(const LSLocation &L) {