summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/MachineInstr.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-07-05 10:03:57 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-07-05 10:03:57 +0000
commit1d5d23106e5a04db410b3cedb4552ec0808d9bd0 (patch)
tree8f612ea109a5e9778207f0514cb27baeba8e4233 /llvm/lib/CodeGen/MachineInstr.cpp
parent0552a2cad2f4eb3c4159e4b04e94c692417e91c5 (diff)
downloadbcm5719-llvm-1d5d23106e5a04db410b3cedb4552ec0808d9bd0.tar.gz
bcm5719-llvm-1d5d23106e5a04db410b3cedb4552ec0808d9bd0.zip
The hash function for MI expressions, used by MachineCSE, is really
broken. This patch fixes the superficial problems which lead to the intractably slow compile times reported in PR13225. The specific issue is that we were failing to include the *offset* of a global variable in the hash code. Oops. This would in turn cause all MIs which were only distinguishable due to operating on different offsets of a global variable to produce identical hash functions. In some of the test cases attached to the PR I saw hash table activity where there were O(1000) probes-per-lookup *on average*. A very few entries were responsible for most of these probes. There is still quite a bit more to do here. The ad-hoc layering of data in MachineOperands makes them *extremely* brittle to hash correctly. We're missing quite a few other cases, the only ones I've fixed here are the specific MO types which were allowed through the assert() in getOffset(). llvm-svn: 159741
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r--llvm/lib/CodeGen/MachineInstr.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp
index 85b5e398646..0ee0213d9a4 100644
--- a/llvm/lib/CodeGen/MachineInstr.cpp
+++ b/llvm/lib/CodeGen/MachineInstr.cpp
@@ -1882,19 +1882,24 @@ MachineInstrExpressionTrait::getHashValue(const MachineInstr* const &MI) {
HashComponents.push_back(hash_combine(MO.getType(), MO.getImm()));
break;
case MachineOperand::MO_FrameIndex:
- case MachineOperand::MO_ConstantPoolIndex:
case MachineOperand::MO_JumpTableIndex:
HashComponents.push_back(hash_combine(MO.getType(), MO.getIndex()));
break;
+ case MachineOperand::MO_ConstantPoolIndex:
+ HashComponents.push_back(hash_combine(MO.getType(), MO.getIndex(),
+ MO.getOffset()));
+ break;
case MachineOperand::MO_MachineBasicBlock:
HashComponents.push_back(hash_combine(MO.getType(), MO.getMBB()));
break;
case MachineOperand::MO_GlobalAddress:
- HashComponents.push_back(hash_combine(MO.getType(), MO.getGlobal()));
+ HashComponents.push_back(hash_combine(MO.getType(), MO.getGlobal(),
+ MO.getOffset()));
break;
case MachineOperand::MO_BlockAddress:
HashComponents.push_back(hash_combine(MO.getType(),
- MO.getBlockAddress()));
+ MO.getBlockAddress(),
+ MO.getOffset()));
break;
case MachineOperand::MO_MCSymbol:
HashComponents.push_back(hash_combine(MO.getType(), MO.getMCSymbol()));
OpenPOWER on IntegriCloud