[llvm] r334599 - [llvm-exegesis] Fix failing assert when creating Snippet for LAHF.
Guillaume Chatelet via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 13 06:53:56 PDT 2018
Author: gchatelet
Date: Wed Jun 13 06:53:56 2018
New Revision: 334599
URL: http://llvm.org/viewvc/llvm-project?rev=334599&view=rev
Log:
[llvm-exegesis] Fix failing assert when creating Snippet for LAHF.
Reviewers: courbet
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D48123
Modified:
llvm/trunk/tools/llvm-exegesis/lib/MCInstrDescView.cpp
llvm/trunk/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp
Modified: llvm/trunk/tools/llvm-exegesis/lib/MCInstrDescView.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-exegesis/lib/MCInstrDescView.cpp?rev=334599&r1=334598&r2=334599&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-exegesis/lib/MCInstrDescView.cpp (original)
+++ llvm/trunk/tools/llvm-exegesis/lib/MCInstrDescView.cpp Wed Jun 13 06:53:56 2018
@@ -208,13 +208,17 @@ static void randomize(const Variable &Va
static void setRegisterOperandValue(const RegisterOperandAssignment &ROV,
InstructionInstance &II) {
assert(ROV.Op);
- assert(ROV.Op->IsExplicit);
- auto &AssignedValue = II.getValueFor(*ROV.Op);
- if (AssignedValue.isValid()) {
- assert(AssignedValue.isReg() && AssignedValue.getReg() == ROV.Reg);
- return;
+ if (ROV.Op->IsExplicit) {
+ auto &AssignedValue = II.getValueFor(*ROV.Op);
+ if (AssignedValue.isValid()) {
+ assert(AssignedValue.isReg() && AssignedValue.getReg() == ROV.Reg);
+ return;
+ }
+ AssignedValue = llvm::MCOperand::createReg(ROV.Reg);
+ } else {
+ assert(ROV.Op->ImplicitReg != nullptr);
+ assert(ROV.Reg == *ROV.Op->ImplicitReg);
}
- AssignedValue = llvm::MCOperand::createReg(ROV.Reg);
}
size_t randomBit(const llvm::BitVector &Vector) {
Modified: llvm/trunk/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp?rev=334599&r1=334598&r2=334599&view=diff
==============================================================================
--- llvm/trunk/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp (original)
+++ llvm/trunk/unittests/tools/llvm-exegesis/X86/SnippetGeneratorTest.cpp Wed Jun 13 06:53:56 2018
@@ -103,11 +103,22 @@ TEST_F(LatencySnippetGeneratorTest, Depe
const unsigned Opcode = llvm::X86::CMP64rr;
auto Conf = checkAndGetConfiguration(Opcode);
- EXPECT_THAT(Conf.Info, testing::HasSubstr("cycle through CMOVLE16rr"));
+ EXPECT_THAT(Conf.Info, testing::HasSubstr("cycle through"));
ASSERT_THAT(Conf.Snippet, testing::SizeIs(2));
+ const llvm::MCInst Instr = Conf.Snippet[0];
+ EXPECT_THAT(Instr.getOpcode(), Opcode);
// TODO: check that the two instructions alias each other.
}
+TEST_F(LatencySnippetGeneratorTest, LAHF) {
+ const unsigned Opcode = llvm::X86::LAHF;
+ auto Conf = checkAndGetConfiguration(Opcode);
+ EXPECT_THAT(Conf.Info, testing::HasSubstr("cycle through"));
+ ASSERT_THAT(Conf.Snippet, testing::SizeIs(2));
+ const llvm::MCInst Instr = Conf.Snippet[0];
+ EXPECT_THAT(Instr.getOpcode(), Opcode);
+}
+
class UopsSnippetGeneratorTest : public X86SnippetGeneratorTest {
protected:
UopsSnippetGeneratorTest() : Runner(State) {}
More information about the llvm-commits
mailing list