Skip to content

[BOLT] Skip FDE emission for patch functions #136224

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

Merged
merged 2 commits into from
Apr 18, 2025
Merged
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: 4 additions & 2 deletions bolt/lib/Core/BinaryEmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,10 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
Streamer.emitLabel(StartSymbol);
}

const bool NeedsFDE =
Function.hasCFI() && !(Function.isPatch() && Function.isAnonymous());
// Emit CFI start
if (Function.hasCFI()) {
if (NeedsFDE) {
Streamer.emitCFIStartProc(/*IsSimple=*/false);
if (Function.getPersonalityFunction() != nullptr)
Streamer.emitCFIPersonality(Function.getPersonalityFunction(),
Expand Down Expand Up @@ -421,7 +423,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
Streamer.emitBytes(BC.MIB->getTrapFillValue());

// Emit CFI end
if (Function.hasCFI())
if (NeedsFDE)
Streamer.emitCFIEndProc();

MCSymbol *EndSymbol = Function.getFunctionEndLabel(FF.getFragmentNum());
Expand Down
7 changes: 7 additions & 0 deletions bolt/test/AArch64/lite-mode.s
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
# RUN: llvm-objdump -d --disassemble-symbols=cold_function %t.bolt \
# RUN: | FileCheck %s


## Verify that the number of FDEs matches the number of functions in the output
## binary. There are three original functions and two optimized.
# RUN: llvm-readelf -u %t.bolt | grep -wc FDE \
# RUN: | FileCheck --check-prefix=CHECK-FDE %s
# CHECK-FDE: 5

## In lite mode, optimized code will be separated from the original .text by
## over 128MB, making it impossible for call/bl instructions in cold functions
## to reach optimized functions directly.
Expand Down
Loading