Index: lib/CodeGen/MachineOperand.cpp =================================================================== --- lib/CodeGen/MachineOperand.cpp +++ lib/CodeGen/MachineOperand.cpp @@ -348,7 +348,7 @@ return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getIndex()); case MachineOperand::MO_ExternalSymbol: return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getOffset(), - MO.getSymbolName()); + StringRef(MO.getSymbolName())); case MachineOperand::MO_GlobalAddress: return hash_combine(MO.getType(), MO.getTargetFlags(), MO.getGlobal(), MO.getOffset()); Index: unittests/CodeGen/MachineOperandTest.cpp =================================================================== --- unittests/CodeGen/MachineOperandTest.cpp +++ unittests/CodeGen/MachineOperandTest.cpp @@ -398,4 +398,13 @@ 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_EQ(hash_value(MO1), hash_value(MO2)); + ASSERT_TRUE(MO1.isIdenticalTo(MO2)); +} + } // end namespace