diff options
author | Steven Wu <stevenwu@apple.com> | 2021-05-20 09:53:55 -0700 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2021-05-20 09:54:38 -0700 |
commit | 5b6cae5524905bc43cfc21a515f828528d1f2e68 (patch) | |
tree | 541c90e4b1a1d8579be9017853d15c14783aa3f8 /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 136ced498ba84f6b6126051626e319f18ba740f5 (diff) | |
download | llvm-5b6cae5524905bc43cfc21a515f828528d1f2e68.zip llvm-5b6cae5524905bc43cfc21a515f828528d1f2e68.tar.gz llvm-5b6cae5524905bc43cfc21a515f828528d1f2e68.tar.bz2 |
[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
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 7272951..ea655f9 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -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())); } } |