[llvm] [DeadArgElim] Renumber allocsize instead of dropping it (PR #221868)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 8 05:52:45 PDT 2026
================
@@ -839,9 +854,42 @@ bool DeadArgumentEliminationPass::removeDeadStuffFromFunction(Function *F) {
AttributeSet RetAttrs = AttributeSet::get(F->getContext(), RAttrs);
- // Strip allocsize attributes. They might refer to the deleted arguments.
- AttributeSet FnAttrs =
- PAL.getFnAttrs().removeAttribute(F->getContext(), Attribute::AllocSize);
+ // allocsize names parameters by index, so deleting an argument ahead of one
+ // renumbers it. surveyFunction() keeps the arguments allocsize points at
+ // alive, so renumber the attribute rather than dropping it; drop it only if
+ // they went away regardless, which leaves the callee no way to report the
+ // size it allocates.
----------------
nikic wrote:
I see, thanks. In that case my next question would be: *Should* call-site allocsize() also prevent the transform? (The question is not rhetorical, I'm not entirely sure... but it seems a bit inconsistent as implemented.)
https://github.com/llvm/llvm-project/pull/221868
More information about the llvm-commits
mailing list