Skip to content

Commit 9692c57

Browse files
bgergely0github-actions[bot]
authored andcommitted
Automerge: [BOLT] Improve regexp in link_fdata.py (#152694)
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.
2 parents bf6a6e8 + a473970 commit 9692c57

File tree

2 files changed

+19
-20
lines changed

2 files changed

+19
-20
lines changed

bolt/test/link_fdata.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
# Regexes to extract FDATA lines from input and parse FDATA and pre-aggregated
3434
# profile data
35-
prefix_pat = re.compile(f"^# {args.prefix}: (.*)")
35+
prefix_pat = re.compile(f"^(#|//) {args.prefix}: (.*)")
3636

3737
# FDATA records:
3838
# <is symbol?> <closest elf symbol or DSO name> <relative FROM address>
@@ -61,7 +61,7 @@
6161
prefix_match = prefix_pat.match(line)
6262
if not prefix_match:
6363
continue
64-
profile_line = prefix_match.group(1)
64+
profile_line = prefix_match.group(2)
6565
fdata_match = fdata_pat.match(profile_line)
6666
preagg_match = preagg_pat.match(profile_line)
6767
nolbr_match = nolbr_pat.match(profile_line)

bolt/test/timers.c

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,21 @@
1-
/* This test checks timers for metadata manager phases.
2-
# RUN: %clang %cflags %s -o %t.exe
3-
# RUN: link_fdata %s %t.exe %t.fdata
4-
# RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
5-
# RUN: 2>&1 | FileCheck %s
6-
# RUN: link_fdata %s %t.exe %t.preagg PREAGG
7-
# RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
8-
# RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B
1+
// This test checks timers for metadata manager phases.
2+
// RUN: %clang %cflags %s -o %t.exe
3+
// RUN: link_fdata %s %t.exe %t.fdata
4+
// RUN: llvm-bolt %t.exe -o %t.null --data %t.fdata -w %t.yaml --time-rewrite \
5+
// RUN: 2>&1 | FileCheck %s
6+
// RUN: link_fdata %s %t.exe %t.preagg PREAGG
7+
// RUN: perf2bolt %t.exe -o %t.null -p %t.preagg --pa --time-rewrite \
8+
// RUN: 2>&1 | FileCheck %s --check-prefix=CHECK-P2B
99

10-
# CHECK-DAG: update metadata post-emit
11-
# CHECK-DAG: process section metadata
12-
# CHECK-DAG: process metadata pre-CFG
13-
# CHECK-DAG: process metadata post-CFG
14-
# CHECK-DAG: finalize metadata pre-emit
10+
// CHECK-DAG: update metadata post-emit
11+
// CHECK-DAG: process section metadata
12+
// CHECK-DAG: process metadata pre-CFG
13+
// CHECK-DAG: process metadata post-CFG
14+
// CHECK-DAG: finalize metadata pre-emit
1515

16-
# CHECK-P2B-DAG: process section metadata
17-
# CHECK-P2B-DAG: process metadata pre-CFG
16+
// CHECK-P2B-DAG: process section metadata
17+
// CHECK-P2B-DAG: process metadata pre-CFG
1818

19-
# FDATA: 0 [unknown] 0 1 main 0 1 0
20-
# PREAGG: B X:0 #main# 1 0
21-
*/
19+
// FDATA: 0 [unknown] 0 1 main 0 1 0
20+
// PREAGG: B X:0 #main# 1 0
2221
int main() { return 0; }

0 commit comments

Comments
 (0)