| 30 | } // namespace |
| 31 | |
| 32 | Pass::Status DescriptorScalarReplacement::Process() { |
| 33 | bool modified = false; |
| 34 | std::vector<Instruction*> vars_to_kill; |
| 35 | |
| 36 | for (Instruction& var : context()->types_values()) { |
| 37 | bool is_candidate = |
| 38 | flatten_arrays_ && descsroautil::IsDescriptorArray(context(), &var); |
| 39 | is_candidate |= flatten_composites_ && |
| 40 | descsroautil::IsDescriptorStruct(context(), &var); |
| 41 | if (is_candidate) { |
| 42 | modified = true; |
| 43 | if (!ReplaceCandidate(&var)) { |
| 44 | return Status::Failure; |
| 45 | } |
| 46 | vars_to_kill.push_back(&var); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | for (Instruction* var : vars_to_kill) { |
| 51 | context()->KillInst(var); |
| 52 | } |
| 53 | |
| 54 | return (modified ? Status::SuccessWithChange : Status::SuccessWithoutChange); |
| 55 | } |
| 56 | |
| 57 | bool DescriptorScalarReplacement::ReplaceCandidate(Instruction* var) { |
| 58 | std::vector<Instruction*> access_chain_work_list; |
nothing calls this directly
no test coverage detected