Revert "Account for @pragma("vm:entry-point") creating additional "root" libraries when partitioning the program into loading units."

This reverts commit 9c2a91fb7236214bcec37bba3214921256c5fa6a.

Reason for revert: breaks google3 (b/237016312)

Original change's description:
> Account for @pragma("vm:entry-point") creating additional "root" libraries when partitioning the program into loading units.
>
> If a library contained an entry point but was not reachable from the root library, it was not assigned to any loading unit and caused a null dereference in gen_snapshot. This is not possible with the standalone embedder, but is possible in Flutter because it passes multiple sources to frontend_server.  E.g., `--source dart_plugin_registrant.dart`.
>
> TEST=gallery
> Bug: https://github.com/flutter/gallery/issues/545
> Change-Id: I9c67f0e39f7509094ee873610d80851a702a0cf2
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249640
> Reviewed-by: Alexander Markov <alexmarkov@google.com>
> Commit-Queue: Ryan Macnak <rmacnak@google.com>

TBR=rmacnak@google.com,alexmarkov@google.com

Change-Id: I3e17bf29b8f29e4797abfca35fa82b9ca3b5a160
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: https://github.com/flutter/gallery/issues/545
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/249681
Reviewed-by: Daco Harkes <dacoharkes@google.com>
Commit-Queue: Emmanuel Pellereau <emmanuelp@google.com>
Reviewed-by: Emmanuel Pellereau <emmanuelp@google.com>
diff --git a/pkg/vm/lib/kernel_front_end.dart b/pkg/vm/lib/kernel_front_end.dart
index 3daefd4..03ffe27 100644
--- a/pkg/vm/lib/kernel_front_end.dart
+++ b/pkg/vm/lib/kernel_front_end.dart
@@ -509,7 +509,7 @@
   // it does it will need the obfuscation prohibitions.
   obfuscationProhibitions.transformComponent(component, coreTypes, target);
 
-  deferred_loading.transformComponent(component, coreTypes, target);
+  deferred_loading.transformComponent(component);
 }
 
 /// Runs given [action] with [CompilerContext]. This is needed to
diff --git a/pkg/vm/lib/transformations/deferred_loading.dart b/pkg/vm/lib/transformations/deferred_loading.dart
index 2280c37..e581096 100644
--- a/pkg/vm/lib/transformations/deferred_loading.dart
+++ b/pkg/vm/lib/transformations/deferred_loading.dart
@@ -5,12 +5,8 @@
 library vm.transformations.deferred_loading;
 
 import 'package:kernel/ast.dart';
-import 'package:kernel/core_types.dart' show CoreTypes;
-import 'package:kernel/target/targets.dart' show Target;
-
 import '../dominators.dart';
 import '../metadata/loading_units.dart';
-import 'pragma.dart';
 
 class _LoadingUnitBuilder {
   late int id;
@@ -41,42 +37,7 @@
   String toString() => "_LibraryVertex(${library.importUri})";
 }
 
-class HasEntryPointVisitor extends RecursiveVisitor {
-  final PragmaAnnotationParser parser;
-  bool _hasEntryPoint = false;
-
-  HasEntryPointVisitor(this.parser);
-
-  visitAnnotations(List<Expression> annotations) {
-    for (var ann in annotations) {
-      ParsedPragma? pragma = parser.parsePragma(ann);
-      if (pragma is ParsedEntryPointPragma) {
-        _hasEntryPoint = true;
-        return;
-      }
-    }
-  }
-
-  @override
-  visitClass(Class klass) {
-    visitAnnotations(klass.annotations);
-    klass.visitChildren(this);
-  }
-
-  @override
-  defaultMember(Member node) {
-    visitAnnotations(node.annotations);
-  }
-
-  bool hasEntryPoint(Library lib) {
-    _hasEntryPoint = false;
-    visitLibrary(lib);
-    return _hasEntryPoint;
-  }
-}
-
-List<LoadingUnit> computeLoadingUnits(
-    Component component, HasEntryPointVisitor visitor) {
+List<LoadingUnit> computeLoadingUnits(Component component) {
   // 1. Build the dominator tree for the library import graph.
   final map = <Library, _LibraryVertex>{};
   for (final lib in component.libraries) {
@@ -90,15 +51,10 @@
   }
   final root = map[component.mainMethod!.enclosingLibrary]!;
 
-  // Fake imports from root library to every core library or library containing
-  // an entry point pragma so that they end up in the same loading unit
-  // attributed to the user's root library.
+  // Fake imports from root library to every core library so they end up in
+  // the same loading unit attributed to the user's root library.
   for (final vertex in map.values) {
-    if (vertex == root) {
-      continue;
-    }
-    if (vertex.library.importUri.isScheme("dart") ||
-        visitor.hasEntryPoint(vertex.library)) {
+    if (vertex.library.importUri.isScheme("dart")) {
       root.successors.add(vertex);
       vertex.isLoadingRoot = false;
     }
@@ -171,12 +127,8 @@
   return loadingUnits.map((u) => u.asLoadingUnit()).toList();
 }
 
-Component transformComponent(
-    Component component, CoreTypes coreTypes, Target target) {
-  final parser = ConstantPragmaAnnotationParser(coreTypes, target);
-  final visitor = HasEntryPointVisitor(parser);
-  final metadata =
-      new LoadingUnitsMetadata(computeLoadingUnits(component, visitor));
+Component transformComponent(Component component) {
+  final metadata = new LoadingUnitsMetadata(computeLoadingUnits(component));
   final repo = new LoadingUnitsMetadataRepository();
   component.addMetadataRepository(repo);
   repo.mapping[component] = metadata;
diff --git a/pkg/vm/test/transformations/deferred_loading_test.dart b/pkg/vm/test/transformations/deferred_loading_test.dart
index 61a2534..5b7cce8 100644
--- a/pkg/vm/test/transformations/deferred_loading_test.dart
+++ b/pkg/vm/test/transformations/deferred_loading_test.dart
@@ -6,7 +6,6 @@
 
 import 'package:kernel/target/targets.dart';
 import 'package:kernel/ast.dart';
-import 'package:kernel/core_types.dart';
 import 'package:kernel/kernel.dart';
 import 'package:test/test.dart';
 import 'package:vm/transformations/deferred_loading.dart'
@@ -25,9 +24,7 @@
   final reversed = component.libraries.reversed.toList();
   component.libraries.setAll(0, reversed);
 
-  final coreTypes = CoreTypes(component);
-
-  component = transformComponent(component, coreTypes, target);
+  component = transformComponent(component);
 
   // Remove core libraries so the expected output isn't enormous and broken by
   // core libraries changes.
diff --git a/runtime/vm/compiler/frontend/kernel_translation_helper.cc b/runtime/vm/compiler/frontend/kernel_translation_helper.cc
index 5758e51..b84479f 100644
--- a/runtime/vm/compiler/frontend/kernel_translation_helper.cc
+++ b/runtime/vm/compiler/frontend/kernel_translation_helper.cc
@@ -1930,16 +1930,6 @@
   object_store->set_loading_units(loading_units);
   ASSERT(object_store->loading_unit_uris() == Array::null());
   object_store->set_loading_unit_uris(loading_unit_uris);
-
-  const GrowableObjectArray& libraries =
-      GrowableObjectArray::Handle(zone, object_store->libraries());
-  for (intptr_t i = 0; i < libraries.Length(); i++) {
-    lib ^= libraries.At(i);
-    unit = lib.loading_unit();
-    if (unit.IsNull()) {
-      FATAL("%s is not attributed to any loading unit", lib.ToCString());
-    }
-  }
 }
 
 CallSiteAttributesMetadataHelper::CallSiteAttributesMetadataHelper(