[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
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user