-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[BOLT][AArch64] Speedup computeInstructionSize
#121106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-bolt Author: Nicholas (liusy58) ChangesAArch64 instructions has a fixed size 4 bytes, no need to compute. Full diff: https://github.com/llvm/llvm-project/pull/121106.diff 1 Files Affected:
diff --git a/bolt/include/bolt/Core/BinaryContext.h b/bolt/include/bolt/Core/BinaryContext.h
index 115e59ca0697e5..22764098700214 100644
--- a/bolt/include/bolt/Core/BinaryContext.h
+++ b/bolt/include/bolt/Core/BinaryContext.h
@@ -1362,7 +1362,15 @@ class BinaryContext {
const MCCodeEmitter *Emitter = nullptr) const {
if (std::optional<uint32_t> Size = MIB->getSize(Inst))
return *Size;
-
+ // Pseudo instrs will not be emiitted and have no size.
+ if (MIB->isPseudo(Inst)) {
+ return 0;
+ }
+ // Directly return 4 because AArch64 instructions always have a
+ // fixed size of 4 bytes.
+ if (isAArch64()) {
+ return 4;
+ }
if (!Emitter)
Emitter = this->MCE.get();
SmallString<256> Code;
|
Every patch requires testing, but I haven't found a suitable way to evaluate its performance. Any suggestions |
e39baaf
to
903b4a8
Compare
|
||
std::optional<uint32_t> | ||
getInstructionSize(const MCInst &Inst) const override { | ||
if (isPseudo(Inst)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isPseudo(Inst)) { | |
if (isPseudo(Inst)) | |
return 0; | |
return 4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW maybe move isPseudo check to computeInstructionSize?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, done~
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM Thanks, just fix a small nit with brackets, thanks!
@yota9 hi, I have updated, please review again! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
AArch64 instructions have a fixed size 4 bytes, no need to compute.
AArch64 instructions have a fixed size 4 bytes, no need to compute.
AArch64 instructions have a fixed size 4 bytes, no need to compute.
AArch64 instructions have a fixed size 4 bytes, no need to compute.
AArch64 instructions have a fixed size 4 bytes, no need to compute.