Skip to content

[BOLT] Omit CFI state while printing functions without CFI #96723

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 1 commit into from
Jun 28, 2024

Conversation

maksfb
Copy link
Contributor

@maksfb maksfb commented Jun 26, 2024

If a function has no CFI program attached to it, do not print redundant empty CFI state for every basic block.

If a function has no CFI program attached to it, do not print redundant
empty CFI state for every basic block.
@llvmbot
Copy link
Member

llvmbot commented Jun 26, 2024

@llvm/pr-subscribers-bolt

Author: Maksim Panchenko (maksfb)

Changes

If a function has no CFI program attached to it, do not print redundant empty CFI state for every basic block.


Full diff: https://github.com/llvm/llvm-project/pull/96723.diff

4 Files Affected:

  • (modified) bolt/lib/Core/BinaryFunction.cpp (+2-2)
  • (modified) bolt/test/X86/issue20.s (-1)
  • (modified) bolt/test/X86/issue20.test (-1)
  • (modified) bolt/test/X86/sctc-bug4.test (-5)
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index c608ff40c6d9c..5d33aa651a648 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -543,7 +543,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
         else
           OS << "<unknown>\n";
       }
-      if (BB->getCFIState() >= 0)
+      if (hasCFI())
         OS << "  CFI State : " << BB->getCFIState() << '\n';
       if (opts::EnableBAT) {
         OS << "  Input offset: 0x" << Twine::utohexstr(BB->getInputOffset())
@@ -611,7 +611,7 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
       }
 
       // In CFG_Finalized state we can miscalculate CFI state at exit.
-      if (CurrentState == State::CFG) {
+      if (CurrentState == State::CFG && hasCFI()) {
         const int32_t CFIStateAtExit = BB->getCFIStateAtExit();
         if (CFIStateAtExit >= 0)
           OS << "  CFI State: " << CFIStateAtExit << '\n';
diff --git a/bolt/test/X86/issue20.s b/bolt/test/X86/issue20.s
index 99a4f2ea2ac99..9645eaf2e6223 100644
--- a/bolt/test/X86/issue20.s
+++ b/bolt/test/X86/issue20.s
@@ -13,7 +13,6 @@
 # CHECK-NOT: BOLT-INFO: UCE removed {{.*}} blocks and {{.*}} bytes of code
 # CHECK: Binary Function "main"
 # CHECK:      .LFT{{.*}} (2 instructions, align : 1)
-# CHECK-NEXT:   CFI State : 0
 # CHECK-NEXT:     00000004:   andq
 # CHECK-NEXT:     00000008:   jmpq
 # CHECK-NEXT:   Successors: .Ltmp{{.*}}, .Ltmp{{.*}}, .Ltmp{{.*}}, .Ltmp{{.*}}
diff --git a/bolt/test/X86/issue20.test b/bolt/test/X86/issue20.test
index dcb1ce5ab1567..09f9c36cc9e3d 100644
--- a/bolt/test/X86/issue20.test
+++ b/bolt/test/X86/issue20.test
@@ -9,7 +9,6 @@
 CHECK-NOT: BOLT-INFO: UCE removed {{.*}} blocks and {{.*}}| bytes of code
 CHECK: Binary Function "main"
 CHECK:      .LFT0 (2 instructions, align : 1)
-CHECK-NEXT:   CFI State : 0
 CHECK-NEXT:     00000004:   andq
 CHECK-NEXT:     00000008:   jmpq
 CHECK-NEXT:   Successors: .Ltmp1, .Ltmp2, .Ltmp3, .Ltmp4
diff --git a/bolt/test/X86/sctc-bug4.test b/bolt/test/X86/sctc-bug4.test
index 21a602b6729ae..e192a238a4d0c 100644
--- a/bolt/test/X86/sctc-bug4.test
+++ b/bolt/test/X86/sctc-bug4.test
@@ -6,24 +6,19 @@ RUN: llvm-bolt %t -o %t.null --enable-bat \
 RUN:   -funcs=test_func -print-sctc -sequential-disassembly 2>&1 | FileCheck %s
 
 CHECK:      .Ltmp2 (3 instructions, align : 1)
-CHECK-NEXT:   CFI State : 0
 CHECK-NEXT:   Input offset: 0x24
 CHECK-NEXT:   Predecessors: .LFT1
 CHECK-NEXT:     00000024: 	cmpq	$0x20, %rsi
 CHECK-NEXT:     00000028: 	ja	dummy # TAILCALL # Offset: 53 # CTCTakenCount: 0
 CHECK-NEXT:     0000002a: 	jmp .Ltmp4
 CHECK-NEXT:   Successors: .Ltmp4
-CHECK-NEXT:   CFI State: 0
 
 CHECK:      .Ltmp1 (2 instructions, align : 1)
-CHECK-NEXT:   CFI State : 0
 CHECK-NEXT:   Input offset: 0x2c
 CHECK-NEXT:   Predecessors: .LFT0
 CHECK-NEXT:     0000002c: 	xorq	%r11, %rax
 CHECK-NEXT:     0000002f: 	retq
-CHECK-NEXT:   CFI State: 0
 
 CHECK:      .Ltmp4 (4 instructions, align : 1)
-CHECK-NEXT:  CFI State : 0
 CHECK-NEXT:  Input offset: 0x3a
 CHECK-NEXT:  Predecessors: .Ltmp2

Copy link
Member

@dcci dcci left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@maksfb maksfb merged commit ca06b61 into llvm:main Jun 28, 2024
8 checks passed
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
If a function has no CFI program attached to it, do not print redundant
empty CFI state for every basic block.
@maksfb maksfb deleted the gh-print-no-cfi branch March 6, 2025 02:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants