ctiller opened PR #14646 from ctiller:fix/else-end-operator-fuel to bytecodealliance:main:
FuncEnvironment::fuel_before_oppreviously added the operator cost for every instruction other thanNopandDropbeforetranslate_operatorran, guarded bystate.reachableat instruction entry. ForOperator::ElseandOperator::End, this caused two bugs when customOperatorCostvalues were configured:
- At entry to
Operator::Else,builderis still positioned at the end of thethenblock beforetranslate_operatoremits the jump toexit_blockand switchesbuilderto theelseblock. ChargingElseinfuel_before_optherefore chargedElsewhen thethenbranch was taken and failed to chargeElsewhen theelsebranch was taken.- When the
thenblock (or the body precedingEnd) ended with an unconditional control transfer (return,br, etc.),state.reachablewasfalseenteringElseorEnd, sobefore_translate_operatorskippedfuel_before_opeven when theelseblock or mergedEndblock was reachable via another incoming edge.Defer
Operator::ElseandOperator::Endfuel charging fromfuel_before_optofuel_after_op, aftertranslate_operatorhas switchedbuilderto the target block and updatedstate.reachable.Assisted-by: Gemini
ctiller requested pchickey for a review on PR #14646.
ctiller requested wasmtime-core-reviewers for a review on PR #14646.
ctiller requested alexcrichton for a review on PR #14646.
ctiller requested wasmtime-compiler-reviewers for a review on PR #14646.
ctiller updated PR #14646.
:thumbs_up: cfallin submitted PR review.
cfallin added PR #14646 cranelift: charge Else and End operator fuel in target blocks to the merge queue.
github-merge-queue[bot] removed PR #14646 cranelift: charge Else and End operator fuel in target blocks from the merge queue.
alexcrichton added PR #14646 cranelift: charge Else and End operator fuel in target blocks to the merge queue.
:check: alexcrichton merged PR #14646.
alexcrichton removed PR #14646 cranelift: charge Else and End operator fuel in target blocks from the merge queue.
Last updated: Oct 11 2026 at 04:10 UTC