[PATCH] D156575: [llvm[NFC] Adjust mem fn auto upgrade detection
Nathan Sidwell via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 28 15:06:10 PDT 2023
urnathan created this revision.
urnathan added reviewers: jroelofs, echristo.
Herald added a subscriber: hiraditya.
Herald added a project: All.
urnathan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
In working on how to augment llvm.memcpy and friends to distingish src from dst volatility I noticed the auto upgrade processing was somewhat duplicative. This commonizes the memcpy and memmove detection. In addition to being general goodness, this will make it easier to do the change I want to make.
This change itself is NFC
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,17 @@
// 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 = (Name.startswith("memcpy.") ? Intrinsic::memcpy
+ : Name.startswith("memmove.") ? Intrinsic::memmove
+ : 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.545285.patch
Type: text/x-patch
Size: 1689 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230728/750c503e/attachment.bin>
More information about the llvm-commits
mailing list