Skip to content

Commit fdb5206

Browse files
committed
SIL: fix the hash function for Projection
The hash function didn't take the "index" of an projection into account. This lead to quadratic behavior in redundant load elimination and dead store elimination when compiling very large functions with many loads and stores. rdar://problem/56268570
1 parent 3a317b3 commit fdb5206

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/swift/SIL/Projection.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ class Projection {
255255
unsigned getIndex() const {
256256
return Value.getIndex();
257257
}
258+
259+
unsigned getHash() const { return (unsigned)Value.getStorage(); }
258260

259261
/// Determine if I is a value projection instruction whose corresponding
260262
/// projection equals this projection.
@@ -689,7 +691,7 @@ static inline llvm::hash_code hash_value(const ProjectionPath &P) {
689691

690692
/// Returns the hashcode for the projection path.
691693
static inline llvm::hash_code hash_value(const Projection &P) {
692-
return llvm::hash_combine(static_cast<unsigned>(P.getKind()));
694+
return llvm::hash_combine(P.getHash());
693695
}
694696

695697
class ProjectionTree;

0 commit comments

Comments
 (0)