| 583 | } |
| 584 | |
| 585 | bool InterfaceVariableScalarReplacement::ReplaceInterfaceVarInEntryPoint( |
| 586 | Instruction* interface_var, Instruction* entry_point, |
| 587 | uint32_t scalar_var_id) { |
| 588 | analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr(); |
| 589 | uint32_t interface_var_id = interface_var->result_id(); |
| 590 | if (interface_vars_removed_from_entry_point_operands_.find( |
| 591 | interface_var_id) != |
| 592 | interface_vars_removed_from_entry_point_operands_.end()) { |
| 593 | entry_point->AddOperand({SPV_OPERAND_TYPE_ID, {scalar_var_id}}); |
| 594 | def_use_mgr->AnalyzeInstUse(entry_point); |
| 595 | return true; |
| 596 | } |
| 597 | |
| 598 | bool success = !entry_point->WhileEachInId( |
| 599 | [&interface_var_id, &scalar_var_id](uint32_t* id) { |
| 600 | if (*id == interface_var_id) { |
| 601 | *id = scalar_var_id; |
| 602 | return false; |
| 603 | } |
| 604 | return true; |
| 605 | }); |
| 606 | if (!success) { |
| 607 | std::string message( |
| 608 | "interface variable is not an operand of the entry point"); |
| 609 | message += "\n " + interface_var->PrettyPrint( |
| 610 | SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); |
| 611 | message += "\n " + entry_point->PrettyPrint( |
| 612 | SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES); |
| 613 | context()->consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, message.c_str()); |
| 614 | return false; |
| 615 | } |
| 616 | |
| 617 | def_use_mgr->AnalyzeInstUse(entry_point); |
| 618 | interface_vars_removed_from_entry_point_operands_.insert(interface_var_id); |
| 619 | return true; |
| 620 | } |
| 621 | |
| 622 | uint32_t InterfaceVariableScalarReplacement::GetPointeeTypeIdOfVar( |
| 623 | Instruction* var) { |
nothing calls this directly
no test coverage detected