[PATCH] D83841: [argprom] Assessing impact of magic value MaxElements promoted on compiler performance

Shiva Badruswamy via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 14 18:51:19 PDT 2020


teamiceberg created this revision.
teamiceberg added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, hiraditya.
Herald added a project: LLVM.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D83841

Files:
  llvm/include/llvm/Transforms/IPO/ArgumentPromotion.h
  llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  llvm/test/Transforms/ArgumentPromotion/fourmember-struct-promote-DEFAULT.ll
  llvm/test/Transforms/ArgumentPromotion/fourmember-struct-promote-INTMAX.ll
  llvm/test/Transforms/ArgumentPromotion/fourmember-struct-promote-ZERO.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D83841.278044.patch
Type: text/x-patch
Size: 18570 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200715/4835f6f1/attachment.bin>


More information about the llvm-commits mailing list