@@ -1242,22 +1242,19 @@ void LowerGPCallArg::FixAddressSpaceInAllUses(Value* ptr, uint newAS, uint oldAS
1242
1242
// Loops over the argument list transferring uses from old function to new one.
1243
1243
void LowerGPCallArg::updateFunctionArgs (Function* oldFunc, Function* newFunc, GenericPointerArgs& newArgs)
1244
1244
{
1245
-
1246
1245
Function::arg_iterator currArg = newFunc->arg_begin ();
1247
1246
unsigned currentArgIdx = 0 , newArgIdx = 0 ;
1248
1247
1249
-
1250
-
1251
1248
for (Function::arg_iterator I = oldFunc->arg_begin (), E = oldFunc->arg_end ();
1252
1249
I != E; ++I, ++currArg, ++currentArgIdx)
1253
1250
{
1254
1251
Value* newArg = &(*currArg);
1255
- if ((*I).getType () != currArg->getType ())
1252
+ // Check if the next entry in newArgs is for currentArgIdx arg
1253
+ if (newArgIdx < newArgs.size () && currentArgIdx == newArgs[newArgIdx].first )
1256
1254
{
1257
- if (currentArgIdx == newArgs[newArgIdx]. first )
1255
+ if ((*I). getType () != currArg-> getType () )
1258
1256
{
1259
1257
PointerType* originalPointerTy = dyn_cast<PointerType>(I->getType ());
1260
-
1261
1258
PointerType* newPointerTy = PointerType::get (I->getType ()->getPointerElementType (),
1262
1259
newArgs[newArgIdx].second );
1263
1260
I->mutateType (newPointerTy);
@@ -1273,16 +1270,14 @@ void LowerGPCallArg::updateFunctionArgs(Function* oldFunc, Function* newFunc, Ge
1273
1270
{
1274
1271
recoverASC->eraseFromParent ();
1275
1272
}
1276
- newArgIdx++;
1277
1273
}
1274
+ newArgIdx++;
1278
1275
}
1279
1276
I->replaceAllUsesWith (newArg);
1280
1277
currArg->takeName (&(*I));
1281
1278
}
1282
1279
}
1283
1280
1284
-
1285
-
1286
1281
void LowerGPCallArg::updateAllUsesWithNewFunction (FuncToUpdate& f)
1287
1282
{
1288
1283
IGC_ASSERT (!f.oldFunc ->use_empty ());
0 commit comments