Skip to content

Commit ca06b61

Browse files
authored
[BOLT] Omit CFI state while printing functions without CFI (#96723)
If a function has no CFI program attached to it, do not print redundant empty CFI state for every basic block.
1 parent c63eadd commit ca06b61

File tree

4 files changed

+2
-9
lines changed

4 files changed

+2
-9
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
543543
else
544544
OS << "<unknown>\n";
545545
}
546-
if (BB->getCFIState() >= 0)
546+
if (hasCFI())
547547
OS << " CFI State : " << BB->getCFIState() << '\n';
548548
if (opts::EnableBAT) {
549549
OS << " Input offset: 0x" << Twine::utohexstr(BB->getInputOffset())
@@ -611,7 +611,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
611611
}
612612

613613
// In CFG_Finalized state we can miscalculate CFI state at exit.
614-
if (CurrentState == State::CFG) {
614+
if (CurrentState == State::CFG && hasCFI()) {
615615
const int32_t CFIStateAtExit = BB->getCFIStateAtExit();
616616
if (CFIStateAtExit >= 0)
617617
OS << " CFI State: " << CFIStateAtExit << '\n';

bolt/test/X86/issue20.s

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# CHECK-NOT: BOLT-INFO: UCE removed {{.*}} blocks and {{.*}} bytes of code
1414
# CHECK: Binary Function "main"
1515
# CHECK: .LFT{{.*}} (2 instructions, align : 1)
16-
# CHECK-NEXT: CFI State : 0
1716
# CHECK-NEXT: 00000004: andq
1817
# CHECK-NEXT: 00000008: jmpq
1918
# CHECK-NEXT: Successors: .Ltmp{{.*}}, .Ltmp{{.*}}, .Ltmp{{.*}}, .Ltmp{{.*}}

bolt/test/X86/issue20.test

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
CHECK-NOT: BOLT-INFO: UCE removed {{.*}} blocks and {{.*}}| bytes of code
1010
CHECK: Binary Function "main"
1111
CHECK: .LFT0 (2 instructions, align : 1)
12-
CHECK-NEXT: CFI State : 0
1312
CHECK-NEXT: 00000004: andq
1413
CHECK-NEXT: 00000008: jmpq
1514
CHECK-NEXT: Successors: .Ltmp1, .Ltmp2, .Ltmp3, .Ltmp4

bolt/test/X86/sctc-bug4.test

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,19 @@ RUN: llvm-bolt %t -o %t.null --enable-bat \
66
RUN: -funcs=test_func -print-sctc -sequential-disassembly 2>&1 | FileCheck %s
77

88
CHECK: .Ltmp2 (3 instructions, align : 1)
9-
CHECK-NEXT: CFI State : 0
109
CHECK-NEXT: Input offset: 0x24
1110
CHECK-NEXT: Predecessors: .LFT1
1211
CHECK-NEXT: 00000024: cmpq $0x20, %rsi
1312
CHECK-NEXT: 00000028: ja dummy # TAILCALL # Offset: 53 # CTCTakenCount: 0
1413
CHECK-NEXT: 0000002a: jmp .Ltmp4
1514
CHECK-NEXT: Successors: .Ltmp4
16-
CHECK-NEXT: CFI State: 0
1715

1816
CHECK: .Ltmp1 (2 instructions, align : 1)
19-
CHECK-NEXT: CFI State : 0
2017
CHECK-NEXT: Input offset: 0x2c
2118
CHECK-NEXT: Predecessors: .LFT0
2219
CHECK-NEXT: 0000002c: xorq %r11, %rax
2320
CHECK-NEXT: 0000002f: retq
24-
CHECK-NEXT: CFI State: 0
2521

2622
CHECK: .Ltmp4 (4 instructions, align : 1)
27-
CHECK-NEXT: CFI State : 0
2823
CHECK-NEXT: Input offset: 0x3a
2924
CHECK-NEXT: Predecessors: .Ltmp2

0 commit comments

Comments
 (0)