@@ -1200,6 +1200,11 @@ struct AAPointerInfoImpl
1200
1200
A, this , IRPosition::function (Scope), DepClassTy::OPTIONAL,
1201
1201
IsKnownNoRecurse);
1202
1202
1203
+ // TODO: Use reaching kernels from AAKernelInfo (or move it to
1204
+ // AAExecutionDomain) such that we allow scopes other than kernels as long
1205
+ // as the reaching kernels are disjoint.
1206
+ bool InstInKernel = Scope.hasFnAttribute (" kernel" );
1207
+ bool ObjHasKernelLifetime = false ;
1203
1208
const bool UseDominanceReasoning =
1204
1209
FindInterferingWrites && IsKnownNoRecurse;
1205
1210
const DominatorTree *DT =
@@ -1232,6 +1237,7 @@ struct AAPointerInfoImpl
1232
1237
// If the alloca containing function is not recursive the alloca
1233
1238
// must be dead in the callee.
1234
1239
const Function *AIFn = AI->getFunction ();
1240
+ ObjHasKernelLifetime = AIFn->hasFnAttribute (" kernel" );
1235
1241
bool IsKnownNoRecurse;
1236
1242
if (AA::hasAssumedIRAttr<Attribute::NoRecurse>(
1237
1243
A, this , IRPosition::function (*AIFn), DepClassTy::OPTIONAL,
@@ -1241,7 +1247,8 @@ struct AAPointerInfoImpl
1241
1247
} else if (auto *GV = dyn_cast<GlobalValue>(&getAssociatedValue ())) {
1242
1248
// If the global has kernel lifetime we can stop if we reach a kernel
1243
1249
// as it is "dead" in the (unknown) callees.
1244
- if (HasKernelLifetime (GV, *GV->getParent ()))
1250
+ ObjHasKernelLifetime = HasKernelLifetime (GV, *GV->getParent ());
1251
+ if (ObjHasKernelLifetime)
1245
1252
IsLiveInCalleeCB = [](const Function &Fn) {
1246
1253
return !Fn.hasFnAttribute (" kernel" );
1247
1254
};
@@ -1252,6 +1259,15 @@ struct AAPointerInfoImpl
1252
1259
AA::InstExclusionSetTy ExclusionSet;
1253
1260
1254
1261
auto AccessCB = [&](const Access &Acc, bool Exact) {
1262
+ Function *AccScope = Acc.getRemoteInst ()->getFunction ();
1263
+ bool AccInSameScope = AccScope == &Scope;
1264
+
1265
+ // If the object has kernel lifetime we can ignore accesses only reachable
1266
+ // by other kernels. For now we only skip accesses *in* other kernels.
1267
+ if (InstInKernel && ObjHasKernelLifetime && !AccInSameScope &&
1268
+ AccScope->hasFnAttribute (" kernel" ))
1269
+ return true ;
1270
+
1255
1271
if (Exact && Acc.isMustAccess () && Acc.getRemoteInst () != &I) {
1256
1272
if (Acc.isWrite () || (isa<LoadInst>(I) && Acc.isWriteOrAssumption ()))
1257
1273
ExclusionSet.insert (Acc.getRemoteInst ());
@@ -1262,8 +1278,7 @@ struct AAPointerInfoImpl
1262
1278
return true ;
1263
1279
1264
1280
bool Dominates = FindInterferingWrites && DT && Exact &&
1265
- Acc.isMustAccess () &&
1266
- (Acc.getRemoteInst ()->getFunction () == &Scope) &&
1281
+ Acc.isMustAccess () && AccInSameScope &&
1267
1282
DT->dominates (Acc.getRemoteInst (), &I);
1268
1283
if (Dominates)
1269
1284
DominatingWrites.insert (&Acc);
0 commit comments