| 36 | } |
| 37 | |
| 38 | Pass::Status CombineAccessChains::ProcessFunction(Function& function) { |
| 39 | if (function.IsDeclaration()) { |
| 40 | return Status::SuccessWithoutChange; |
| 41 | } |
| 42 | |
| 43 | bool modified = false; |
| 44 | bool failure = false; |
| 45 | |
| 46 | cfg()->ForEachBlockInReversePostOrder( |
| 47 | function.entry().get(), [&modified, &failure, this](BasicBlock* block) { |
| 48 | if (failure) return; |
| 49 | block->ForEachInst([&modified, &failure, this](Instruction* inst) { |
| 50 | if (failure) return; |
| 51 | switch (inst->opcode()) { |
| 52 | case spv::Op::OpAccessChain: |
| 53 | case spv::Op::OpInBoundsAccessChain: |
| 54 | case spv::Op::OpPtrAccessChain: |
| 55 | case spv::Op::OpInBoundsPtrAccessChain: { |
| 56 | auto status = CombineAccessChain(inst); |
| 57 | if (status == Status::Failure) { |
| 58 | failure = true; |
| 59 | } else if (status == Status::SuccessWithChange) { |
| 60 | modified = true; |
| 61 | } |
| 62 | break; |
| 63 | } |
| 64 | default: |
| 65 | break; |
| 66 | } |
| 67 | }); |
| 68 | }); |
| 69 | |
| 70 | if (failure) return Status::Failure; |
| 71 | return modified ? Status::SuccessWithChange : Status::SuccessWithoutChange; |
| 72 | } |
| 73 | |
| 74 | uint32_t CombineAccessChains::GetConstantValue( |
| 75 | const analysis::Constant* constant_inst) { |
nothing calls this directly
no test coverage detected