Skip to content

Commit

Permalink
The compiler produce invalid spirv with enabled PhysicalPointerArgsPass.
Browse files Browse the repository at this point in the history
The tool spirv-val return errors for some spirv binaries.
  • Loading branch information
AlexDemydenko committed Nov 10, 2024
1 parent c24e77d commit 5b25660
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/PhysicalPointerArgsPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,20 @@ PreservedAnalyses clspv::PhysicalPointerArgsPass::run(Module &M,
auto *NewArg = NewFunc->getArg(ArgNum);
if (OriginalArgTy != NewArg->getType()) {
auto *IntAsPtr = Builder.CreateIntToPtr(NewArg, OriginalArgTy);

// Convert a void pointer to a typed if possible
Type *resource_type =
clspv::InferType(F.getArg(ArgNum), M.getContext(), &TypeCache);
if (resource_type && resource_type OriginalArgTy != resource_type) {
// Create the type only once.
auto *arr_type = ArrayType::get(resource_type, 0);
resource_type = StructType::get(arr_type);

Value *zero = Builder.getInt32(0);
IntAsPtr =
Builder.CreateGEP(resource_type, IntAsPtr, {zero, zero, zero});
OriginalArgTy = resource_type;
}
WrappedArgs.push_back(IntAsPtr);

// We can't attach metadata to arguments directly, so add to this
Expand Down

0 comments on commit 5b25660

Please sign in to comment.