instrument: Ensure linking works even of nothing is changed (#5419)

spirv-link requires that memory models match between its input files.
Ensure this is the case by always returning SuccessWithChange and
always changing the memory model to match the instrumentation
code in Vulkan-ValidationLayers.

Also, disable the DCE pass in the --inst-* command line options, since
it will only work after linking.
This commit is contained in:
Jeremy Gebben 2023-10-02 09:15:39 -06:00 committed by GitHub
parent dc9900967d
commit 847715d6c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 10 deletions

View File

@ -724,7 +724,6 @@ void InstBindlessCheckPass::InitializeInstBindlessCheck() {
}
Pass::Status InstBindlessCheckPass::ProcessImpl() {
bool modified = false;
// The memory model and linkage must always be updated for spirv-link to work
// correctly.
AddStorageBufferExt();
@ -747,8 +746,10 @@ Pass::Status InstBindlessCheckPass::ProcessImpl() {
new_blocks);
};
modified = InstProcessEntryPointCallTree(pfn);
return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange;
InstProcessEntryPointCallTree(pfn);
// This pass always changes the memory model, so that linking will work
// properly.
return Status::SuccessWithChange;
}
Pass::Status InstBindlessCheckPass::Process() {

View File

@ -301,6 +301,11 @@ Pass::Status InstBuffAddrCheckPass::ProcessImpl() {
context()->AddExtension("SPV_KHR_physical_storage_buffer");
}
context()->AddCapability(spv::Capability::PhysicalStorageBufferAddresses);
Instruction* memory_model = get_module()->GetMemoryModel();
memory_model->SetInOperand(
0u, {uint32_t(spv::AddressingModel::PhysicalStorageBuffer64)});
context()->AddCapability(spv::Capability::Int64);
context()->AddCapability(spv::Capability::Linkage);
// Perform bindless bounds check on each entry point function in module
@ -311,14 +316,13 @@ Pass::Status InstBuffAddrCheckPass::ProcessImpl() {
return GenBuffAddrCheckCode(ref_inst_itr, ref_block_itr, stage_idx,
new_blocks);
};
bool modified = InstProcessEntryPointCallTree(pfn);
return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange;
InstProcessEntryPointCallTree(pfn);
// This pass always changes the memory model, so that linking will work
// properly.
return Status::SuccessWithChange;
}
Pass::Status InstBuffAddrCheckPass::Process() {
if (!get_feature_mgr()->HasCapability(
spv::Capability::PhysicalStorageBufferAddressesEXT))
return Status::SuccessWithoutChange;
InitInstBuffAddrCheck();
return ProcessImpl();
}

View File

@ -439,10 +439,8 @@ bool Optimizer::RegisterPassFromFlag(const std::string& flag) {
RegisterPass(CreateSimplificationPass());
RegisterPass(CreateDeadBranchElimPass());
RegisterPass(CreateBlockMergePass());
RegisterPass(CreateAggressiveDCEPass(true));
} else if (pass_name == "inst-buff-addr-check") {
RegisterPass(CreateInstBuffAddrCheckPass(23));
RegisterPass(CreateAggressiveDCEPass(true));
} else if (pass_name == "convert-relaxed-to-half") {
RegisterPass(CreateConvertRelaxedToHalfPass());
} else if (pass_name == "relax-float-ops") {