+ @cached_property
+ def copy_related_ssa_vals(self):
+ # type: () -> FMap[SSAVal, OFSet[SSAVal]]
+ """ map from SSAVals to the full set of SSAVals that are related by
+ being sources/destinations of copies, transitively looking through all
+ copies.
+ This ignores inputs of copy Ops that aren't actually being copied
+ (e.g. the VL input of VecCopyToReg).
+ """
+ sets_map = {i: OSet([i]) for i in self.uses.keys()}
+ for k, v in self.copies.items():
+ k_set = sets_map[k.ssa_val]
+ v_set = sets_map[v.ssa_val]
+ # merge k_set and v_set
+ if k_set is v_set:
+ continue
+ k_set |= v_set
+ for i in k_set:
+ sets_map[i] = k_set
+ # this way we construct each OFSet only once rather than
+ # for each SSAVal
+ sets_set = {id(i): i for i in sets_map.values()}
+ retval = {} # type: dict[SSAVal, OFSet[SSAVal]]
+ for v in sets_set.values():
+ v = OFSet(v)
+ for k in v:
+ retval[k] = v
+ return FMap(retval)
+