The DenseMap doesn't store hash results. This means that when it is resized it has to recompute them.
This patch is a small hack that wraps the StringRef in a struct that remembers the hash value. That way we can be sure it is only hashed once.
This gives at least a small speedup in every testcase. The largest win is in a fast link (no icf, no gc sections) of chromium. The link goes from 1.821525390 to 1.740146930 seconds.
Do you have to use DenseMapInfo<StringRef>::getHashValue? I'd just use llvm::hash_value.