Skip to content

Conversation

@paschalis-mpeis
Copy link
Member

@paschalis-mpeis paschalis-mpeis commented Oct 21, 2024

Allow using hardcoded offsets to blocks, eg:

// RUN: link_fdata --no-lbr ...
// FDATA: 1 foo 0 10

For LBR mode this was already supported. See for example:

  • tail-duplication-complex.s

For example, the below fails as the script tries to match it with the
LBR mode:

```
// RUN: link_fdata --no-lbr ...
// FDATA: 1 foo 0 10
```
Allow using hardcoded offsets to blocks, eg:
```
// RUN: link_fdata --no-lbr ...
// FDATA: 1 foo 0 10
```

For LBR mode this was already supported. See for example:
- tail-duplication-complex.s
@paschalis-mpeis paschalis-mpeis changed the title Users/paschalis mpeis/bolt link fdata nolbr [BOLT] link_fdata support for hardcoded offsets in no-LBR Oct 21, 2024
@paschalis-mpeis paschalis-mpeis marked this pull request as ready for review October 21, 2024 13:15
@llvmbot llvmbot added the BOLT label Oct 21, 2024
@llvmbot
Copy link
Member

llvmbot commented Oct 21, 2024

@llvm/pr-subscribers-bolt

Author: Paschalis Mpeis (paschalis-mpeis)

Changes

Allow using hardcoded offsets to blocks, eg:

// RUN: link_fdata --no-lbr ...
// FDATA: 1 foo 0 10

For LBR mode this was already supported. See for example:

  • tail-duplication-complex.s

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

2 Files Affected:

  • (added) bolt/test/AArch64/fdata-nolbr.s (+19)
  • (modified) bolt/test/link_fdata.py (+1-1)
diff --git a/bolt/test/AArch64/fdata-nolbr.s b/bolt/test/AArch64/fdata-nolbr.s
new file mode 100644
index 00000000000000..5d7c0a4014986e
--- /dev/null
+++ b/bolt/test/AArch64/fdata-nolbr.s
@@ -0,0 +1,19 @@
+# Check that using link_fdata tool in non-lbr mode allows using hardcoded
+# addresses for basic block offsets.
+
+# REQUIRES: system-linux
+
+# RUN: %clang %cflags -o %t %s
+# RUN: %clang %s %cflags -Wl,-q -o %t
+# RUN: link_fdata --no-lbr %s %t %t.fdata
+# RUN: cat %t.fdata | FileCheck %s
+
+  .text
+  .globl  foo
+  .type foo, %function
+foo:
+# FDATA: 1 foo 0 10
+    ret
+
+# CHECK: no_lbr
+# CHECK-NEXT: 1 foo 0 10
diff --git a/bolt/test/link_fdata.py b/bolt/test/link_fdata.py
index 3837e394ccc87b..613d58248bb052 100755
--- a/bolt/test/link_fdata.py
+++ b/bolt/test/link_fdata.py
@@ -58,7 +58,7 @@
         fdata_match = fdata_pat.match(profile_line)
         preagg_match = preagg_pat.match(profile_line)
         nolbr_match = nolbr_pat.match(profile_line)
-        if fdata_match:
+        if fdata_match and not (nolbr_match and args.no_lbr):
             src_dst, execnt, mispred = fdata_match.groups()
             # Split by whitespaces not preceded by a backslash (negative lookbehind)
             chunks = re.split(r"(?<!\\) +", src_dst)

@paschalis-mpeis
Copy link
Member Author

Just adding that people could (and are) using LBR mode with link_fdata to set hardcoded offsets to blocks, regardless of architecture. So there is a way without this minor patch.

Based on that I could be closing this PR unless I hear otherwise in the next couple of days.

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