-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[BOLT] Do not reject irreversible branches during disassembly #95572
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: Nathan Sidwell (urnathan) ChangesNow that Removing this check results in no new test failures. The use of If some branches should be rejected at this point, a new MCPlusBuilder hook is most likely needed -- this cannot be the correct predicate to use (after all, it would render all the other uses moot. Full diff: https://github.com/llvm/llvm-project/pull/95572.diff 1 Files Affected:
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index d13e28999a05c..a8b1f69166d21 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -1288,13 +1288,6 @@ Error BinaryFunction::disassemble() {
const bool IsCondBranch = MIB->isConditionalBranch(Instruction);
MCSymbol *TargetSymbol = nullptr;
- if (!BC.MIB->isReversibleBranch(Instruction)) {
- setIgnored();
- if (BinaryFunction *TargetFunc =
- BC.getBinaryFunctionContainingAddress(TargetAddress))
- TargetFunc->setIgnored();
- }
-
if (IsCall && containsAddress(TargetAddress)) {
if (TargetAddress == getAddress()) {
// Recursive call.
|
The change is in the right direction. However, we need to cover the handling of |
Now that `isUnsupportedBranch` is renamed (and inverted) to `isReversibleBranch`, this use in `BinaryFunction::disassemble` sticks out like a sore thumb. My guess is that at one point one needed to reject unintelligible branches early, and that morphed into the use for detecting uninvertible branches. Removing this check results in no new test failures. The use of `isReversibleBranch` here raises questions about what it should return for instructions that are not conditional branches -- given the other uses of this function I had been presuming 'don't care'. If some branches should be rejected at this point, a new MCPlusBuilder hook is most likely needed -- this cannot be the correct predicate to use (after all, it would render all the other uses moot.
8e3a6ed
to
0408a96
Compare
Thanks, that test fails with this original change (as expected). Here's an update adding The X86_64 target marks the loop and j*rcx instructions as unsupported. This is the only overrider. AFAICT, x86's The Instrumentation pass change is a result of that assert, it doesn't seem to me that a special check is needed there. The other change is in the X86 target code, and again I don't think it's needed. We just reject indirect branches at that point -- but the placement of the comment 'Handle conditional branches and ignore indirect branches' confuses me. I /think/ it's talking about the entire remainder of the loop, not just the if statment it's attached to. The remaining call if isReversibleBranch in [*] back in the pentium microarchitecture days, Intel had to figure out how close ahead to the PC existing self-modifying code wrote, btw |
We've seen inter-proc
Makes sense.
I agree. The comment is most likely outdated.
I cannot test this change at the moment. Do you expect it to be NFC? As a follow-up, we need to add a pass that marks functions as non-optimizible/simple and move the unsupported check in there. |
Yes, I expect this to be NFC. |
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.
Cool. Please update Title+Summary before committing. Thanks!
`isUnsupportedBranch` was renamed (and inverted) to `isReversibleBranch`, as that was how it was being used. But one use in `BinaryFunction::disassemble` was using the original meaning to detect unsupported branches, and the `isUnsupportedBranch` had 2 separate semantic checks. Move the unsupported branch check from `isReversibleBranch` to a new entry point: `isUnsupportedInstruction`. Call that from `BinaryFunction::disassemble`. Move the dynamic branch check from X86's isReversibleBranch to the base class, as it is not an architecture-specific check. Remove unnecessary `isReversibleBranch` calls from Instrumentation and X86 MCPlusBuilder.
Now that
isUnsupportedBranch
is renamed (and inverted) toisReversibleBranch
, this use inBinaryFunction::disassemble
sticks out like a sore thumb. My guess is that at one point one needed to reject unintelligible branches early, and that morphed into the use for detecting uninvertible branches.Removing this check results in no new test failures.
The use of
isReversibleBranch
here raises questions about what it should return for instructions that are not conditional branches -- given the other uses of this function I had been presuming 'don't care'.If some branches should be rejected at this point, a new MCPlusBuilder hook is most likely needed -- this cannot be the correct predicate to use (after all, it would render all the other uses moot.