diff options
author | Steven Wu <stevenwu@apple.com> | 2021-05-11 08:23:08 -0700 |
---|---|---|
committer | Steven Wu <stevenwu@apple.com> | 2021-05-11 08:23:55 -0700 |
commit | 4eff9469475384a59a9da407e78aa00262edcdd0 (patch) | |
tree | a5d56bb2277d2d7daa414fbc9304a4c9219fb34f /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | d6a228cba47ffb33d4f6814af1feaf49b34568d0 (diff) | |
download | llvm-4eff9469475384a59a9da407e78aa00262edcdd0.zip llvm-4eff9469475384a59a9da407e78aa00262edcdd0.tar.gz llvm-4eff9469475384a59a9da407e78aa00262edcdd0.tar.bz2 |
[IR][AutoUpgrade] Drop align attribute from void return types
Since D87304, `align` become an invalid attribute on none pointer types and
verifier will reject bitcode that has invalid `align` attribute.
The problem is before the change, DeadArgumentElimination can easily
turn a pointer return type into a void return type without removing
`align` attribute. Teach Autograde to remove invalid `align` attribute
from return types to maintain bitcode compatibility.
rdar://77022993
Reviewed By: dexonsmith
Differential Revision: https://reviews.llvm.org/D102201
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 46db3ed..38d7b77 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -5562,8 +5562,8 @@ Error BitcodeReader::materialize(GlobalValue *GV) { } } - // "Upgrade" older incorrect branch weights by dropping them. for (auto &I : instructions(F)) { + // "Upgrade" older incorrect branch weights by dropping them. if (auto *MD = I.getMetadata(LLVMContext::MD_prof)) { if (MD->getOperand(0) != nullptr && isa<MDString>(MD->getOperand(0))) { MDString *MDS = cast<MDString>(MD->getOperand(0)); @@ -5590,6 +5590,12 @@ Error BitcodeReader::materialize(GlobalValue *GV) { I.setMetadata(LLVMContext::MD_prof, nullptr); } } + + // Remove align from return attribute on CallInst. + if (auto *CI = dyn_cast<CallInst>(&I)) { + if (CI->getFunctionType()->getReturnType()->isVoidTy()) + CI->removeAttribute(0, Attribute::Alignment); + } } // Look for functions that rely on old function attribute behavior. |