[llvm] [NVPTX] Check Before inserting AddrSpaceCastInst in NVPTXLoweringAlloca (PR #106127)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 3 10:57:12 PDT 2024
================
@@ -72,12 +72,26 @@ bool NVPTXLowerAlloca::runOnFunction(Function &F) {
Changed = true;
auto ETy = allocaInst->getAllocatedType();
auto LocalAddrTy = PointerType::get(ETy, ADDRESS_SPACE_LOCAL);
- auto NewASCToLocal = new AddrSpaceCastInst(allocaInst, LocalAddrTy, "");
- auto GenericAddrTy = PointerType::get(ETy, ADDRESS_SPACE_GENERIC);
- auto NewASCToGeneric =
- new AddrSpaceCastInst(NewASCToLocal, GenericAddrTy, "");
- NewASCToLocal->insertAfter(allocaInst);
- NewASCToGeneric->insertAfter(NewASCToLocal);
+ PointerType *AllocInstPtrTy =
+ cast<PointerType>(allocaInst->getType()->getScalarType());
+ Instruction *NewASCToGeneric = allocaInst;
----------------
Artem-B wrote:
This could use a better name, given that ASC may or may not be there now. `AllocaInGenericAS` ?
I'd also push the variables down, into the `if` body -- some of them seem to be needed by the now-conditional code only.
https://github.com/llvm/llvm-project/pull/106127
More information about the llvm-commits
mailing list