Skip to content

[Wasm RyuJIT] Fix: Pass Call's struct type to Wasm ABI Classifier Instead of Dest Store Type - #133281

Open
adamperlin wants to merge 1 commit into
dotnet:mainfrom
adamperlin:adamperlin/wasm-single-reg-struct-store-fix
Open

[Wasm RyuJIT] Fix: Pass Call's struct type to Wasm ABI Classifier Instead of Dest Store Type#133281
adamperlin wants to merge 1 commit into
dotnet:mainfrom
adamperlin:adamperlin/wasm-single-reg-struct-store-fix

Conversation

@adamperlin

@adamperlinadamperlin commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

When we store the return value of a function returning a struct with a single reg return, the ABI classification may not match the destination's. For example,

V2<int>result=Unsafe.BitCast<Vector64<int>,V2<int>>(CreateVector());

with

[StructLayout(LayoutKind.Sequential)]privatestructV2<T>(Tx,Ty){publicTX=x;publicTY=y;}

V2 has a pass by ref ABI classification since it has two fields, whereas Vector64, the result of CreateVector(), has a by-value classification since Vector64 has only one field. We were using the struct ABI classification of the destination of the store in these cases instead of the return value of the call.

Resolves#133224

…consumer's type in LowerStoreSingleRegCallStruct
CopilotAI lite review requested due to automatic review settings September 5, 2026 00:51
@adamperlinadamperlin changed the title [Wasm RyuJIT] Fix: Pass Call's struct type to Wasm ABI Classifier Instead of Block Store Struct Type[Wasm RyuJIT] Fix: Pass Call's struct type to Wasm ABI Classifier Instead of Dest Store TypeSep 5, 2026
@github-actionsgithub-actionsBot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Sep 5, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 5 pipeline(s).
11 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @JulieLeeMSFT, @jakobbotsch
See info in area-owners.md if you want to be subscribed.

@adamperlinadamperlin added the arch-wasm WebAssembly architecture label Sep 5, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The Wasm lowering path still asserts CORINFO_WASM_TYPE_VOID can’t occur (despite the interface contract defining it as “by-ref”), which can still abort crossgen2 for valid shapes.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR adjusts Wasm-specific lowering for GT_STORE_BLK nodes sourced from single-register struct-returning calls by using the call’s return class handle (call->gtRetClsHnd) for Wasm ABI classification instead of using the store’s destination layout type.

Changes:

  • Use call->gtRetClsHnd as the input to getWasmLowering(...) in LowerStoreSingleRegCallStruct.
  • Retype the store based on the call’s Wasm ABI-lowered primitive type rather than the destination’s layout classification.
File summaries
FileDescription
src/coreclr/jit/lower.cppUpdates Wasm ABI classification source in LowerStoreSingleRegCallStruct to use the call return type.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 1
  • Review effort level: Lite

Comment on lines +6282 to +6284
CorInfoWasmType wasmAbiType = m_compiler->info.compCompHnd->getWasmLowering(call->gtRetClsHnd);
assert(wasmAbiType != CORINFO_WASM_TYPE_VOID);
regType = WasmClassifier::ToJitType(wasmAbiType);

@lewinglewing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've verified this fixes the linked issue and my read is that copilot's review is not correct.

@lewing

lewing commented Sep 5, 2026

Copy link
Copy Markdown
Member

I've also verified that the other wasm failures are known and in the set tracked by #133305

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasmWebAssembly architecturearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[wasm][R2R] crossgen2 asserts 'wasmAbiType != CORINFO_WASM_TYPE_VOID' in LowerStoreSingleRegCallStruct, aborting the whole Regression_ro_2 work item

3 participants

@adamperlin@lewing