[llvm] [BOLT] link_fdata support for hardcoded offsets in no-LBR (PR #113157)

via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 21 06:16:07 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-bolt

Author: Paschalis Mpeis (paschalis-mpeis)

<details>
<summary>Changes</summary>

  
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
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)

``````````

</details>


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


More information about the llvm-commits mailing list