This is an archive of the discontinued LLVM Phabricator instance.

CodeGen: Let frame index value type match alloca addr space
ClosedPublic

Authored by yaxunl on Apr 13 2017, 8:35 AM.

Details

Summary

Recently alloca address space has been added to data layout. Due to this change, pointer returned by alloca may have different size as pointer in address space 0.

However, currently the value type of frame index is assumed to be of the same size as pointer in address space 0.

This patch fixes that.

Most targets assume alloca returning pointer in address space 0, which is the default alloca address space. Therefore it is NFC for them.

AMDGCN target with amdgiz environment requires this change since it assumes alloca returning pointer to addr space 5 and its size is 32, which is different from the size of pointer in addr space 0 which is 64.

Diff Detail

Repository
rL LLVM

Event Timeline

yaxunl created this revision.Apr 13 2017, 8:35 AM
arsenm edited edge metadata.Apr 13 2017, 11:30 AM

Can you add a test using the new mapping for this

lib/CodeGen/SelectionDAG/SelectionDAG.cpp
1829 ↗(On Diff #95134)

Add a new TLI->getAllocaPointerTy?

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
5418 ↗(On Diff #95134)

This one hasn't been updated with mangling yet, so might as well leave it for now

t-tye edited reviewers, added: t-tye; removed: tony-tye.Apr 13 2017, 7:14 PM
arsenm added inline comments.Apr 14 2017, 9:41 AM
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
1829 ↗(On Diff #95134)

getFrameIndexTy would be better

yaxunl marked 3 inline comments as done.Apr 17 2017, 2:26 PM
yaxunl added inline comments.
lib/CodeGen/SelectionDAG/SelectionDAG.cpp
1829 ↗(On Diff #95134)

will do.

lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
5418 ↗(On Diff #95134)

will do.

yaxunl updated this revision to Diff 95580.Apr 18 2017, 8:52 AM
yaxunl marked 2 inline comments as done.

Revised as Matt suggested.

t-tye accepted this revision.Apr 18 2017, 9:25 AM

LGTM

This revision is now accepted and ready to land.Apr 18 2017, 9:25 AM

Ping. Any further comments? Thanks.

arsenm accepted this revision.Apr 19 2017, 10:53 AM

LGTM with test cleanups

test/CodeGen/AMDGPU/frame-index-amdgiz.ll
14 ↗(On Diff #95580)

Drop metadata

54 ↗(On Diff #95580)

Strip unnecessary string attributes

58 ↗(On Diff #95580)

You can drop this

This revision was automatically updated to reflect the committed changes.