Skip to content

Commit e2bb479

Browse files
Drop the JointMatrixINTEL struct-renaming pass when opaque pointers are enabled. (#1570)
The frontend is being changed to lower the struct name to the correct LLVM name directly, obviating the need for this check. See intel/llvm#6535 for this change. This marks the removal of the final call to the deprecated method Type::getPointerElementType, although there remains some code that is not fully working with opaque pointers enabled.
1 parent 4dd494e commit e2bb479

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/SPIRV/SPIRVRegularizeLLVM.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,10 @@ void SPIRVRegularizeLLVMBase::adaptStructTypes(StructType *ST) {
355355
STName.consume_front("__spv::");
356356
StringRef MangledName = STName.substr(0, STName.find('.'));
357357

358+
// Older versions of clang will generate JointMatrixINTEL types using this
359+
// representation. Newer versions will generate the correct struct name
360+
// "%spirv.JointMatrixINTEL._{parameters}" directly, obviating the need for
361+
// this check.
358362
// Representation in LLVM IR before the translator is a pointer array wrapped
359363
// in a structure:
360364
// %struct.__spirv_JointMatrixINTEL = type { [R x [C x [L x [S x type]]]]* }
@@ -371,12 +375,13 @@ void SPIRVRegularizeLLVMBase::adaptStructTypes(StructType *ST) {
371375
// register by OpCompositeConstruct. And we can't claim, that the Result type
372376
// of OpCompositeConstruct instruction is always the joint matrix type, it's
373377
// simply not true.
374-
if (MangledName == "__spirv_JointMatrixINTEL") {
378+
if (MangledName == "__spirv_JointMatrixINTEL" && !ST->isOpaquePointerTy()) {
375379
auto *PtrTy = dyn_cast<PointerType>(ST->getElementType(0));
376380
assert(PtrTy &&
377381
"Expected a pointer to an array to represent joint matrix type");
378382
std::vector<size_t> TypeLayout;
379-
ArrayType *ArrayTy = dyn_cast<ArrayType>(PtrTy->getPointerElementType());
383+
ArrayType *ArrayTy =
384+
dyn_cast<ArrayType>(PtrTy->getNonOpaquePointerElementType());
380385
assert(ArrayTy && "Expected a pointer element type of an array type to "
381386
"represent joint matrix type");
382387
TypeLayout.push_back(ArrayTy->getNumElements());

0 commit comments

Comments
 (0)