Skip to content

[BOLT][NFC] Align fdata pattern ordering in link_fdata.py #142102

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

paschalis-mpeis
Copy link
Member

@paschalis-mpeis paschalis-mpeis commented May 30, 2025

The mispred and execnt values were originally recorded in reverse order and then consumed in the opposite order to compensate.

This patch records and uses them in the same order (FDATA) for clarity. That order is:

<is symbol?> <closest ELF symbol or DSO name> <relative FROM address> 
<is symbol?> <closest ELF symbol or DSO name> <relative TO address> 
<number of mispredictions> <number of branches>

The mispred and execnt values were originally recorded in reverse order and
then consumed in the opposite order to compensate.

This patch records and uses them in the same order (FDATA) for clarity.
That order is:
<is symbol?> <closest ELF symbol or DSO name> <relative FROM address>
<is symbol?> <closest ELF symbol or DSO name> <relative TO address>
<number of mispredictions> <number of branches>
@llvmbot
Copy link
Member

llvmbot commented May 30, 2025

@llvm/pr-subscribers-bolt

Author: Paschalis Mpeis (paschalis-mpeis)

Changes

The mispred and execnt values were originally recorded in reverse order and then consumed in the opposite order to compensate.

This patch records and uses them in the same order (FDATA) for clarity. That order is:
<is symbol?> <closest ELF symbol or DSO name> <relative FROM address> <is symbol?> <closest ELF symbol or DSO name> <relative TO address> <number of mispredictions> <number of branches>


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

1 Files Affected:

  • (modified) bolt/test/link_fdata.py (+3-3)
diff --git a/bolt/test/link_fdata.py b/bolt/test/link_fdata.py
index bcf9a777922d5..b6358fae1b8d0 100755
--- a/bolt/test/link_fdata.py
+++ b/bolt/test/link_fdata.py
@@ -33,7 +33,7 @@
 # <is symbol?> <closest elf symbol or DSO name> <relative FROM address>
 # <is symbol?> <closest elf symbol or DSO name> <relative TO address>
 # <number of mispredictions> <number of branches>
-fdata_pat = re.compile(r"([01].*) (?P<exec>\d+) (?P<mispred>\d+)")
+fdata_pat = re.compile(r"([01].*) (?P<mispred>\d+) (?P<exec>\d+)")
 
 # Pre-aggregated profile:
 # {T|B|F|f} [<start_id>:]<start_offset> [<end_id>:]<end_offset> [<ft_end>]
@@ -61,7 +61,7 @@
         preagg_match = preagg_pat.match(profile_line)
         nolbr_match = nolbr_pat.match(profile_line)
         if fdata_match:
-            src_dst, execnt, mispred = fdata_match.groups()
+            src_dst, mispred, execnt = fdata_match.groups()
             # Split by whitespaces not preceded by a backslash (negative lookbehind)
             chunks = re.split(r"(?<!\\) +", src_dst)
             # Check if the number of records separated by non-escaped whitespace
@@ -69,7 +69,7 @@
             assert (
                 len(chunks) == 6
             ), f"ERROR: wrong format/whitespaces must be escaped:\n{line}"
-            exprs.append(("FDATA", (*chunks, execnt, mispred)))
+            exprs.append(("FDATA", (*chunks, mispred, execnt)))
         elif nolbr_match:
             loc, count = nolbr_match.groups()
             # Split by whitespaces not preceded by a backslash (negative lookbehind)

Copy link
Contributor

@maksfb maksfb left a comment

Choose a reason for hiding this comment

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

Thanks!

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.

4 participants