This is an archive of the discontinued LLVM Phabricator instance.

[argprom] Assessing impact of magic value MaxElements promoted on compiler performance
AbandonedPublic

Authored by teamiceberg on Jul 13 2020, 10:40 PM.

Details

Reviewers
jdoerfert
Summary

Our initial hypothesis is that changes to the magic value of (unsigned) MaxElements variable in ArgumentPromotion.cpp/ArgumentPromotion.h file can
lead to changes in compiler performance. To assess such changes, we have to introduce a global variable in the ArgumentPromotion.h header file. Then, we supply different values for this global variable by having a command line flag (-numargspromoted) bound to this global variable via the cl::opt interface. Initial analysis of compiler performance using the built in test suite demonstrate some significant changes in compile time as well as run time.
However, we are in the process of validating if these changes are real or just noise induced by other means. More experiments and sample runs need to be run, to be sure. However, we are setting up this initial patch as a way to learn how to setup a pipeline to enable the use of global variables to simulate magic values. Also, we are designing LIT tests to ensure that we submit a patch that conforms to built-in argument promotion tests in llvm/test folder.
Regression Test Setup: /llvm/test/Transforms/ArgumentPromotion has 3 tests written by me a) fourmember-struct-promote-ZERO.ll; b)fourmember-struct-promote-DEFAULT.ll ; c) fourmember-struct-promote-INTMAX.ll to demonstrate that the flag works successfully.
Regression Test success criteria: For aggregate arguments, such as structs, by design only a maximum of 3 members are promoted (DEFAULT case). However by introducing a custom OPT flag, we can set this number to different values to promote any number of an aggregate's arguments. For instance, the regression test file "fourmember-struct-promote-xxx.ll" has a four member struct passed by reference to a simple function that sums the values of the members. The flag '-numargspromoted' value has to be 0 or 4 or higher for all the 4 members in the struct to be promoted. '0' defaults to 'always promote'. Supplying a value less than th number of members in the aggregate (in this case 4) halts promotion. The regression tests are designed to PASS when the FILECHECK tool pattern matches against an output that reflects all members have been promoted to "by value".

RESULTS:

  • fourmember-struct-promote-ZERO and fourmember-struct-promote-INTMAX pass.
  • fourmember-struct-promote-DEFAULT fails, as we allow only 3 members to be promoted whereas the struct has 4 members.

Therefore, we conclude that the -numargspromoted user flag works correctly.

Now that we have this flag working correctly, we can test out the impact of the argument promotion of aggregates on compile time and run time performance.

Diff Detail

Event Timeline

teamiceberg created this revision.Jul 13 2020, 10:40 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 13 2020, 10:40 PM

Updated with comments for MaxElements global variable in ArgumentPromotion.h file

teamiceberg edited the summary of this revision. (Show Details)Jul 13 2020, 10:56 PM
teamiceberg edited the summary of this revision. (Show Details)

Updated with LIT test files for regression tests

teamiceberg edited the summary of this revision. (Show Details)Jul 14 2020, 2:11 AM
jdoerfert added inline comments.Jul 14 2020, 5:08 AM
llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
98

Can you please update this diff to be against a proper commit of the master branch?

teamiceberg abandoned this revision.Jul 14 2020, 6:47 PM
teamiceberg marked 2 inline comments as done.

A new patch will be put in to baseline against the latest LLVM Master Commit (at least at the time of uploading this patch).

llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
98

I am putting in a new diff so it can against the very latest master commit. SO I will be abandoning this patch.