ArgumentPromotion: Drop sret attribute on functions that are only called directly.
authorPeter Collingbourne <peter@pcc.me.uk>
Wed, 10 Jun 2015 21:14:34 +0000 (21:14 +0000)
committerPeter Collingbourne <peter@pcc.me.uk>
Wed, 10 Jun 2015 21:14:34 +0000 (21:14 +0000)
commit6e5bbb57e4bd70688e78000d92712496be7105f6
tree625ee20149a34182dc05bd96b776edc36a37b14b
parentc826b54b526e3d7cff34340bb45a3aa5cc0ab5a6
ArgumentPromotion: Drop sret attribute on functions that are only called directly.

If the first argument to a function is a 'this' argument and the second
has the sret attribute, the ArgumentPromotion pass may promote the 'this'
argument to more than one argument, violating the IR constraint that 'sret'
may only be applied to the first or second argument.

Although this IR constraint is arguably unnecessary, it highlighted the fact
that ArgPromotion does not need to preserve this attribute. Dropping the
attribute reduces register pressure in the backend by avoiding the register
copy required by sret. Because sret implies noalias, we also replace the
former with the latter.

Differential Revision: http://reviews.llvm.org/D10353

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@239488 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/Function.cpp
lib/Transforms/IPO/ArgumentPromotion.cpp
test/Transforms/ArgumentPromotion/sret.ll [new file with mode: 0644]