mirror of
https://github.com/KhronosGroup/SPIRV-Tools
synced 2025-01-11 17:10:06 +00:00
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:
parent
dc9900967d
commit
847715d6c6
@ -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() {
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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") {
|
||||
|
Loading…
Reference in New Issue
Block a user