Skip to content
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: 6 additions & 0 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,12 @@ bool shouldPrint(const BinaryFunction &Function) {
}
}

std::optional<StringRef> Origin = Function.getOriginSectionName();
if (Origin && llvm::any_of(opts::PrintOnly, [&](const std::string &Name) {
return Name == *Origin;
}))
return true;

return false;
}

Expand Down
29 changes: 29 additions & 0 deletions bolt/test/X86/print-only-section.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
## Check that --print-only flag works with sections.

# REQUIRES: system-linux

# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o %t.exe
# RUN: llvm-bolt %t.exe -o %t.out --print-cfg --print-only=unused_code 2>&1 \
# RUN: | FileCheck %s

# CHECK: Binary Function "foo"
# CHECK-NOT: Binary Function "_start"

.text
.globl _start
.type _start, %function
_start:
.cfi_startproc
ret
.cfi_endproc
.size _start, .-_start

.section unused_code,"ax",@progbits
.globl foo
.type foo, %function
foo:
.cfi_startproc
ret
.cfi_endproc
.size foo, .-foo