@@ -900,9 +900,19 @@ SplitVec(Value *Vec, unsigned NumElts, Instruction *InsertBefore,
900
900
static void EraseUsers (Instruction *Inst) {
901
901
std::forward_list<User *> Users (Inst->user_begin (), Inst->user_end ());
902
902
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" );
903
913
Instruction *PotentiallyDeadInst = cast<Instruction>(U);
904
914
EraseUsers (PotentiallyDeadInst);
905
- IGC_ASSERT_MESSAGE (U->getNumUses () == 0 ,
915
+ IGC_ASSERT_MESSAGE (U->use_empty () ,
906
916
" Cannot recursively remove users of a replaced alloca" );
907
917
PotentiallyDeadInst->eraseFromParent ();
908
918
}
@@ -1257,7 +1267,7 @@ bool GenXThreadPrivateMemory::runOnFunction(Function &F) {
1257
1267
I->eraseFromParent ();
1258
1268
Changed = true ;
1259
1269
}
1260
- } else if (IntrinsicInst *CI = dyn_cast<IntrinsicInst >(I)) {
1270
+ } else if (auto *CI = dyn_cast<CallInst >(I)) {
1261
1271
unsigned ID = GenXIntrinsic::getAnyIntrinsicID (CI);
1262
1272
if (ID == GenXIntrinsic::genx_gather_private)
1263
1273
Changed |= replaceGatherPrivate (CI);
@@ -1267,6 +1277,18 @@ bool GenXThreadPrivateMemory::runOnFunction(Function &F) {
1267
1277
ID == Intrinsic::lifetime_end) {
1268
1278
CI->eraseFromParent ();
1269
1279
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 ;
1270
1292
}
1271
1293
} else if (PHINode *Phi = dyn_cast<PHINode>(I)) {
1272
1294
if (isa<PointerType>(Phi->getType ()))
0 commit comments