[llvm] caeb636 - [AutoUpgrade] Remove redundant remangling code (NFCI)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 14 06:14:49 PDT 2023
Author: Nikita Popov
Date: 2023-08-14T15:14:40+02:00
New Revision: caeb636e8bad4a7d7ce624682846dc88fc6d7a08
URL: https://github.com/llvm/llvm-project/commit/caeb636e8bad4a7d7ce624682846dc88fc6d7a08
DIFF: https://github.com/llvm/llvm-project/commit/caeb636e8bad4a7d7ce624682846dc88fc6d7a08.diff
LOG: [AutoUpgrade] Remove redundant remangling code (NFCI)
If the only purpose of the upgrade is a mangling change, this is
handled generically by intrinsic remangling, and does not require
any hand-written code.
Added:
Modified:
llvm/lib/IR/AutoUpgrade.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 94f2ae6089da4b..813fbb77a64b8c 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -1013,32 +1013,6 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
break;
case 'i':
case 'l': {
- bool IsLifetimeStart = Name.startswith("lifetime.start");
- if (IsLifetimeStart || Name.startswith("invariant.start")) {
- Intrinsic::ID ID = IsLifetimeStart ?
- Intrinsic::lifetime_start : Intrinsic::invariant_start;
- auto Args = F->getFunctionType()->params();
- Type* ObjectPtr[1] = {Args[1]};
- if (F->getName() != Intrinsic::getName(ID, ObjectPtr, F->getParent())) {
- rename(F);
- NewFn = Intrinsic::getDeclaration(F->getParent(), ID, ObjectPtr);
- return true;
- }
- }
-
- bool IsLifetimeEnd = Name.startswith("lifetime.end");
- if (IsLifetimeEnd || Name.startswith("invariant.end")) {
- Intrinsic::ID ID = IsLifetimeEnd ?
- Intrinsic::lifetime_end : Intrinsic::invariant_end;
-
- auto Args = F->getFunctionType()->params();
- Type* ObjectPtr[1] = {Args[IsLifetimeEnd ? 1 : 2]};
- if (F->getName() != Intrinsic::getName(ID, ObjectPtr, F->getParent())) {
- rename(F);
- NewFn = Intrinsic::getDeclaration(F->getParent(), ID, ObjectPtr);
- return true;
- }
- }
if (Name.startswith("invariant.group.barrier")) {
// Rename invariant.group.barrier to launder.invariant.group
auto Args = F->getFunctionType()->params();
@@ -1053,35 +1027,6 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
break;
}
case 'm': {
- StringRef MaskPfx = "masked.";
- if (Name.startswith(MaskPfx)) {
- // Renaming masked intrinsics with no address space overloading
- // to the new overload, which includes an address space.
- Intrinsic::ID ID =
- StringSwitch<Intrinsic::ID>(Name.substr(MaskPfx.size()))
- .StartsWith("load.", Intrinsic::masked_load)
- .StartsWith("store.", Intrinsic::masked_store)
- .StartsWith("gather.", Intrinsic::masked_gather)
- .StartsWith("scatter.", Intrinsic::masked_scatter)
- .Default(Intrinsic::not_intrinsic);
- if (ID != Intrinsic::not_intrinsic) {
- const auto *FT = F->getFunctionType();
- SmallVector<Type *, 2> Tys;
- if (ID == Intrinsic::masked_load || ID == Intrinsic::masked_gather)
- // Loading operations overload on the return type.
- Tys.push_back(FT->getReturnType());
- Tys.push_back(FT->getParamType(0));
- if (ID == Intrinsic::masked_store || ID == Intrinsic::masked_scatter)
- // Store operations overload on the stored type.
- Tys.push_back(FT->getParamType(1));
- if (F->getName() != Intrinsic::getName(ID, Tys, F->getParent())) {
- rename(F);
- NewFn = Intrinsic::getDeclaration(F->getParent(), ID, Tys);
- return true;
- }
- }
- break; // No other 'masked.*'
- }
// Updating the memory intrinsics (memcpy/memmove/memset) that have an
// alignment parameter to embedding the alignment as an attribute of
// the pointer args.
@@ -1169,17 +1114,7 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
break;
case 'p':
- if (Name == "prefetch") {
- // Handle address space overloading.
- Type *Tys[] = {F->arg_begin()->getType()};
- if (F->getName() !=
- Intrinsic::getName(Intrinsic::prefetch, Tys, F->getParent())) {
- rename(F);
- NewFn =
- Intrinsic::getDeclaration(F->getParent(), Intrinsic::prefetch, Tys);
- return true;
- }
- } else if (Name.startswith("ptr.annotation.") && F->arg_size() == 4) {
+ if (Name.startswith("ptr.annotation.") && F->arg_size() == 4) {
rename(F);
NewFn = Intrinsic::getDeclaration(
F->getParent(), Intrinsic::ptr_annotation,
@@ -4636,22 +4571,6 @@ void llvm::UpgradeIntrinsicCall(CallBase *CI, Function *NewFn) {
break;
}
- case Intrinsic::invariant_start:
- case Intrinsic::invariant_end: {
- SmallVector<Value *, 4> Args(CI->args());
- NewCall = Builder.CreateCall(NewFn, Args);
- break;
- }
- case Intrinsic::masked_load:
- case Intrinsic::masked_store:
- case Intrinsic::masked_gather:
- case Intrinsic::masked_scatter: {
- SmallVector<Value *, 4> Args(CI->args());
- NewCall = Builder.CreateCall(NewFn, Args);
- NewCall->copyMetadata(*CI);
- break;
- }
-
case Intrinsic::memcpy:
case Intrinsic::memmove:
case Intrinsic::memset: {
More information about the llvm-commits
mailing list