Skip to content

[BOLT][NFCI] Allow non-simple functions to be in disassembled state #90806

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

aaupov
Copy link
Contributor

@aaupov aaupov commented May 2, 2024

BOLTed binaries have no relocations, thus all split functions are marked
as non-simple (BinaryContext::registerFragment). In turn, this prevents
them from being disassembled. Relax the restriction to allow instruction
lookups.

Depends on: #90804

Test Plan: NFC

Created using spr 1.3.4
@llvmbot
Copy link
Member

llvmbot commented May 2, 2024

@llvm/pr-subscribers-bolt

Author: Amir Ayupov (aaupov)

Changes

BOLTed binaries have no relocations, thus all split functions are marked
as non-simple (BinaryContext::registerFragment). In turn, this prevents
them from being disassembled. Relax the restriction to allow instruction
lookups.

Test Plan: NFC


Full diff: https://github.com/llvm/llvm-project/pull/90806.diff

2 Files Affected:

  • (modified) bolt/lib/Core/BinaryFunction.cpp (-5)
  • (modified) bolt/lib/Rewrite/RewriteInstance.cpp (+2-1)
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index fff53dd25004a4..8b12492aa1a134 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -1437,11 +1437,6 @@ Error BinaryFunction::disassemble() {
 
   clearList(Relocations);
 
-  if (!IsSimple) {
-    clearList(Instructions);
-    return createNonFatalBOLTError("");
-  }
-
   updateState(State::Disassembled);
 
   return Error::success();
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 23f79e3c135a78..f6f597c8cee0d8 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -3343,7 +3343,8 @@ void RewriteInstance::disassembleFunctions() {
 
     if (!Function.isSimple()) {
       assert((!BC->HasRelocations || Function.getSize() == 0 ||
-              Function.hasIndirectTargetToSplitFragment()) &&
+              Function.hasIndirectTargetToSplitFragment() ||
+              Function.hasInternalCalls()) &&
              "unexpected non-simple function in relocation mode");
       continue;
     }

@aaupov aaupov marked this pull request as draft May 2, 2024 23:27
@aaupov aaupov closed this May 8, 2024
@aaupov aaupov deleted the users/aaupov/spr/boltnfci-allow-non-simple-functions-to-be-in-disassembled-state branch May 8, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants