[clang] [lld] [llvm] [LLVM][WebAssembly] Implement branch hinting proposal (PR #146230)
Alexis Engelke via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 29 04:39:51 PDT 2025
================
@@ -0,0 +1,79 @@
+; RUN: llc -mcpu=mvp -filetype=obj %s -mattr=+branch-hinting -wasm-branch-prob-high=0x60000000 -wasm-branch-prob-low=0x0 -o - | obj2yaml | FileCheck %s
+
+; This test checks that branch weight metadata (!prof) is correctly translated to webassembly branch hints
+; We set the prob-thresholds so that "likely" branches are only emitted if prob > 75% and "unlikely" branches
+; if prob <= 0%.
+
+; CHECK: - Type: CUSTOM
+; CHECK-NEXT: Relocations:
+; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
+; CHECK-NEXT: Index: 0
+; CHECK-NEXT: Offset: 0x5
+; CHECK-NEXT: - Type: R_WASM_FUNCTION_INDEX_LEB
+; CHECK-NEXT: Index: 2
+; CHECK-NEXT: Offset: 0xE
+; CHECK-NEXT: Name: metadata.code.branch_hint
+; CHECK-NEXT: Payload: '8380808000808080800001050101828080800001050100'
----------------
aengelke wrote:
Why not test with the textual llc output? Would be more readable and also include the assembly code. Right now it is not easy to see what this means and that this is indeed the expected outcome (I haven't verified).
https://github.com/llvm/llvm-project/pull/146230
More information about the llvm-commits
mailing list