[polly] [polly] Avoid llvm::Type::getPointerTo() (NFC) (PR #112368)

Youngsuk Kim via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 15 07:37:48 PDT 2024


https://github.com/JOE1994 created https://github.com/llvm/llvm-project/pull/112368

`llvm::Type::getPointerTo()` is to be deprecated & removed soon.

Also, avoid pointercasts that are essentially no-ops.

>From 2c4a9068388cda25a60843375d11504374fe2836 Mon Sep 17 00:00:00 2001
From: Youngsuk Kim <youngsuk.kim at hpe.com>
Date: Tue, 15 Oct 2024 09:29:37 -0500
Subject: [PATCH] [polly] Avoid llvm::Type::getPointerTo() (NFC)

`llvm::Type::getPointerTo()` is to be deprecated & removed soon.

Also, avoid pointercasts that are essentially no-ops.
---
 polly/lib/CodeGen/BlockGenerators.cpp    | 6 ------
 polly/lib/CodeGen/IslNodeBuilder.cpp     | 2 --
 polly/lib/CodeGen/LoopGeneratorsGOMP.cpp | 2 +-
 3 files changed, 1 insertion(+), 9 deletions(-)

diff --git a/polly/lib/CodeGen/BlockGenerators.cpp b/polly/lib/CodeGen/BlockGenerators.cpp
index c58763603cfa22..b76d8f4c18a551 100644
--- a/polly/lib/CodeGen/BlockGenerators.cpp
+++ b/polly/lib/CodeGen/BlockGenerators.cpp
@@ -786,12 +786,6 @@ void BlockGenerator::generateScalarStores(
                                Builder.GetInsertBlock())) &&
                  "Domination violation");
 
-          // The new Val might have a different type than the old Val due to
-          // ScalarEvolution looking through bitcasts.
-          Address = Builder.CreateBitOrPointerCast(
-              Address, Val->getType()->getPointerTo(
-                           Address->getType()->getPointerAddressSpace()));
-
           Builder.CreateStore(Val, Address);
         });
   }
diff --git a/polly/lib/CodeGen/IslNodeBuilder.cpp b/polly/lib/CodeGen/IslNodeBuilder.cpp
index 3f07f02038a1ec..d76f6251ea4ced 100644
--- a/polly/lib/CodeGen/IslNodeBuilder.cpp
+++ b/polly/lib/CodeGen/IslNodeBuilder.cpp
@@ -1050,8 +1050,6 @@ Value *IslNodeBuilder::preloadUnconditionally(__isl_take isl_set *AccessRange,
 
   auto *Ptr = AddressValue;
   auto Name = Ptr->getName();
-  auto AS = Ptr->getType()->getPointerAddressSpace();
-  Ptr = Builder.CreatePointerCast(Ptr, Ty->getPointerTo(AS), Name + ".cast");
   PreloadVal = Builder.CreateLoad(Ty, Ptr, Name + ".load");
   if (LoadInst *PreloadInst = dyn_cast<LoadInst>(PreloadVal))
     PreloadInst->setAlignment(cast<LoadInst>(AccInst)->getAlign());
diff --git a/polly/lib/CodeGen/LoopGeneratorsGOMP.cpp b/polly/lib/CodeGen/LoopGeneratorsGOMP.cpp
index cd440b28202e6d..b98416a92097f2 100644
--- a/polly/lib/CodeGen/LoopGeneratorsGOMP.cpp
+++ b/polly/lib/CodeGen/LoopGeneratorsGOMP.cpp
@@ -183,7 +183,7 @@ Value *ParallelLoopGeneratorGOMP::createCallGetWorkItem(Value *LBPtr,
   // If F is not available, declare it.
   if (!F) {
     GlobalValue::LinkageTypes Linkage = Function::ExternalLinkage;
-    Type *Params[] = {LongType->getPointerTo(), LongType->getPointerTo()};
+    Type *Params[] = {Builder.getPtrTy(0), Builder.getPtrTy(0)};
     FunctionType *Ty = FunctionType::get(Builder.getInt8Ty(), Params, false);
     F = Function::Create(Ty, Linkage, Name, M);
   }



More information about the llvm-commits mailing list