[PATCH] D61286: Skip functions with inallocas in argpromotion
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 11:56:13 PDT 2019
rnk added a comment.
Now that I see we already had an optimization for inalloca, I'm hesitant to lose it. I think there's a simple fix, though. We can just remove inalloca in any situation where we could do argument promotion.
Hoisting the dynamic alloca to the entry block and stripping the inalloca marker off of it are also nice improvements, but they aren't necessary for correctness.
================
Comment at: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:152
Params.push_back(I->getType());
ArgAttrVec.push_back(PAL.getParamAttributes(ArgNo));
} else if (I->use_empty()) {
----------------
I think the simplest fix that preserves the existing optimization would be to strip off inalloca from the parameter and argument attributes. I think it's just a matter of pulling off inalloca here, and on the call site.
================
Comment at: llvm/lib/Transforms/IPO/ArgumentPromotion.cpp:255-257
if (!ArgsToPromote.count(&*I) && !ByValArgsToTransform.count(&*I)) {
Args.push_back(*AI); // Unmodified argument
ArgAttrVec.push_back(CallPAL.getParamAttributes(ArgNo));
----------------
This is where you would remove inalloca from the call site attribute list.
Optionally, if inalloca was present and you are removing it, you could check if the value passed into the call site is a pointer to a dynamic alloca marked inalloca, and if so turn it into a static alloca by stripping the inalloca marker and hoisting it to the entry block. That's not necessary for correctness, though.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61286/new/
https://reviews.llvm.org/D61286
More information about the llvm-commits
mailing list