Skip to content

Commit 2adb3f2

Browse files
committed
[BOLT][AArch64] Speedup computeInstructionSize
1 parent 8387cbd commit 2adb3f2

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

bolt/include/bolt/Core/BinaryContext.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1363,6 +1363,12 @@ class BinaryContext {
13631363
if (std::optional<uint32_t> Size = MIB->getSize(Inst))
13641364
return *Size;
13651365

1366+
if (MIB->isPseudo(Inst))
1367+
return 0;
1368+
1369+
if (std::optional<uint32_t> Size = MIB->getInstructionSize(Inst))
1370+
return *Size;
1371+
13661372
if (!Emitter)
13671373
Emitter = this->MCE.get();
13681374
SmallString<256> Code;

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,6 +1204,11 @@ class MCPlusBuilder {
12041204
/// Get instruction size specified via annotation.
12051205
std::optional<uint32_t> getSize(const MCInst &Inst) const;
12061206

1207+
/// Get target-specific instruction size.
1208+
virtual std::optional<uint32_t> getInstructionSize(const MCInst &Inst) const {
1209+
return std::nullopt;
1210+
}
1211+
12071212
/// Set instruction size.
12081213
void setSize(MCInst &Inst, uint32_t Size) const;
12091214

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1790,6 +1790,11 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
17901790
}
17911791

17921792
uint16_t getMinFunctionAlignment() const override { return 4; }
1793+
1794+
std::optional<uint32_t>
1795+
getInstructionSize(const MCInst &Inst) const override {
1796+
return 4;
1797+
}
17931798
};
17941799

17951800
} // end anonymous namespace

0 commit comments

Comments
 (0)