mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-12-15 04:00:56 +00:00
[BOLT] Mark fragments related to split jump table as non-simple
Mark fragments related to split jump table as non-simple. A function could be splitted into hot and cold fragments. A split jump table is challenging for correctly reconstructing control flow graphs, so it was marked as ignored. This update marks those fragments as non-simple, allowing them to be printed and partial control flow graph construction. Test Plan: ``` llvm-lit -a tools/bolt/test/X86/split-func-icf.s ``` This test has two functions (main, main2), each has a jump table target to the same cold portion main2.cold.1(*2). We try to print out only this cold portion. If it is ignored, it cannot be printed. If it is non-simple, it can be printed. We verify that it can be printed. Reviewed By: Amir Differential Revision: https://reviews.llvm.org/D127464
This commit is contained in:
parent
e90b56e411
commit
82095bd5ed
@ -715,13 +715,15 @@ void BinaryContext::skipMarkedFragments() {
|
||||
"internal error in traversing function fragments");
|
||||
if (opts::Verbosity >= 1)
|
||||
errs() << "BOLT-WARNING: Ignoring " << BF->getPrintName() << '\n';
|
||||
BF->setIgnored();
|
||||
BF->setSimple(false);
|
||||
BF->setHasSplitJumpTable(true);
|
||||
|
||||
std::for_each(BF->Fragments.begin(), BF->Fragments.end(), addToWorklist);
|
||||
std::for_each(BF->ParentFragments.begin(), BF->ParentFragments.end(),
|
||||
addToWorklist);
|
||||
}
|
||||
if (!FragmentsToSkip.empty())
|
||||
errs() << "BOLT-WARNING: ignored " << FragmentsToSkip.size() << " function"
|
||||
errs() << "BOLT-WARNING: skipped " << FragmentsToSkip.size() << " function"
|
||||
<< (FragmentsToSkip.size() == 1 ? "" : "s")
|
||||
<< " due to cold fragments\n";
|
||||
FragmentsToSkip.clear();
|
||||
|
@ -2925,7 +2925,8 @@ void RewriteInstance::disassembleFunctions() {
|
||||
continue;
|
||||
|
||||
if (!Function.isSimple()) {
|
||||
assert((!BC->HasRelocations || Function.getSize() == 0) &&
|
||||
assert((!BC->HasRelocations || Function.getSize() == 0 ||
|
||||
Function.hasSplitJumpTable()) &&
|
||||
"unexpected non-simple function in relocation mode");
|
||||
continue;
|
||||
}
|
||||
|
@ -8,15 +8,17 @@
|
||||
# RUN: llvm-mc -filetype=obj -triple x86_64-unknown-unknown %s -o %t.o
|
||||
# RUN: llvm-strip --strip-unneeded %t.o
|
||||
# RUN: %clang %cflags %t.o -o %t.exe -Wl,-q
|
||||
# RUN: llvm-bolt %t.exe -o %t.out -lite=0 -v=1 2>&1 | FileCheck %s
|
||||
# RUN: llvm-bolt %t.exe -o %t.out -v=1 --print-only=main2.cold.1 --print-disasm 2>&1 | FileCheck %s
|
||||
|
||||
# CHECK-NOT: unclaimed PC-relative relocations left in data
|
||||
# CHECK-DAG: BOLT-INFO: marking main2.cold.1(*2) as a fragment of main
|
||||
# CHECK-DAG: BOLT-INFO: marking main2.cold.1(*2) as a fragment of main2
|
||||
# CHECK: Binary Function "main2.cold.1(*2)" after disassembly
|
||||
# CHECK: End of Function "main2.cold.1(*2)"
|
||||
# CHECK-DAG: BOLT-WARNING: Ignoring main2
|
||||
# CHECK-DAG: BOLT-WARNING: Ignoring main
|
||||
# CHECK-DAG: BOLT-WARNING: Ignoring main2.cold.1(*2)
|
||||
# CHECK: BOLT-WARNING: ignored 3 functions due to cold fragments
|
||||
# CHECK: BOLT-WARNING: skipped 3 functions due to cold fragments
|
||||
.text
|
||||
.globl main
|
||||
.type main, %function
|
||||
|
Loading…
Reference in New Issue
Block a user