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 both compile time and run time compiler performance. To assess such changes, we extern declare a global variable (unsigned MaxElemsToPromote) in the IPO.h header file (default defined to 3 in ArgumentPromotion.h). Then, we supply different values for this global variable through an OPT command line flag (-argpromotion-max-elements-to-promote) 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, including beneficial changes(reductions in CT/RT) for some test cases.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 a LIT test in llvm/tests folder to ensure that we submit a patch that demonstrates that the OPT flag works.
Regression Test Setup: /llvm/test/Transforms/ArgumentPromotion has 1 test written by me (fourmember-struct-promote.ll) which demonstrates the flag works successfully.
Regression Test success criteria: For aggregate arguments, such as structs, by design only a maximum of 3 members are promoted. 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.ll" has a four member struct passed by reference to a simple callee that sums the values of the members. The flag '-argpromotion-max-elements-to-promote' value has to be 0 or 4 (or higher) for all 4 members in the struct to be promoted. '0' defaults to 'always promote'. Supplying a value less than the 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" for -argpromotion-max-elements-to-promote=[0 , 3, INT_MAX] cases respectively.
RESULTS:
fourmember-struct-promote.ll test PASSES according to success criteria defined above.
Therefore, we conclude that the --argpromotion-max-elements-to-promote user flag works correctly.
Now that we have this flag working correctly, users can test out the impact of argument promotion of elements of aggregates on compile time and run time performance.
clang-format not found in user's PATH; not linting file.