@@ -900,9 +900,19 @@ SplitVec(Value *Vec, unsigned NumElts, Instruction *InsertBefore,
900900static void EraseUsers (Instruction *Inst) {
901901 std::forward_list<User *> Users (Inst->user_begin (), Inst->user_end ());
902902 for (auto U : Users) {
903+ IGC_ASSERT_MESSAGE (
904+ !isa<StoreInst>(U) &&
905+ !(isa<CallInst>(U) &&
906+ (GenXIntrinsic::getGenXIntrinsicID (cast<CallInst>(U)) ==
907+ GenXIntrinsic::genx_svm_scatter ||
908+ GenXIntrinsic::getGenXIntrinsicID (cast<CallInst>(U)) ==
909+ GenXIntrinsic::genx_scatter_scaled ||
910+ GenXIntrinsic::getGenXIntrinsicID (cast<CallInst>(U)) ==
911+ GenXIntrinsic::genx_svm_block_st)),
912+ " Should not erase stores" );
903913 Instruction *PotentiallyDeadInst = cast<Instruction>(U);
904914 EraseUsers (PotentiallyDeadInst);
905- IGC_ASSERT_MESSAGE (U->getNumUses () == 0 ,
915+ IGC_ASSERT_MESSAGE (U->use_empty () ,
906916 " Cannot recursively remove users of a replaced alloca" );
907917 PotentiallyDeadInst->eraseFromParent ();
908918 }
@@ -1257,7 +1267,7 @@ bool GenXThreadPrivateMemory::runOnFunction(Function &F) {
12571267 I->eraseFromParent ();
12581268 Changed = true ;
12591269 }
1260- } else if (IntrinsicInst *CI = dyn_cast<IntrinsicInst >(I)) {
1270+ } else if (auto *CI = dyn_cast<CallInst >(I)) {
12611271 unsigned ID = GenXIntrinsic::getAnyIntrinsicID (CI);
12621272 if (ID == GenXIntrinsic::genx_gather_private)
12631273 Changed |= replaceGatherPrivate (CI);
@@ -1267,6 +1277,18 @@ bool GenXThreadPrivateMemory::runOnFunction(Function &F) {
12671277 ID == Intrinsic::lifetime_end) {
12681278 CI->eraseFromParent ();
12691279 Changed = true ;
1280+ } else if (ID == GenXIntrinsic::not_any_intrinsic) {
1281+ bool ArgChanged = false ;
1282+ std::for_each (CI->arg_begin (), CI->arg_end (),
1283+ [this , &CI, &ArgChanged](Value *Op) {
1284+ if (auto *AI = dyn_cast<AllocaInst>(Op)) {
1285+ CI->replaceUsesOfWith (AI, m_allocaToIntrinsic.at (AI));
1286+ ArgChanged = true ;
1287+ }
1288+ });
1289+ IGC_ASSERT_MESSAGE (
1290+ ArgChanged, " Cannot analyze modified alloca passed to other func" );
1291+ Changed = true ;
12701292 }
12711293 } else if (PHINode *Phi = dyn_cast<PHINode>(I)) {
12721294 if (isa<PointerType>(Phi->getType ()))
0 commit comments