@@ -43,9 +43,18 @@ llvm::Type *DirectXTargetCodeGenInfo::getHLSLType(CodeGenModule &CGM,
4343 if (ContainedTy.isNull ())
4444 return nullptr ;
4545
46- // convert element type
4746 llvm::Type *ElemType = CGM.getTypes ().ConvertType (ContainedTy);
4847
48+ // target ext type parameters may not be named struct types
49+ // so we should convert any named struct types to anonymous
50+ // struct types in the parameter list
51+ llvm::Type *ConvertedElemType = ElemType;
52+ if (auto *STy = dyn_cast<llvm::StructType>(ElemType)) {
53+ if (STy->hasName ())
54+ ConvertedElemType =
55+ llvm::StructType::get (Ctx, STy->elements (), /* isPacked=*/ false );
56+ }
57+
4958 llvm::StringRef TypeName =
5059 ResAttrs.RawBuffer ? " dx.RawBuffer" : " dx.TypedBuffer" ;
5160 SmallVector<unsigned , 3 > Ints = {/* IsWriteable*/ ResAttrs.ResourceClass ==
@@ -54,7 +63,7 @@ llvm::Type *DirectXTargetCodeGenInfo::getHLSLType(CodeGenModule &CGM,
5463 if (!ResAttrs.RawBuffer )
5564 Ints.push_back (/* IsSigned*/ ContainedTy->isSignedIntegerType ());
5665
57- return llvm::TargetExtType::get (Ctx, TypeName, {ElemType }, Ints);
66+ return llvm::TargetExtType::get (Ctx, TypeName, {ConvertedElemType }, Ints);
5867 }
5968 case llvm::dxil::ResourceClass::CBuffer:
6069 llvm_unreachable (" dx.CBuffer handles are not implemented yet" );
0 commit comments