aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/TargetInfo.cpp
diff options
context:
space:
mode:
authorMichael Liao <michael.hliao@gmail.com>2020-11-10 09:34:14 -0500
committerMichael Liao <michael.hliao@gmail.com>2020-11-12 21:19:30 -0500
commit8920ef06a138c46b208fb6471d500261c4b9bacc (patch)
tree56a7021f7591c573b4d52837b39768212a71928c /clang/lib/CodeGen/TargetInfo.cpp
parent243511a24e5ac134d88178b036d52f151da260ac (diff)
downloadllvm-8920ef06a138c46b208fb6471d500261c4b9bacc.zip
llvm-8920ef06a138c46b208fb6471d500261c4b9bacc.tar.gz
llvm-8920ef06a138c46b208fb6471d500261c4b9bacc.tar.bz2
[hip] Remove the coercion on aggregate kernel arguments.
- If an aggregate argument is indirectly accessed within kernels, direct passing results in unpromotable `alloca`, which degrade performance significantly. InferAddrSpace pass is enhanced in [D91121](https://reviews.llvm.org/D91121) to take the assumption that generic pointers loaded from the constant memory could be regarded global ones. The need for the coercion on aggregate arguments is mitigated. Differential Revision: https://reviews.llvm.org/D89980
Diffstat (limited to 'clang/lib/CodeGen/TargetInfo.cpp')
-rw-r--r--clang/lib/CodeGen/TargetInfo.cpp28
1 files changed, 1 insertions, 27 deletions
diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp
index 63502cc..1e59203 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -8712,35 +8712,9 @@ private:
bool isHomogeneousAggregateSmallEnough(const Type *Base,
uint64_t Members) const override;
- // Coerce HIP pointer arguments from generic pointers to global ones.
+ // Coerce HIP scalar pointer arguments from generic pointers to global ones.
llvm::Type *coerceKernelArgumentType(llvm::Type *Ty, unsigned FromAS,
unsigned ToAS) const {
- // Structure types.
- if (auto STy = dyn_cast<llvm::StructType>(Ty)) {
- SmallVector<llvm::Type *, 8> EltTys;
- bool Changed = false;
- for (auto T : STy->elements()) {
- auto NT = coerceKernelArgumentType(T, FromAS, ToAS);
- EltTys.push_back(NT);
- Changed |= (NT != T);
- }
- // Skip if there is no change in element types.
- if (!Changed)
- return STy;
- if (STy->hasName())
- return llvm::StructType::create(
- EltTys, (STy->getName() + ".coerce").str(), STy->isPacked());
- return llvm::StructType::get(getVMContext(), EltTys, STy->isPacked());
- }
- // Array types.
- if (auto ATy = dyn_cast<llvm::ArrayType>(Ty)) {
- auto T = ATy->getElementType();
- auto NT = coerceKernelArgumentType(T, FromAS, ToAS);
- // Skip if there is no change in that element type.
- if (NT == T)
- return ATy;
- return llvm::ArrayType::get(NT, ATy->getNumElements());
- }
// Single value types.
if (Ty->isPointerTy() && Ty->getPointerAddressSpace() == FromAS)
return llvm::PointerType::get(