Finds entry point corresponding to a function Returns null if not found, otherwise returns pointer to the EP Instruction.
| 115 | // |
| 116 | // Returns null if not found, otherwise returns pointer to the EP Instruction. |
| 117 | Instruction* FindEntryPoint(const Instruction& fn_inst) { |
| 118 | auto* mod = fn_inst.context()->module(); |
| 119 | for (auto& entry_point : mod->entry_points()) { |
| 120 | const int ep_i = |
| 121 | entry_point.opcode() == spv::Op::OpConditionalEntryPointINTEL ? 2 : 1; |
| 122 | if (entry_point.GetOperand(ep_i).AsId() == fn_inst.result_id()) { |
| 123 | return &entry_point; |
| 124 | } |
| 125 | } |
| 126 | return nullptr; |
| 127 | } |
| 128 | |
| 129 | // If the function has an entry point, converts it to a conditional one |
| 130 | void ConvertEPToConditional(Module* module, const Function& fn, |