[be] Remove dead code in ConstantPropagation
Joe Savona committed
Oct 10, 2023 at 13:15 UTC
ba23b990acf5d16cd8c96975e38298bbfb6de344
1 file changed
-20
compiler/packages/babel-plugin-react-forget/src/Optimization/ConstantPropagation.ts
-20
@@ -97,26 +97,6 @@ function applyConstantPropagation(
97
fn: HIRFunction,
98
constants: Constants
99
): boolean {
100
- // Track the set of identifiers which are used as dependencies for function expressions
101
- // in order to avoid propagating these constants. This is necessary because the function
102
- // itself will still reference the original value. If the dependency is propagated but the
103
- // function still refers to the original value, this can create a situation where DCE
104
- // will think the original expression is unused. Until we are able to propagate constants
105
- // into function expression bodies, we disable propagation of function deps.
106
- const functionDependencies = new Set<IdentifierId>();
107
- for (const [, block] of fn.body.blocks) {
108
- for (const instr of block.instructions) {
109
- if (
110
- instr.value.kind === "FunctionExpression" ||
111
- instr.value.kind === "ObjectMethod"
112
- ) {
113
- for (const operand of instr.value.loweredFunc.dependencies) {
114
- functionDependencies.add(operand.identifier.id);
115
- }
116
- }
117
- }
118
- }
119
-
100
let hasChanges = false;
101
for (const [, block] of fn.body.blocks) {
102
// Initialize phi values if all operands have the same known constant value.