================
@@ -3306,11 +3306,31 @@ bool SemaHLSL::CheckBuiltinFunctionCall(unsigned
BuiltinID, CallExpr *TheCall) {
SemaRef.getASTContext().UnsignedIntTy))
return true;
+ // Figure out the return type of the intrinsic. For most resources it is
the
+ // contained type. For ByteAddressBuffer it is determined by the type used
+ // on the FunctionDecl.
auto *ResourceTy =
TheCall->getArg(0)->getType()->castAs<HLSLAttributedResourceType>();
- QualType ContainedTy = ResourceTy->getContainedType();
+ QualType ElementTy = ResourceTy->getContainedType();
+ if (ResourceTy->getAttrs().RawBuffer && ElementTy->isChar8Type()) {
+ // Load method uses return type
+ FunctionDecl *FD = dyn_cast<FunctionDecl>(SemaRef.CurContext);
+ ElementTy = FD->getReturnType();
+ // Store method uses 2nd parameter type
+ if (ElementTy->isVoidType()) {
+ assert(FD->getNumParams() == 2 &&
+ "expected 2 parameters for Store method");
+ ElementTy = FD->getParamDecl(1)->getType();
+ }
----------------
bogner wrote:
> We could have a separate `resource_getpointer`-like builtin function with an
> extra argument of the dependent type, and the return type for the intrinsic
> could be inferred from that.
This is a little ugly, but it should be better behaved and safer than the
current approach. @kmpeng can you try this?
https://github.com/llvm/llvm-project/pull/176058
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits