summaryrefslogtreecommitdiffstats
path: root/llvm/unittests/CodeGen
diff options
context:
space:
mode:
authorEli Friedman <efriedma@quicinc.com>2019-06-01 00:08:54 +0000
committerEli Friedman <efriedma@quicinc.com>2019-06-01 00:08:54 +0000
commitd8e8722791e4ce6694673d450fdcaf99e5edcbf9 (patch)
treee56228779679241cfa465d5e72155f93d513d2da /llvm/unittests/CodeGen
parenteb4d6142dcd53d79d8f8a86908a035582965fc52 (diff)
downloadbcm5719-llvm-d8e8722791e4ce6694673d450fdcaf99e5edcbf9.tar.gz
bcm5719-llvm-d8e8722791e4ce6694673d450fdcaf99e5edcbf9.zip
[CodeGen] Fix hashing for MO_ExternalSymbol MachineOperands.
We were hashing the string pointer, not the string, so two instructions could be identical (isIdenticalTo), but have different hash codes. This showed up as a very rare, non-deterministic assertion failure rehashing a DenseMap constructed by MachineOutliner. So there's no "real" testcase, just a unittest which checks that the hash function behaves correctly. I'm a little scared fixing this is going to cause a regression in outlining or MachineCSE, but hopefully we won't run into any issues. Differential Revision: https://reviews.llvm.org/D61975 llvm-svn: 362281
Diffstat (limited to 'llvm/unittests/CodeGen')
-rw-r--r--llvm/unittests/CodeGen/MachineOperandTest.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/unittests/CodeGen/MachineOperandTest.cpp b/llvm/unittests/CodeGen/MachineOperandTest.cpp
index cfedfa9c883..faa471f2260 100644
--- a/llvm/unittests/CodeGen/MachineOperandTest.cpp
+++ b/llvm/unittests/CodeGen/MachineOperandTest.cpp
@@ -398,4 +398,14 @@ TEST(MachineOperandTest, PrintPredicate) {
ASSERT_TRUE(OS.str() == "intpred(eq)");
}
+TEST(MachineOperandTest, HashValue) {
+ char SymName1[] = "test";
+ char SymName2[] = "test";
+ MachineOperand MO1 = MachineOperand::CreateES(SymName1);
+ MachineOperand MO2 = MachineOperand::CreateES(SymName2);
+ ASSERT_NE(SymName1, SymName2);
+ ASSERT_EQ(hash_value(MO1), hash_value(MO2));
+ ASSERT_TRUE(MO1.isIdenticalTo(MO2));
+}
+
} // end namespace
OpenPOWER on IntegriCloud