[llvm] [NVPTX] Check Before inserting AddrSpaceCastInst in NVPTXLoweringAlloca (PR #106127)

Justin Fargnoli via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 26 13:37:30 PDT 2024


================
@@ -72,12 +72,22 @@ 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 = dyn_cast_or_null<PointerType>(
----------------
justinfargnoli wrote:

Use `cast` instead of `dyn_cast_or_null`. 

https://github.com/llvm/llvm-project/pull/106127


More information about the llvm-commits mailing list