@@ -87,7 +87,7 @@ namespace {
87
87
Instruction* CreateSubGroup2DBlockOperation (llvm::CallInst& CI, llvm::StringRef funcName, bool isRead);
88
88
89
89
// / LSC Fence intrinsics call method
90
- Instruction* CreateLSCFenceIntrinsicCallInst ();
90
+ Instruction* CreateLSCFenceIntrinsicCallInst (CallInst& CI );
91
91
92
92
Instruction* CreateLSCFenceEvictToMemory ();
93
93
@@ -176,6 +176,7 @@ namespace {
176
176
CodeGenContext* m_pCtx = nullptr ;
177
177
CallInst* m_pCurrInst = nullptr ;
178
178
Function* m_pCurrInstFunc = nullptr ;
179
+ std::set<Instruction*> m_instsToErase{};
179
180
180
181
// For verifying address payload for block 2d read/write.
181
182
llvm::SmallVector<Instruction *, 32 > m_lsc2dblock_readwrite;
@@ -278,6 +279,11 @@ bool LSCFuncsResolution::runOnFunction(Function &F)
278
279
279
280
visit (F);
280
281
282
+ for (auto * inst : m_instsToErase) {
283
+ inst->eraseFromParent ();
284
+ }
285
+ m_instsToErase.clear ();
286
+
281
287
verifyBlock2DAddressPayload ();
282
288
283
289
if (hasError ()) {
@@ -388,7 +394,7 @@ void LSCFuncsResolution::visitCallInst(CallInst &CI)
388
394
}
389
395
else if (FN.startswith (LSCFuncsResolution::PREFIX_LSC_FENCE)) {
390
396
// LSC fence
391
- lscCall = CreateLSCFenceIntrinsicCallInst ();
397
+ lscCall = CreateLSCFenceIntrinsicCallInst (CI );
392
398
} else {
393
399
// not an LSC message, bail silently
394
400
return ;
@@ -404,7 +410,7 @@ void LSCFuncsResolution::visitCallInst(CallInst &CI)
404
410
if (lscCall != nullptr ) {
405
411
lscCall->setDebugLoc (CI.getDebugLoc ());
406
412
CI.replaceAllUsesWith (lscCall);
407
- CI. eraseFromParent ( );
413
+ m_instsToErase. insert (&CI );
408
414
409
415
m_changed = true ;
410
416
}
@@ -1454,7 +1460,7 @@ Instruction* LSCFuncsResolution::CreateLSCStoreCmaskIntrinsicCallInst(
1454
1460
return lscCall;
1455
1461
}
1456
1462
1457
- Instruction* LSCFuncsResolution::CreateLSCFenceIntrinsicCallInst () {
1463
+ Instruction* LSCFuncsResolution::CreateLSCFenceIntrinsicCallInst (CallInst& CI ) {
1458
1464
LSC_SFID memPort = decodeSfidFromName ();
1459
1465
1460
1466
auto context = getAnalysis<CodeGenContextWrapper>().getCodeGenContext ();
@@ -1479,6 +1485,12 @@ Instruction* LSCFuncsResolution::CreateLSCFenceIntrinsicCallInst() {
1479
1485
1480
1486
if (scope && (scope->getZExtValue () == LSC_SCOPE_SYSACQ || scope->getZExtValue () == LSC_SCOPE_SYSREL))
1481
1487
{
1488
+ if (context->platform .isIntegratedGraphics () || context->platform .isCoreXE2 ())
1489
+ {
1490
+ // Global memory fences are not needed on integrated devices or on Xe2 platforms.
1491
+ m_instsToErase.insert (&CI);
1492
+ return nullptr ;
1493
+ }
1482
1494
if (!context->platform .supportSystemFence ())
1483
1495
{
1484
1496
reportError (" platform does not support system fence" );
0 commit comments