This is an archive of the discontinued LLVM Phabricator instance.

[GlobalISel] Replace hard coded dynamic alloca handling with G_DYN_STACKALLOC
ClosedPublic

Authored by aemerson on Aug 23 2019, 12:45 PM.

Details

Summary

This change moves the actual stack pointer manipulation into the legalizer, available to targets via lower(). The codegen is slightly different because we're using explicit masks instead of G_PTRMASK, and using G_SUB rather than adding a negative amount via G_GEP.

Diff Detail

Event Timeline

aemerson created this revision.Aug 23 2019, 12:45 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 23 2019, 12:45 PM
arsenm added inline comments.Aug 23 2019, 12:50 PM
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
1795–1796

SDNodeFlags?

1798–1800

buildAdd?

1803

Why not use PtrMask?

aemerson marked an inline comment as done.Aug 23 2019, 1:31 PM
aemerson added inline comments.
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
1803

Here's we're masking the allocation amount, which is an integer type, not a pointer, hence we can't use ptrmask.

aemerson updated this revision to Diff 216944.Aug 23 2019, 1:39 PM

Delete unused code and use buildAdd().

One nit, inlined, other then that looks good.

llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
3940

uint64_t or int64_t instead of unsigned?

3957

Or use explicit APInt for -Align here just to be sure we make bitmask of appropriate size/value.

llvm/test/CodeGen/AArch64/GlobalISel/legalize-dyn-alloca.mir
97

This bitmask seems strange, it looks like zeroextended 32 bit value -32 to a 64 bit value.

aemerson marked 2 inline comments as done.Aug 27 2019, 12:24 PM
aemerson added inline comments.
llvm/lib/CodeGen/GlobalISel/LegalizerHelper.cpp
3957

You're right, I'll fix this with APInt and commit.

aemerson accepted this revision.Aug 27 2019, 12:51 PM
This revision is now accepted and ready to land.Aug 27 2019, 12:51 PM
This revision was automatically updated to reflect the committed changes.