[DeadArgElim] Remove allocsize attributes on callsites

We're already removing allocsize attributes from Functions that we
remove args from, since removing arguments from a function may make the
allocsize attribute incorrect. It appears we forgot to also remove them
from callsites.

Without this, I get verifier errors on `@Test2`.

It probably wouldn't be too hard to make DAE properly update allocsize
attributes instead of dropping them, but I can't think of a scenario
where that'd be useful in practice.

llvm-svn: 329868
This commit is contained in:
George Burgess IV 2018-04-12 02:06:01 +00:00
parent a8c689e70c
commit 48ee59b6f0
2 changed files with 12 additions and 1 deletions

View File

@ -916,8 +916,14 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
// Reconstruct the AttributesList based on the vector we constructed.
assert(ArgAttrVec.size() == Args.size());
// Again, be sure to remove any allocsize attributes, since their indices
// may now be incorrect.
AttributeSet FnAttrs = CallPAL.getFnAttributes().removeAttribute(
F->getContext(), Attribute::AllocSize);
AttributeList NewCallPAL = AttributeList::get(
F->getContext(), CallPAL.getFnAttributes(), RetAttrs, ArgAttrVec);
F->getContext(), FnAttrs, RetAttrs, ArgAttrVec);
SmallVector<OperandBundleDef, 1> OpBundles;
CS.getOperandBundlesAsDefs(OpBundles);

View File

@ -11,3 +11,8 @@ define i64 @NeedsArg(i64 %s) {
%c = call i64 @MagickMallocAligned(i64 0, i64 %s)
ret i64 %c
}
define i64 @Test2(i64 %s) {
%c = call i64 @MagickMallocAligned(i64 0, i64 %s) allocsize(1)
ret i64 %c
}