[clang] [lld] [llvm] [LLVM][WebAssembly] Implement branch hinting proposal (PR #146230)
Lukas Döllerer via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 28 07:18:01 PST 2025
================
@@ -0,0 +1,100 @@
+; RUN: llc -mcpu=mvp -filetype=asm %s -mattr=+branch-hinting -wasm-branch-prob-high=.5 -wasm-branch-prob-low=0.5 -o - | FileCheck --check-prefixes=C1 %s
+; RUN: llc -mcpu=mvp -filetype=asm %s -mattr=+branch-hinting -wasm-branch-prob-high=.76 -wasm-branch-prob-low=0 -o - | FileCheck --check-prefixes=C2 %s
+; RUN: llc -mcpu=mvp -filetype=asm %s -mattr=+branch-hinting -wasm-branch-prob-high=.75 -wasm-branch-prob-low=0 -o - | FileCheck --check-prefixes=C3 %s
+
+; C1: .section .custom_section.target_features,"",@
+; C1-NEXT: .int8 1
+; C1-NEXT: .int8 43
+; C1-NEXT: .int8 14
+; C1-NEXT: .ascii "branch-hinting"
+; C1-NEXT: .section .text.test2,"",@
+; C1: .section .custom_section.metadata.code.branch_hint,"",@
+; C1-NEXT: .int8 3
+; C1-DAG: .uleb128 test0 at FUNCINDEX
----------------
Lukasdoe wrote:
Sorry for the long downtime. This does assemble correctly, since during parsing of the assembly (for assembling to an object file in `llvm-mc`), the `AsmParser::parseDirectiveLEB128` function calls `MCWasmStreamer::emitULEB128Value` to emit the parsed uleb. This causes the uleb to be padded correctly.
So all-in-all: you are correct: this is what the asm backend change actually does. The ref is turned in a `MCExpr::SymbolRef` during parsing, which causes it to be padded correctly.
https://github.com/llvm/llvm-project/pull/146230
More information about the llvm-commits
mailing list