[IR][AutoUpgrade] Drop alignment from non-pointer parameters and returns

This is a follow-up of D102201. After some discussion, it is a better idea
to upgrade all invalid uses of alignment attributes on function return
values and parameters, not just limited to void function return types.

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D102726
This commit is contained in:
Steven Wu
2021-05-20 09:53:55 -07:00
parent 136ced498b
commit 5b6cae5524
7 changed files with 58 additions and 9 deletions

View File

@@ -5629,10 +5629,15 @@ Error BitcodeReader::materialize(GlobalValue *GV) {
}
}
// Remove align from return attribute on CallInst.
if (auto *CI = dyn_cast<CallInst>(&I)) {
if (CI->getFunctionType()->getReturnType()->isVoidTy())
CI->removeAttribute(0, Attribute::Alignment);
// Remove incompatible attributes on function calls.
if (auto *CI = dyn_cast<CallBase>(&I)) {
CI->removeAttributes(AttributeList::ReturnIndex,
AttributeFuncs::typeIncompatible(
CI->getFunctionType()->getReturnType()));
for (unsigned ArgNo = 0; ArgNo < CI->arg_size(); ++ArgNo)
CI->removeParamAttrs(ArgNo, AttributeFuncs::typeIncompatible(
CI->getArgOperand(ArgNo)->getType()));
}
}