Adapt Tarjan generic cycle detector for use in Crossgen2 (#71426)
authorTomáš Rylek <trylek@microsoft.com>
Tue, 13 Jun 2023 00:49:39 +0000 (02:49 +0200)
committerGitHub <noreply@github.com>
Tue, 13 Jun 2023 00:49:39 +0000 (02:49 +0200)
commitbc4cbb604279901ce49b80fa79a43e1a948dbd4e
tree6192832f8a5c2bb5fc54a54e18f6b900c3dfb3f1
parentc32bee11a457151e5c400107ababed54dcd70438
Adapt Tarjan generic cycle detector for use in Crossgen2 (#71426)

This change modifies Crossgen2 to use the generic cycle detector
originally implemented for NativeAOT to trim infinite generic
expansion as observed in the LanguageExt public nuget package
and tracked by the issue

https://github.com/dotnet/runtime/issues/66079

For now the generic cycle detector is opt-in as it's relatively costly
in terms of compiler performance and it seems to be a relatively
niche case. We can follow up by optimizing the detector if it turns
out to be more prevalent or if we make the call to turn it on by
default, I have mentioned several options for that in the PR.

Thanks

Tomas
35 files changed:
src/coreclr/tools/Common/Compiler/GenericCycleDetection/GenericCycleDetection.projitems [new file with mode: 0644]
src/coreclr/tools/Common/Compiler/GenericCycleDetection/Graph.Cycles.cs [moved from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Cycles.cs with 100% similarity]
src/coreclr/tools/Common/Compiler/GenericCycleDetection/Graph.Vertex.cs [moved from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.Vertex.cs with 100% similarity]
src/coreclr/tools/Common/Compiler/GenericCycleDetection/Graph.cs [moved from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/Graph.cs with 100% similarity]
src/coreclr/tools/Common/Compiler/GenericCycleDetection/GraphBuilder.ForEach.cs [moved from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.ForEach.cs with 100% similarity]
src/coreclr/tools/Common/Compiler/GenericCycleDetection/GraphBuilder.MethodCall.cs [moved from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.MethodCall.cs with 100% similarity]
src/coreclr/tools/Common/Compiler/GenericCycleDetection/GraphBuilder.cs [moved from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/GraphBuilder.cs with 100% similarity]
src/coreclr/tools/Common/Compiler/GenericCycleDetection/ModuleCycleInfo.cs [moved from src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/LazyGenerics/ModuleCycleInfo.cs with 82% similarity]
src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/CompilerTypeSystemContext.Aot.cs
src/coreclr/tools/aot/ILCompiler.Compiler/ILCompiler.Compiler.csproj
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/AllMethodsOnTypeNode.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/DelayLoadHelperMethodImport.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/MethodFixupSignature.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRun/TypeFixupSignature.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/DependencyAnalysis/ReadyToRunCodegenNodeFactory.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilation.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCodegenCompilationBuilder.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilationModuleGroupBase.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunCompilerContext.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/ILCompiler.ReadyToRun.csproj
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs
src/coreclr/tools/aot/ILCompiler/Program.cs
src/coreclr/tools/aot/Mono.Linker.Tests/TestCasesRunner/ILCompilerDriver.cs
src/coreclr/tools/aot/crossgen2.sln
src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs
src/coreclr/tools/aot/crossgen2/Program.cs
src/coreclr/tools/aot/crossgen2/Properties/Resources.resx
src/tests/readytorun/GenericCycleDetection/Breadth1Test.cs [new file with mode: 0644]
src/tests/readytorun/GenericCycleDetection/Breadth1Test.csproj [new file with mode: 0644]
src/tests/readytorun/GenericCycleDetection/Depth1Test.cs [new file with mode: 0644]
src/tests/readytorun/GenericCycleDetection/Depth1Test.csproj [new file with mode: 0644]
src/tests/readytorun/GenericCycleDetection/Depth3Test.cs [new file with mode: 0644]
src/tests/readytorun/GenericCycleDetection/Depth3Test.csproj [new file with mode: 0644]