MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / ValidateLifetime

Function ValidateLifetime

source/val/validate_cfg.cpp:355–381  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353}
354
355spv_result_t ValidateLifetime(ValidationState_t& _, const Instruction* inst) {
356 const uint32_t pointer_id = _.GetOperandTypeId(inst, 0);
357 const Instruction* pointer_inst = _.FindDef(pointer_id);
358 if (pointer_inst->opcode() != spv::Op::OpTypePointer) {
359 return _.diag(SPV_ERROR_INVALID_DATA, inst)
360 << "Op" << spvOpcodeString(inst->opcode())
361 << " pointer operand type must be a OpTypePointer.";
362 } else if (pointer_inst->GetOperandAs<spv::StorageClass>(1) !=
363 spv::StorageClass::Function) {
364 return _.diag(SPV_ERROR_INVALID_DATA, inst)
365 << "Op" << spvOpcodeString(inst->opcode())
366 << " pointer operand must be in the Function storage class.";
367 }
368
369 const uint32_t size = inst->GetOperandAs<uint32_t>(1);
370 if (size != 0) {
371 if (!_.HasCapability(spv::Capability::Addresses)) {
372 return _.diag(SPV_ERROR_INVALID_DATA, inst)
373 << "Op" << spvOpcodeString(inst->opcode())
374 << " size is non-zero, but the Addresses Capability is not "
375 "declared.";
376 }
377 // TODO - "Size must be 0 if Pointer is a pointer to a non-void type"
378 }
379
380 return SPV_SUCCESS;
381}
382
383} // namespace
384

Callers 1

ControlFlowPassFunction · 0.85

Calls 6

spvOpcodeStringFunction · 0.85
GetOperandTypeIdMethod · 0.80
FindDefMethod · 0.80
diagMethod · 0.80
opcodeMethod · 0.45
HasCapabilityMethod · 0.45

Tested by

no test coverage detected