[clang] [lld] [llvm] [LLVM][WebAssembly] Implement branch hinting proposal (PR #146230)
Derek Schuff via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 23 17:46:01 PDT 2026
Lukas =?utf-8?q?Döllerer?= <contact at lukas-doellerer.de>,
Lukas =?utf-8?q?Döllerer?= <contact at lukas-doellerer.de>,
Lukas =?utf-8?q?Döllerer?= <contact at lukas-doellerer.de>,
Lukas =?utf-8?q?Döllerer?= <contact at lukas-doellerer.de>,
Lukas =?utf-8?q?Döllerer?= <contact at lukas-doellerer.de>,
Lukas =?utf-8?q?Döllerer?= <contact at lukas-doellerer.de>,
Lukas =?utf-8?q?Döllerer?= <lukas.doellerer at tum.de>,
Lukas =?utf-8?q?Döllerer?= <contact at lukas-doellerer.de>,
Lukas =?utf-8?q?Döllerer?= <contact at lukas-doellerer.de>,
Lukas =?utf-8?q?Döllerer?= <lukas.doellerer at tum.de>,
Lukas =?utf-8?q?Döllerer?= <lukas.doellerer at tum.de>,
Lukas =?utf-8?q?Döllerer?= <lukas.doellerer at tum.de>,
Lukas =?utf-8?q?Döllerer?= <lukas.doellerer at tum.de>,
Lukas =?utf-8?q?Döllerer?= <lukas.doellerer at tum.de>,Derek Schuff
<dschuff at chromium.org>,Derek Schuff <dschuff at chromium.org>,Derek Schuff
<dschuff at chromium.org>,Derek Schuff <dschuff at chromium.org>,Derek Schuff
<dschuff at chromium.org>,Derek Schuff <dschuff at chromium.org>,Derek Schuff
<dschuff at chromium.org>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/146230 at github.com>
================
@@ -97,6 +102,33 @@ bool WebAssemblyAsmBackend::writeNopData(raw_ostream &OS, uint64_t Count,
return true;
}
+std::optional<bool> WebAssemblyAsmBackend::evaluateFixup(const MCFragment &,
+ MCFixup &Fixup,
+ MCValue &Target,
+ uint64_t &Value) {
+ if (Fixup.getKind() == WebAssembly::fixup_uleb128_i32 &&
+ static_cast<WebAssembly::Specifier>(Target.getSpecifier()) ==
+ WebAssembly::S_None) {
+ if (const auto *SymExpr =
+ dyn_cast_or_null<MCSymbolRefExpr>(Fixup.getValue())) {
+ // only evaluate fixups for temporary symbols
+ // (in-function offsets for compilation hints metadata)
+ if (const MCSymbol &SymA = SymExpr->getSymbol();
----------------
dschuff wrote:
This is indeed a bit of a weird situation; I think some of the weirdness is because of the way wasm uses LEB128 pervasively; and usually we want to avoid relaxing it but sometimes we want to treat it more "normally" e.g. for use in DWARF. Here in this case we want to evaluate it only for this particular use case but let it go out to the object as a relocation in other cases. I'm open to any actual suggestions to simplify it further.
https://github.com/llvm/llvm-project/pull/146230
More information about the cfe-commits
mailing list