Skip to content

Remove GT_ASG nodes #10873

@mikedn

Description

@mikedn

This came up occasionally in discussions but AFAIK there's no issue associated with it and IMO there should be due to the significant (negative) impact GT_ASG nodes have on RyuJIT's IR.

IMO it's one of the worst IR "features", if not plain and simple the worst. So far I only encountered pros and no cons:

  • It's an extra IR node - wastes memory and slows down IR traversal.
  • It imposes a model where the meaning of some nodes depends on the context - a GT_LCL_VAR on the RHS is a use but on the LHS is a def. The JIT uses various means to deal with this issue - GTF_VAR_DEF, GTF_IND_ASG_LHS, gtGetParent() etc.
  • It complicates UD chain traversal. SSA gives you the GT_LCL_VAR node on the LHS, from there you need to use gtGetParent() to get the GT_ASG node and then get the assignment's second operand. If you're lucky the LHS follow the assignment, otherwise gtGetParent() will need to traverse multiple nodes.
  • It requires additional work to transform HIR into LIR, the later does not use assignment nodes.
  • It doesn't match the IL model that uses stores. While I don't think that the IR has to strictly follow the IL model this one seems like a huge and unnecessary deviation.
  • It doesn't follow the assembly model either. One could argue that mov eax, ebx is assignment but that's only true if eax and ebx happen to be enregistered variables. Otherwise you'd be looking at mov [eax], ebx which is more similar to a store.

Anyone knows any advantages?

AFAIR Phoenix did have Assign but its IR was very different, looking more like assembly. I know next to nothing about LLVM but I don't think it has assignment.

category:implementation
theme:ir
skill-level:expert
cost:extra-large

Metadata

Metadata

Labels

JitUntriagedCLR JIT issues needing additional triagearea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMIdesign-discussionOngoing discussion about design without consensus

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions