Home / Function/ removeDeadDoWhileStatements() — react Function Reference

removeDeadDoWhileStatements() — react Function Reference

Architecture documentation for the removeDeadDoWhileStatements() function in HIRBuilder.ts from the react codebase.

Entity Profile

Dependency Diagram

graph TD
  ba25d103_adb3_8e17_0348_cdf4b23496b5["removeDeadDoWhileStatements()"]
  df6865e0_b573_e905_84d6_4eb6b419a888["HIRBuilder.ts"]
  ba25d103_adb3_8e17_0348_cdf4b23496b5 -->|defined in| df6865e0_b573_e905_84d6_4eb6b419a888
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391["build()"]
  5dec5bb8_e0f9_d79d_1c1d_65a05ff57391 -->|calls| ba25d103_adb3_8e17_0348_cdf4b23496b5
  fbdc3953_3621_331c_a5b1_d3199bea5254["constantPropagationImpl()"]
  fbdc3953_3621_331c_a5b1_d3199bea5254 -->|calls| ba25d103_adb3_8e17_0348_cdf4b23496b5
  82b1d221_48c8_7d34_669c_abce4ff71f21["pruneMaybeThrows()"]
  82b1d221_48c8_7d34_669c_abce4ff71f21 -->|calls| ba25d103_adb3_8e17_0348_cdf4b23496b5
  style ba25d103_adb3_8e17_0348_cdf4b23496b5 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts lines 681–705

export function removeDeadDoWhileStatements(func: HIR): void {
  const visited: Set<BlockId> = new Set();
  for (const [_, block] of func.blocks) {
    visited.add(block.id);
  }

  /*
   * If the test condition of a DoWhile is unreachable, the terminal is effectively deadcode and we
   * can just inline the loop body. We replace the terminal with a goto to the loop block and
   * MergeConsecutiveBlocks figures out how to merge as appropriate.
   */
  for (const [_, block] of func.blocks) {
    if (block.terminal.kind === 'do-while') {
      if (!visited.has(block.terminal.test)) {
        block.terminal = {
          kind: 'goto',
          block: block.terminal.loop,
          variant: GotoVariant.Break,
          id: block.terminal.id,
          loc: block.terminal.loc,
        };
      }
    }
  }
}

Subdomains

Frequently Asked Questions

What does removeDeadDoWhileStatements() do?
removeDeadDoWhileStatements() is a function in the react codebase, defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts.
Where is removeDeadDoWhileStatements() defined?
removeDeadDoWhileStatements() is defined in compiler/packages/babel-plugin-react-compiler/src/HIR/HIRBuilder.ts at line 681.
What calls removeDeadDoWhileStatements()?
removeDeadDoWhileStatements() is called by 3 function(s): build, constantPropagationImpl, pruneMaybeThrows.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free