-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[BOLT] Add reading support for Linux kernel .altinstructions section #84283
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
Read .altinstructions and annotate instructions that have alternative sequences with "AltInst" annotation. Note that some instructions may have more than one alternatives, in which case they will have multiple annotations in the form "AltInst", "AltInst2", "AltInst3", etc.
Need to add a test case. |
|
||
static cl::opt<bool> | ||
DumpAltInstructions("dump-alt-instructions", | ||
cl::desc("dump Linux alernative instructions info"), |
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.
typo: alternative.
DataExtractor::Cursor Cursor(0); | ||
while (Cursor && !DE.eof(Cursor)) { | ||
const uint64_t OrgInstAddress = | ||
Address + Cursor.tell() + (int32_t)DE.getU32(Cursor); |
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.
here you're parsing a signed 32-bit value as unsigned then casting. Is it always correct?
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.
Yes. That's what DataExtractor::getSigned()
does underneath. I would have used it, but there's no Cursor
version of this interface.
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.
Doesn't coding guide prefers using c++ style casting?
https://llvm.org/docs/CodingStandards.html#prefer-c-style-casts
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.
The rule lists an exception for integral type casts.
/// struct alt_instr { | ||
/// s32 instr_offset; | ||
/// s32 repl_offset; | ||
/// uXX feature; |
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.
what does uXX stand for?
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.
u16 or u32. Perhaps u64 in the future.
31de825
to
100df3d
Compare
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. (I already reviewed it -- appreciate you clarifying my comments). Thanks for adding a test.
Thanks for the review. |
Read .altinstructions and annotate instructions that have alternative sequences with "AltInst" annotation. Note that some instructions may have more than one alternatives, in which case they will have multiple annotations in the form "AltInst", "AltInst2", "AltInst3", etc.