[PATCH] D102201: [IR][AutoUpgrade] Drop align attribute from void return types
Steven Wu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 11 08:24:15 PDT 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4eff94694753: [IR][AutoUpgrade] Drop align attribute from void return types (authored by steven_wu).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D102201/new/
https://reviews.llvm.org/D102201
Files:
llvm/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/lib/IR/AutoUpgrade.cpp
llvm/test/Bitcode/upgrade-void-ret-attr-11.0.ll
llvm/test/Bitcode/upgrade-void-ret-attr-11.0.ll.bc
Index: llvm/test/Bitcode/upgrade-void-ret-attr-11.0.ll
===================================================================
--- /dev/null
+++ llvm/test/Bitcode/upgrade-void-ret-attr-11.0.ll
@@ -0,0 +1,14 @@
+; Check upgrade is removing the incompatible attributes on void return type.
+
+; RUN: llvm-dis < %s.bc | FileCheck %s
+
+; CHECK: define void @f()
+define align 8 void @f() {
+ ret void
+}
+
+define void @g() {
+; CHECK: call void @f()
+ call align 8 void @f();
+ ret void
+}
Index: llvm/lib/IR/AutoUpgrade.cpp
===================================================================
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -4371,6 +4371,12 @@
Attribute NewAttr = Attribute::getWithByValType(F.getContext(), ByValTy);
F.addParamAttr(0, NewAttr);
}
+
+ // If function has void return type, check it has align attribute. It has no
+ // affect on the return type and no longer passes the verifier.
+ if (F.getReturnType()->isVoidTy() &&
+ F.hasAttribute(AttributeList::ReturnIndex, Attribute::Alignment))
+ F.removeAttribute(AttributeList::ReturnIndex, Attribute::Alignment);
}
static bool isOldLoopArgument(Metadata *MD) {
Index: llvm/lib/Bitcode/Reader/BitcodeReader.cpp
===================================================================
--- llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -5562,8 +5562,8 @@
}
}
- // "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 @@
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102201.344411.patch
Type: text/x-patch
Size: 2197 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210511/b851e622/attachment.bin>
More information about the llvm-commits
mailing list