This is an archive of the discontinued LLVM Phabricator instance.

[SROA] Add new test cases to cover existing SROA behavior that structs will be scalarized.
ClosedPublic

Authored by mingmingl on Nov 17 2021, 4:45 PM.

Details

Summary

Add an IR in unit test directory, which demonstrate the scalarization for struct allocations.
This is added to pave the way for an SROA change to skip scalarization for some cases.

Diff Detail

Event Timeline

mingmingl requested review of this revision.Nov 17 2021, 4:45 PM
mingmingl created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptNov 17 2021, 4:45 PM
mingmingl updated this revision to Diff 388067.Nov 17 2021, 4:51 PM
lebedev.ri retitled this revision from Add an IR to test that allocations of struct are scalarized. to [SROA] Add an IR to test that allocations of struct are scalarized..Nov 18 2021, 12:37 AM
lebedev.ri added inline comments.
llvm/test/Transforms/SROA/alloca-struct.ll
1

Please just use auto-update test like in the other tests here

davidxl added inline comments.Nov 18 2021, 9:07 AM
llvm/test/Transforms/SROA/alloca-struct.ll
31

remove %test.addr

32

same here

33

remove %frombool

35

Remove the above two stores

36

remove load

37

remove

38

Replace %tobool with %test

48

remove load

49

replace %1 with %p

61

Similar cleanup can be done for this test cse.

lebedev.ri added a comment.EditedNov 18 2021, 9:36 AM

(disclaimer for the change itself: note that it is not sufficient to check that there are scalar loads/stores, it'd miss the point of SROA.)

mingmingl updated this revision to Diff 388308.Nov 18 2021, 1:29 PM

Simplify IR by cleaning up alloca instructions for function parameters, and
cleaning up attributes as well as some unused metadata.

mingmingl marked 10 inline comments as done.Nov 18 2021, 1:43 PM

(disclaimer for the change itself: note that it is not sufficient to check that there are scalar loads/stores, it'd miss the point of SROA.)

It's true. This test is added with the goal to demonstrate how current sroa works, and for a planned patch, it will slightly change the scalarization, so this IR will be updated.

llvm/test/Transforms/SROA/alloca-struct.ll
1

Some unit tests run the auto-update while others doesn't (e.g., https://github.com/llvm/llvm-project/blob/main/llvm/test/Transforms/SROA/fca.ll is not updated by auto-updater)

For this IR, using auto-updater inserts quite many checker lines and somewhat hard to read. So will keep the current format.

mingmingl updated this revision to Diff 388333.Nov 18 2021, 2:44 PM

Clean up all metadata for simplicity.

davidxl accepted this revision.Nov 19 2021, 9:06 AM

lgtm (perhaps change the title of the patch to 'Add new test cases to cover existing SROA behavior'.

This revision is now accepted and ready to land.Nov 19 2021, 9:06 AM
mingmingl retitled this revision from [SROA] Add an IR to test that allocations of struct are scalarized. to [SROA] Add new test cases to cover existing SROA behavior that structs will be scalarized..Nov 19 2021, 9:13 AM