@@ -1506,23 +1506,45 @@ static bool isUnsupportedAMDGPUAddrspace(Value *Addr) {
1506
1506
return false ;
1507
1507
}
1508
1508
1509
- static bool containsTargetExtType ( const Type *Ty) {
1510
- if (isa <TargetExtType>(Ty))
1511
- return true ;
1509
+ static TargetExtType * getTargetExtType ( Type *Ty) {
1510
+ if (auto *TargetTy = dyn_cast <TargetExtType>(Ty))
1511
+ return TargetTy ;
1512
1512
1513
1513
if (Ty->isVectorTy ())
1514
- return containsTargetExtType (Ty->getScalarType ());
1514
+ return getTargetExtType (Ty->getScalarType ());
1515
1515
1516
1516
if (Ty->isArrayTy ())
1517
- return containsTargetExtType (Ty->getArrayElementType ());
1517
+ return getTargetExtType (Ty->getArrayElementType ());
1518
1518
1519
1519
if (auto *STy = dyn_cast<StructType>(Ty)) {
1520
1520
for (unsigned int i = 0 ; i < STy->getNumElements (); i++)
1521
- if (containsTargetExtType (STy->getElementType (i)))
1522
- return true ;
1523
- return false ;
1521
+ if (auto *TargetTy = getTargetExtType (STy->getElementType (i)))
1522
+ return TargetTy ;
1523
+ return nullptr ;
1524
1524
}
1525
1525
1526
+ return nullptr ;
1527
+ }
1528
+
1529
+ // Skip pointer operand that is sycl joint matrix access since it isn't from
1530
+ // user code, e.g. %call:
1531
+ // clang-format off
1532
+ // %a = alloca %"struct.sycl::_V1::ext::oneapi::experimental::matrix::joint_matrix", align 8
1533
+ // %0 = getelementptr inbounds %"struct.sycl::_V1::ext::oneapi::experimental::matrix::joint_matrix", ptr %a, i64 0, i32 0
1534
+ // %call = call spir_func ptr
1535
+ // @_Z19__spirv_AccessChainIfN4sycl3_V13ext6oneapi12experimental6matrix9precision4tf32ELm8ELm8ELN5__spv9MatrixUseE0ELNS8_5Scope4FlagE3EEPT_PPNS8_28__spirv_CooperativeMatrixKHRIT0_XT4_EXT1_EXT2_EXT3_EEEm(ptr %0, i64 0)
1536
+ // %1 = load float, ptr %call, align 4
1537
+ // store float %1, ptr %call, align 4
1538
+ // clang-format on
1539
+ static bool isJointMatrixAccess (Value *V) {
1540
+ if (auto *CI = dyn_cast<CallInst>(V)) {
1541
+ for (Value *Op : CI->args ()) {
1542
+ if (auto *AI = dyn_cast<AllocaInst>(Op->stripInBoundsOffsets ()))
1543
+ if (auto *TargetTy = getTargetExtType (AI->getAllocatedType ()))
1544
+ return TargetTy->getName ().startswith (" spirv." ) &&
1545
+ TargetTy->getName ().contains (" Matrix" );
1546
+ }
1547
+ }
1526
1548
return false ;
1527
1549
}
1528
1550
@@ -1534,13 +1556,15 @@ static bool isUnsupportedSPIRAccess(Value *Addr, Instruction *Inst) {
1534
1556
1535
1557
// Ignore load/store for target ext type since we can't know exactly what size
1536
1558
// it is.
1537
- if (isa <StoreInst>(Inst) &&
1538
- containsTargetExtType (
1539
- cast<StoreInst>(Inst)-> getValueOperand ()-> getType ()))
1540
- return true ;
1559
+ if (auto *SI = dyn_cast <StoreInst>(Inst))
1560
+ if ( getTargetExtType (SI-> getValueOperand ()-> getType ()) ||
1561
+ isJointMatrixAccess (SI-> getPointerOperand ()))
1562
+ return true ;
1541
1563
1542
- if (isa<LoadInst>(Inst) && containsTargetExtType (Inst->getType ()))
1543
- return true ;
1564
+ if (auto *LI = dyn_cast<LoadInst>(Inst))
1565
+ if (getTargetExtType (Inst->getType ()) ||
1566
+ isJointMatrixAccess (LI->getPointerOperand ()))
1567
+ return true ;
1544
1568
1545
1569
Type *PtrTy = cast<PointerType>(Addr->getType ()->getScalarType ());
1546
1570
switch (PtrTy->getPointerAddressSpace ()) {
@@ -1789,7 +1813,7 @@ bool AddressSanitizer::isInterestingAlloca(const AllocaInst &AI) {
1789
1813
!(SSGI && SSGI->isSafe (AI)) &&
1790
1814
// ignore alloc contains target ext type since we can't know exactly what
1791
1815
// size it is.
1792
- !containsTargetExtType (AI.getAllocatedType ()));
1816
+ !getTargetExtType (AI.getAllocatedType ()));
1793
1817
1794
1818
ProcessedAllocas[&AI] = IsInteresting;
1795
1819
return IsInteresting;
0 commit comments