[BOLT][AArch64] Speedup computeInstructionSize (#121106)

AArch64 instructions have a fixed size 4 bytes, no need to compute.
This commit is contained in:
Nicholas
2025-01-17 09:48:17 +08:00
committed by GitHub
parent e83e0c300d
commit 1fa02b9684
3 changed files with 16 additions and 0 deletions

View File

@@ -1363,6 +1363,12 @@ public:
if (std::optional<uint32_t> Size = MIB->getSize(Inst))
return *Size;
if (MIB->isPseudo(Inst))
return 0;
if (std::optional<uint32_t> Size = MIB->getInstructionSize(Inst))
return *Size;
if (!Emitter)
Emitter = this->MCE.get();
SmallString<256> Code;

View File

@@ -1204,6 +1204,11 @@ public:
/// Get instruction size specified via annotation.
std::optional<uint32_t> getSize(const MCInst &Inst) const;
/// Get target-specific instruction size.
virtual std::optional<uint32_t> getInstructionSize(const MCInst &Inst) const {
return std::nullopt;
}
/// Set instruction size.
void setSize(MCInst &Inst, uint32_t Size) const;

View File

@@ -1792,6 +1792,11 @@ public:
}
uint16_t getMinFunctionAlignment() const override { return 4; }
std::optional<uint32_t>
getInstructionSize(const MCInst &Inst) const override {
return 4;
}
};
} // end anonymous namespace