Skip to content

Make it possible to order methods by specifying symbolic names #117537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 18, 2025

Conversation

MichalStrehovsky
Copy link
Member

Text file with an ordered list of symbol names is much easier to emit based on sampling than MIBC (that requires methods in IL terms). Methods that are listed are generated in the specified order. Methods that are not listed are sorted by the compiler. Things that are listed but don't exist are silently skipped.

Cc @dotnet/ilc-contrib

Text file with an ordered list of symbol names is much easier to emit based on sampling than MIBC (that requires methods in IL terms). Methods that are listed are generated in the specified order. Methods that are not listed are sorted by the compiler. Things that are listed but don't exist are silently skipped.
@Copilot Copilot AI review requested due to automatic review settings July 11, 2025 13:11
Copy link
Contributor

Tagging subscribers to this area: @agocke, @MichalStrehovsky, @jkotas
See info in area-owners.md if you want to be subscribed.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces support for ordering emitted methods by providing a symbol list file, plus a corresponding smoke test and build integration.

  • Adds a new --order option to ILCompiler and wires it through to the RyuJIT builder and file layout optimizer.
  • Implements an explicit layout algorithm in FileLayoutOptimizer that reads symbol names from the specified order file.
  • Updates the test suite with Ordering.cs, order.txt, and MSBuild targets to exercise and pass the order file to the native AOT compilation.

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
src/tests/nativeaot/SmokeTests/UnitTests/order.txt New order file listing symbols for explicit layout
src/tests/nativeaot/SmokeTests/UnitTests/UnitTests.csproj Added <IlcOrderFile> property and include Ordering.cs
src/tests/nativeaot/SmokeTests/UnitTests/Ordering.cs Smoke test sorting method pointers by address
src/tests/nativeaot/SmokeTests/UnitTests/Main.cs Added Ordering.Run to the test sequence
src/coreclr/tools/aot/ILCompiler/Program.cs Integrated .UseSymbolOrder into the compilation builder
src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs Defined the --order CLI option
src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilationBuilder.cs Added UseSymbolOrder and _orderFile field
src/coreclr/tools/aot/ILCompiler.RyuJit/Compiler/RyuJitCompilation.cs Propagated orderFile to FileLayoutOptimizer
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/FileLayoutOptimizer.cs Implemented Explicit layout by reading the order file
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.targets Passed --order and --method-layout:explicit and included order file in inputs
Comments suppressed due to low confidence (2)

src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/FileLayoutOptimizer.cs:208

  • There are no existing tests validating that the Explicit layout algorithm actually applies the file's symbol order; consider adding unit or integration tests that inspect the generated layout to ensure the feature works as intended.
                case MethodLayoutAlgorithm.Explicit:

src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/FileLayoutOptimizer.cs:223

  • [nitpick] Normalize or trim symbol names (e.g. strip leading underscores) when comparing against GetMangledName to ensure cross-platform consistency and avoid silent skips.
                            string symbolName = sr.ReadLine();

@MichalStrehovsky
Copy link
Member Author

@dotnet/ilc-contrib could someone have a look at this? This is for a first party customer and I'd like this to make the next preview.

Copy link
Member

@agocke agocke left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, a few questions about perf that aren't critical

@MichalStrehovsky MichalStrehovsky merged commit f37ff8a into dotnet:main Jul 18, 2025
101 of 103 checks passed
@MichalStrehovsky MichalStrehovsky deleted the sortmethods branch July 18, 2025 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants