This is an archive of the discontinued LLVM Phabricator instance.

[CodeGen] Make CreateStackTemporary work for scalable vectors
AbandonedPublic

Authored by david-arm on May 12 2020, 5:52 AM.

Details

Summary

In CreateStackTemporary we were promoting alignments beyond the
stack alignment, which I have fixed in this patch. In addition, we
need to set the stack id explicitly for scalable vectors so that
we allocate the correct amount of stack using vscale.

I added a test to

CodeGen/AArch64/sve-insert-element.ll

that tries to insert an element into an illegal scalable vector
type that involves creating temporary stack objects.

Diff Detail

Event Timeline

david-arm created this revision.May 12 2020, 5:52 AM
sdesmalen added inline comments.
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2020

Can you split this patch up into two patches:

  • one that prevents the stack temporary to exceed the stack alignment (which also needs tests for fixed-width vectors). Please also add @efriedma as reviewer to these patches, since he recently fixed a very similar problem in D79532.
  • another to make createStackTemporary support scalable types.
david-arm marked an inline comment as done.May 12 2020, 11:33 PM
david-arm added inline comments.
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
2020

Sure. It will take me a long time to get a patch ready for the stack alignment fix anyway due to it breaking 64 tests!

david-arm abandoned this revision.May 13 2020, 2:06 AM

This patch will be split into two patches in this submission order:

  1. A patch to fix the alignment and fix up all of the tests, which will take time since at least some of the tests were using the alignment as a convenient way to defend bug fixes for instruction selection, etc.
  2. A patch to add scalable vector support for CreateStackTemporary.

I've decided to abandon this revision for now and will create new ones later.

I would split the patch into the following steps:

  1. Introduce the new CreateStackTemporary(TypeSize, Align) API, and refactor the code.
  2. Set the StackID in CreateStackTemporary
  3. Fix the APIs that take a VT to choose more appropriate alignment. This is the hard part; probably requires some work to make the interaction between the alignment assumed by the users, vs. the actual alignment, work correctly. Probably makes sense to do this last; you might end up splitting this into multiple patches and/or change users of the API.