[Lldb-commits] [lldb] 5aed2ef - Fix buildbot out of memory
via lldb-commits
lldb-commits at lists.llvm.org
Thu Dec 15 10:20:48 PST 2022
Author: Emmmer
Date: 2022-12-16T02:20:19+08:00
New Revision: 5aed2eff43c075b54be81095fdc5917bc32b530a
URL: https://github.com/llvm/llvm-project/commit/5aed2eff43c075b54be81095fdc5917bc32b530a
DIFF: https://github.com/llvm/llvm-project/commit/5aed2eff43c075b54be81095fdc5917bc32b530a.diff
LOG: Fix buildbot out of memory
https://lab.llvm.org/buildbot#builders/17/builds/31659
Added:
Modified:
lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
Removed:
################################################################################
diff --git a/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h b/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
index 8fc51d1d9a717..b144a7cb2a9d2 100644
--- a/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
+++ b/lldb/source/Plugins/Instruction/RISCV/RISCVInstructions.h
@@ -36,22 +36,30 @@ struct Rs {
bool isDouble);
};
+#define DERIVE_EQ(NAME) \
+ bool operator==(const NAME &r) const { \
+ return std::memcmp(this, &r, sizeof(NAME)) == 0; \
+ }
+
#define I_TYPE_INST(NAME) \
struct NAME { \
Rd rd; \
Rs rs1; \
uint32_t imm; \
+ DERIVE_EQ(NAME); \
}
#define S_TYPE_INST(NAME) \
struct NAME { \
Rs rs1; \
Rs rs2; \
uint32_t imm; \
+ DERIVE_EQ(NAME); \
}
#define U_TYPE_INST(NAME) \
struct NAME { \
Rd rd; \
uint32_t imm; \
+ DERIVE_EQ(NAME); \
}
/// The memory layout are the same in our code.
#define J_TYPE_INST(NAME) U_TYPE_INST(NAME)
@@ -60,17 +68,20 @@ struct Rs {
Rd rd; \
Rs rs1; \
Rs rs2; \
+ DERIVE_EQ(NAME); \
}
#define R_SHAMT_TYPE_INST(NAME) \
struct NAME { \
Rd rd; \
Rs rs1; \
uint32_t shamt; \
+ DERIVE_EQ(NAME); \
}
#define R_RS1_TYPE_INST(NAME) \
struct NAME { \
Rd rd; \
Rs rs1; \
+ DERIVE_EQ(NAME); \
}
#define R4_TYPE_INST(NAME) \
struct NAME { \
@@ -79,11 +90,13 @@ struct Rs {
Rs rs2; \
Rs rs3; \
int32_t rm; \
+ DERIVE_EQ(NAME); \
}
/// The `inst` fields are used for debugging.
#define INVALID_INST(NAME) \
struct NAME { \
uint32_t inst; \
+ DERIVE_EQ(NAME); \
}
// RV32I instructions (The base integer ISA)
@@ -92,6 +105,7 @@ struct B {
Rs rs2;
uint32_t imm;
uint32_t funct3;
+ DERIVE_EQ(B);
};
U_TYPE_INST(LUI);
U_TYPE_INST(AUIPC);
@@ -323,5 +337,17 @@ constexpr uint32_t NanUnBoxing(uint64_t val) {
return val & (~0xFFFF'FFFF'0000'0000);
}
+#undef R_TYPE_INST
+#undef R_SHAMT_TYPE_INST
+#undef R_RS1_TYPE_INST
+#undef R4_TYPE_INST
+#undef I_TYPE_INST
+#undef S_TYPE_INST
+#undef B_TYPE_INST
+#undef U_TYPE_INST
+#undef J_TYPE_INST
+#undef INVALID_INST
+#undef DERIVE_EQ
+
} // namespace lldb_private
#endif // LLDB_SOURCE_PLUGINS_INSTRUCTION_RISCV_RISCVINSTRUCTION_H
diff --git a/lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp b/lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
index f00d581275a74..23cdd77e2c734 100644
--- a/lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
+++ b/lldb/unittests/Instruction/RISCV/TestRISCVEmulator.cpp
@@ -281,25 +281,6 @@ struct TestDecode {
RISCVInst inst_type;
};
-static bool compareInst(const RISCVInst &lhs, const RISCVInst &rhs) {
- if (lhs.index() != rhs.index())
- return false;
- return std::visit(
- [&](auto &&L) {
- return std::visit(
- [&](auto &&R) {
- // guaranteed by
- // 1. lhs.index() == rhs.index()
- // (they are the same instruction type)
- // 2. all instruction representations are plain data objects
- // consisting of primitive types.
- return std::memcmp(&L, &R, sizeof(L)) == 0;
- },
- rhs);
- },
- lhs);
-}
-
TEST_F(RISCVEmulatorTester, TestCDecode) {
std::vector<TestDecode> tests = {
{0x0000, INVALID{0x0000}},
@@ -354,7 +335,7 @@ TEST_F(RISCVEmulatorTester, TestCDecode) {
for (auto i : tests) {
auto decode = this->Decode(i.inst);
ASSERT_TRUE(decode.has_value());
- ASSERT_TRUE(compareInst(decode->decoded, i.inst_type));
+ ASSERT_EQ(decode->decoded, i.inst_type);
}
}
@@ -374,7 +355,7 @@ TEST_F(RISCVEmulatorTester32, TestCDecodeRV32) {
for (auto i : tests) {
auto decode = this->Decode(i.inst);
ASSERT_TRUE(decode.has_value());
- ASSERT_TRUE(compareInst(decode->decoded, i.inst_type));
+ ASSERT_EQ(decode->decoded, i.inst_type);
}
}
More information about the lldb-commits
mailing list