[PATCH] D156575: [llvm[NFC] Adjust mem fn auto upgrade detection
Nathan Sidwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 2 13:49:00 PDT 2023
urnathan updated this revision to Diff 546592.
urnathan added a comment.
let's try with StringSwitch ... will commit if tests pass
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156575/new/
https://reviews.llvm.org/D156575
Files:
llvm/lib/IR/AutoUpgrade.cpp
Index: llvm/lib/IR/AutoUpgrade.cpp
===================================================================
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -1102,21 +1102,18 @@
// Updating the memory intrinsics (memcpy/memmove/memset) that have an
// alignment parameter to embedding the alignment as an attribute of
// the pointer args.
- if (Name.startswith("memcpy.") && F->arg_size() == 5) {
- rename(F);
- // Get the types of dest, src, and len
- ArrayRef<Type *> ParamTypes = F->getFunctionType()->params().slice(0, 3);
- NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::memcpy,
- ParamTypes);
- return true;
- }
- if (Name.startswith("memmove.") && F->arg_size() == 5) {
- rename(F);
- // Get the types of dest, src, and len
- ArrayRef<Type *> ParamTypes = F->getFunctionType()->params().slice(0, 3);
- NewFn = Intrinsic::getDeclaration(F->getParent(), Intrinsic::memmove,
- ParamTypes);
- return true;
+ if (unsigned ID = StringSwitch<unsigned>(Name)
+ .StartsWith("memcpy.", Intrinsic::memcpy)
+ .StartsWith("memmove.", Intrinsic::memmove)
+ .Default(0)) {
+ if (F->arg_size() == 5) {
+ rename(F);
+ // Get the types of dest, src, and len
+ ArrayRef<Type *> ParamTypes =
+ F->getFunctionType()->params().slice(0, 3);
+ NewFn = Intrinsic::getDeclaration(F->getParent(), ID, ParamTypes);
+ return true;
+ }
}
if (Name.startswith("memset.") && F->arg_size() == 5) {
rename(F);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156575.546592.patch
Type: text/x-patch
Size: 1712 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230802/2e12b821/attachment.bin>
More information about the llvm-commits
mailing list