Skip to content

Commit 5c09317

Browse files
authored
[BOLT][RISCV] Implement MCPlusBuilder::equals (#68989)
This enables ICF for RISC-V. No tests are added by this commit as `bolt-icf.test` covers this case (only on a RISC-V host though).
1 parent 33b58f3 commit 5c09317

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
3131
public:
3232
using MCPlusBuilder::MCPlusBuilder;
3333

34+
bool equals(const MCTargetExpr &A, const MCTargetExpr &B,
35+
CompFuncTy Comp) const override {
36+
const auto &RISCVExprA = cast<RISCVMCExpr>(A);
37+
const auto &RISCVExprB = cast<RISCVMCExpr>(B);
38+
if (RISCVExprA.getKind() != RISCVExprB.getKind())
39+
return false;
40+
41+
return MCPlusBuilder::equals(*RISCVExprA.getSubExpr(),
42+
*RISCVExprB.getSubExpr(), Comp);
43+
}
44+
3445
bool shouldRecordCodeRelocation(uint64_t RelType) const override {
3546
switch (RelType) {
3647
case ELF::R_RISCV_JAL:

0 commit comments

Comments
 (0)