Skip to content

[BOLT][NFC] Add HasInternalCalls BinaryFunction property #90804

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions bolt/include/bolt/Core/BinaryFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ class BinaryFunction {
/// True if another function body was merged into this one.
bool HasFunctionsFoldedInto{false};

/// True if the function has internal calls.
bool HasInternalCalls{false};

/// Name for the section this function code should reside in.
std::string CodeSectionName;

Expand Down Expand Up @@ -1334,6 +1337,9 @@ class BinaryFunction {
/// Return true if other functions were folded into this one.
bool hasFunctionsFoldedInto() const { return HasFunctionsFoldedInto; }

/// Return true if the function has internal calls.
bool hasInternalCalls() const { return HasInternalCalls; }

/// If this function was folded, return the function it was folded into.
BinaryFunction *getFoldedIntoFunction() const { return FoldedIntoFunction; }

Expand Down
1 change: 1 addition & 0 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1281,6 +1281,7 @@ Error BinaryFunction::disassemble() {
// Recursive call.
TargetSymbol = getSymbol();
} else {
HasInternalCalls = true;
if (BC.isX86()) {
// Dangerous old-style x86 PIC code. We may need to freeze this
// function, so preserve the function as is for now.
Expand Down
13 changes: 4 additions & 9 deletions bolt/lib/Passes/ValidateInternalCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,15 +309,10 @@ Error ValidateInternalCalls::runOnFunctions(BinaryContext &BC) {
std::set<BinaryFunction *> NeedsValidation;
for (auto &BFI : BC.getBinaryFunctions()) {
BinaryFunction &Function = BFI.second;
for (BinaryBasicBlock &BB : Function) {
for (MCInst &Inst : BB) {
if (getInternalCallTarget(Function, Inst)) {
NeedsValidation.insert(&Function);
Function.setSimple(false);
break;
}
}
}
if (!Function.hasInternalCalls())
continue;
NeedsValidation.insert(&Function);
Function.setSimple(false);
}

// Skip validation for non-relocation mode
Expand Down