Skip to content

Commit 37e5d80

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.4
2 parents d484c4d + ff94c5a commit 37e5d80

File tree

4 files changed

+13
-15
lines changed

4 files changed

+13
-15
lines changed

bolt/include/bolt/Core/BinaryFunction.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,9 @@ class BinaryFunction {
361361
/// True if another function body was merged into this one.
362362
bool HasFunctionsFoldedInto{false};
363363

364+
/// True if the function has internal calls.
365+
bool HasInternalCalls{false};
366+
364367
/// Name for the section this function code should reside in.
365368
std::string CodeSectionName;
366369

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

1340+
/// Return true if the function has internal calls.
1341+
bool hasInternalCalls() const { return HasInternalCalls; }
1342+
13371343
/// If this function was folded, return the function it was folded into.
13381344
BinaryFunction *getFoldedIntoFunction() const { return FoldedIntoFunction; }
13391345

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1281,6 +1281,7 @@ Error BinaryFunction::disassemble() {
12811281
// Recursive call.
12821282
TargetSymbol = getSymbol();
12831283
} else {
1284+
HasInternalCalls = true;
12841285
if (BC.isX86()) {
12851286
// Dangerous old-style x86 PIC code. We may need to freeze this
12861287
// function, so preserve the function as is for now.
@@ -1436,11 +1437,6 @@ Error BinaryFunction::disassemble() {
14361437

14371438
clearList(Relocations);
14381439

1439-
if (!IsSimple) {
1440-
clearList(Instructions);
1441-
return createNonFatalBOLTError("");
1442-
}
1443-
14441440
updateState(State::Disassembled);
14451441

14461442
return Error::success();

bolt/lib/Passes/ValidateInternalCalls.cpp

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -309,15 +309,10 @@ Error ValidateInternalCalls::runOnFunctions(BinaryContext &BC) {
309309
std::set<BinaryFunction *> NeedsValidation;
310310
for (auto &BFI : BC.getBinaryFunctions()) {
311311
BinaryFunction &Function = BFI.second;
312-
for (BinaryBasicBlock &BB : Function) {
313-
for (MCInst &Inst : BB) {
314-
if (getInternalCallTarget(Function, Inst)) {
315-
NeedsValidation.insert(&Function);
316-
Function.setSimple(false);
317-
break;
318-
}
319-
}
320-
}
312+
if (!Function.hasInternalCalls())
313+
continue;
314+
NeedsValidation.insert(&Function);
315+
Function.setSimple(false);
321316
}
322317

323318
// Skip validation for non-relocation mode

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3343,7 +3343,8 @@ void RewriteInstance::disassembleFunctions() {
33433343

33443344
if (!Function.isSimple()) {
33453345
assert((!BC->HasRelocations || Function.getSize() == 0 ||
3346-
Function.hasIndirectTargetToSplitFragment()) &&
3346+
Function.hasIndirectTargetToSplitFragment() ||
3347+
Function.hasInternalCalls()) &&
33473348
"unexpected non-simple function in relocation mode");
33483349
continue;
33493350
}

0 commit comments

Comments
 (0)