KEMBAR78
Jit: move runtime lookup expansion to lower · Issue #35551 · dotnet/runtime · GitHub
Skip to content

Jit: move runtime lookup expansion to lower #35551

@erozenfeld

Description

@erozenfeld

This is a follow-up to #341.

The jit currently expands runtime lookups in the importer (impRuntimeLookupToTree). The optimal expansion requires introducing control flow either via GT_QMARK or via IndirectCallTransformer.

The tail call via helpers mechanism introduced in #341 also needs to insert runtime lookups. The expansion of tail calls via helpers happens in morph and it's impossible to change control flow there the way it's done in the importer. Because of that the runtime lookups introduced in morph use the slower helper call expansion:

// If the first condition is true, runtime lookup tree is available only via the run-time helper function.
// TODO-CQ If the second or third condition is true, we are always using the slow path since we can't
// introduce control flow at this point. See impRuntimeLookupToTree for the logic to avoid calling the helper.
// The long-term solution is to introduce a new node representing a runtime lookup, create instances
// of that node both in the importer and here, and expand the node in lower (introducing control flow if
// necessary).
return gtNewRuntimeLookupHelperCallNode(pRuntimeLookup,
getRuntimeContextTree(pLookup->lookupKind.runtimeLookupKind),
compileTimeHandle);

The suggested solution is to move the expansion of runtime lookups to lower so that both the importer and morph can just create and insert a new node representing a runtime lookup and have lower expand it in an optimal way. This will involve teaching optimization phases (e.g., value numbering) about the new runtime lookup node.

category:cq
theme:helpers
skill-level:intermediate
cost:medium

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions