@@ -369,27 +369,17 @@ void copyModuleContents(Module& input, Name inputName) {
369369 // No previous start; just refer to the new one.
370370 merged.start = input.start ;
371371 } else {
372- // Merge them, keeping the order. We copy both functions to avoid issues
373- // with other references to them, and then add a new function that calls
374- // the two (we leave proper inlining, including handling of control flow
375- // etc., to the optimizer).
376- auto copiedOldName =
377- Names::getValidFunctionName (merged, " merged.start.old" );
378- auto copiedNewName =
379- Names::getValidFunctionName (merged, " merged.start.new" );
380- auto * copiedOld = ModuleUtils::copyFunction (
381- merged.getFunction (merged.start ), merged, copiedOldName);
382- ModuleUtils::copyFunction (
383- merged.getFunction (input.start ), merged, copiedNewName);
384-
372+ // Merge them, keeping the order. We add a new function that calls the two
373+ // (leaving proper inlining, including handling of control flow etc., to
374+ // the optimizer).
385375 auto combinedName =
386376 Names::getValidFunctionName (merged, " merged.start.combined" );
387377 Builder builder (merged);
388- auto * callOld = builder.makeCall (copiedOldName , {}, Type::none);
389- auto * callNew = builder.makeCall (copiedNewName , {}, Type::none);
378+ auto * callOld = builder.makeCall (merged. start , {}, Type::none);
379+ auto * callNew = builder.makeCall (input. start , {}, Type::none);
390380 auto * body = builder.makeSequence (callOld, callNew);
391381 auto combinedStart = builder.makeFunction (
392- combinedName, Signature (Type::none, Type::none), {}, calls );
382+ combinedName, Signature (Type::none, Type::none), {}, body );
393383 merged.start = combinedName;
394384 }
395385 }
0 commit comments