[clang] [lld] [llvm] [LLVM][WebAssembly] Implement branch hinting proposal (PR #146230)
Lukas Döllerer via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 29 15:03:27 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'
----------------
Lukasdoe wrote:
Very good idea, I just did not think about that option. Implemented yaml parsing for branch hints now anyways, so we now test both representations.
https://github.com/llvm/llvm-project/pull/146230
More information about the llvm-commits
mailing list