[all-commits] [llvm/llvm-project] 91ef93: [GlobalOpt] Remove preallocated calls when possible

aeubanks via All-commits all-commits at lists.llvm.org
Thu Jun 18 10:01:48 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 91ef9305268760727e8cc90e2542a803621b2336
      https://github.com/llvm/llvm-project/commit/91ef9305268760727e8cc90e2542a803621b2336
  Author: Arthur Eubanks <aeubanks at google.com>
  Date:   2020-06-18 (Thu, 18 Jun 2020)

  Changed paths:
    M llvm/lib/Transforms/IPO/GlobalOpt.cpp
    M llvm/test/Transforms/GlobalOpt/fastcc.ll
    A llvm/test/Transforms/GlobalOpt/preallocated.ll

  Log Message:
  -----------
  [GlobalOpt] Remove preallocated calls when possible

When possible (e.g. internal linkage), strip preallocated attribute off
parameters/arguments.
This requires removing the "preallocated" operand bundle from the call
site, replacing @llvm.call.preallocated.arg() with an alloca and a
bitcast to i8*, and removing the @llvm.call.preallocated.setup(). Since
@llvm.call.preallocated.arg() can be called multiple times with the same
arg index, we create an alloca per arg index.
We add a @llvm.stacksave() where the @llvm.call.preallocated.setup() was
and a @llvm.stackrestore() after the preallocated call to prevent the
stack from blowing up. This is valid because the argument would normally
not exist on the stack after the call before the transformation.

This does not currently handle all possible preallocated calls. We will
need to figure out where to put @llvm.stackrestore() in the cases where
there is no obvious place to put it, for example conditional
preallocated calls, invokes.

This sort of transformation may need to be moved to somewhere more
accessible to accomodate similar transformations (like inlining) in the
future.

Reviewers: efriedma, hans

Subscribers: hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D80951




More information about the All-commits mailing list