Skip to content

Conversation

bgergely0
Copy link
Contributor

FileCheck accepts both '#' and '//' as leading chars for commands, but link_fdata.py only searched for lines starting with '#'. This changes the regexps in link_fdata.py to mirror FileCheck's behaviour.
The comment syntax in test/timers.c is modified to present this capability.

@llvmbot
Copy link
Member

llvmbot commented Aug 8, 2025

@llvm/pr-subscribers-bolt

Author: Gergely Bálint (bgergely0)

Changes

FileCheck accepts both '#' and '//' as leading chars for commands, but link_fdata.py only searched for lines starting with '#'. This changes the regexps in link_fdata.py to mirror FileCheck's behaviour.
The comment syntax in test/timers.c is modified to present this capability.


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

2 Files Affected:

  • (modified) bolt/test/link_fdata.py (+2-2)
  • (modified) bolt/test/timers.c (+20-21)
diff --git a/bolt/test/link_fdata.py b/bolt/test/link_fdata.py
index 898dce8e3fb5f..0361500ae7194 100755
--- a/bolt/test/link_fdata.py
+++ b/bolt/test/link_fdata.py
@@ -27,7 +27,7 @@
 
 # Regexes to extract FDATA lines from input and parse FDATA and pre-aggregated
 # profile data
-prefix_pat = re.compile(f"^# {args.prefix}: (.*)")
+prefix_pat = re.compile(f"^(#|//) {args.prefix}: (.*)")
 
 # FDATA records:
 # <is symbol?> <closest elf symbol or DSO name> <relative FROM address>
@@ -56,7 +56,7 @@
         prefix_match = prefix_pat.match(line)
         if not prefix_match:
             continue
-        profile_line = prefix_match.group(1)
+        profile_line = prefix_match.group(2)
         fdata_match = fdata_pat.match(profile_line)
         preagg_match = preagg_pat.match(profile_line)
         nolbr_match = nolbr_pat.match(profile_line)
diff --git a/bolt/test/timers.c b/bolt/test/timers.c
index a34958a2a15e9..9a82218de72ad 100644
--- a/bolt/test/timers.c
+++ b/bolt/test/timers.c
@@ -1,22 +1,21 @@
-/* This test checks timers for metadata manager phases.
-# RUN: %clang %cflags %s -o %t.exe
-# RUN: link_fdata %s %t.exe %t.fdata
-# RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
-# RUN:   2>&1 | FileCheck %s
-# RUN: link_fdata %s %t.exe %t.preagg PREAGG
-# RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
-# RUN:   2>&1 | FileCheck %s --check-prefix=CHECK-P2B
-
-# CHECK-DAG: update metadata post-emit
-# CHECK-DAG: process section metadata
-# CHECK-DAG: process metadata pre-CFG
-# CHECK-DAG: process metadata post-CFG
-# CHECK-DAG: finalize metadata pre-emit
-
-# CHECK-P2B-DAG: process section metadata
-# CHECK-P2B-DAG: process metadata pre-CFG
-
-# FDATA: 0 [unknown] 0 1 main 0 1 0
-# PREAGG: B X:0 #main# 1 0
-*/
+// This test checks timers for metadata manager phases.
+// RUN: %clang %cflags %s -o %t.exe
+// RUN: link_fdata %s %t.exe %t.fdata
+// RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
+// RUN:   2>&1 | FileCheck %s
+// RUN: link_fdata %s %t.exe %t.preagg PREAGG
+// RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
+// RUN:   2>&1 | FileCheck %s --check-prefix=CHECK-P2B
+//
+// CHECK-DAG: update metadata post-emit
+// CHECK-DAG: process section metadata
+// CHECK-DAG: process metadata pre-CFG
+// CHECK-DAG: process metadata post-CFG
+// CHECK-DAG: finalize metadata pre-emit
+//
+// CHECK-P2B-DAG: process section metadata
+// CHECK-P2B-DAG: process metadata pre-CFG
+//
+// FDATA: 0 [unknown] 0 1 main 0 1 0
+// PREAGG: B X:0 #main# 1 0
 int main() { return 0; }

Copy link
Member

@paschalis-mpeis paschalis-mpeis left a comment

Choose a reason for hiding this comment

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

Thanks Gergely.

Please allow 1-2 days in case there are any objections.

FileCheck accepts both '#' and '//' as leading chars for commands,
but link_fdata.py only searched for lines starting with '#'.
This changes the regexps in link_fdata.py to mirror FileCheck's
behaviour.
test/timers.c is modified to present this capability.
@bgergely0 bgergely0 force-pushed the improve-link-fdata branch from 7a10125 to 9d093d9 Compare August 8, 2025 12:24
@bgergely0
Copy link
Contributor Author

nit: removed // from empty lines.

@paschalis-mpeis paschalis-mpeis merged commit a473970 into llvm:main Sep 2, 2025
9 checks passed
@paschalis-mpeis
Copy link
Member

Merged on behalf of Gergely at his request.

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