| 227 | } |
| 228 | |
| 229 | std::unique_ptr<CFG> ControlFlowGraphBuilder::build( |
| 230 | AsmAnalysisInfo const& _analysisInfo, |
| 231 | Dialect const& _dialect, |
| 232 | Block const& _block |
| 233 | ) |
| 234 | { |
| 235 | std::optional<uint8_t> eofVersion; |
| 236 | if (EVMDialect const* evmDialect = dynamic_cast<EVMDialect const*>(&_dialect)) |
| 237 | eofVersion = evmDialect->eofVersion(); |
| 238 | |
| 239 | auto result = std::make_unique<CFG>(); |
| 240 | result->entry = &result->makeBlock(debugDataOf(_block)); |
| 241 | |
| 242 | ControlFlowSideEffectsCollector sideEffects(_dialect, _block); |
| 243 | ControlFlowGraphBuilder builder(*result, _analysisInfo, sideEffects.functionSideEffects(), _dialect); |
| 244 | builder.m_currentBlock = result->entry; |
| 245 | builder(_block); |
| 246 | |
| 247 | cleanUnreachable(*result); |
| 248 | markRecursiveCalls(*result); |
| 249 | markStartsOfSubGraphs(*result); |
| 250 | markNeedsCleanStack(*result); |
| 251 | |
| 252 | // TODO: It might be worthwhile to run some further simplifications on the graph itself here. |
| 253 | // E.g. if there is a jump to a node that has the jumping node as its only entry, the nodes can be fused, etc. |
| 254 | |
| 255 | return result; |
| 256 | } |
| 257 | |
| 258 | ControlFlowGraphBuilder::ControlFlowGraphBuilder( |
| 259 | CFG& _graph, |
nothing calls this directly
no test coverage detected