-
Notifications
You must be signed in to change notification settings - Fork 5.2k
Reuse crossgen2 logic to lay out methods using PGO data #114736
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,7 @@ | |
| binaries are up to date and which are stale. --> | ||
| <GenerateDependencyFile>false</GenerateDependencyFile> | ||
| <Configurations>Debug;Release;Checked</Configurations> | ||
| <RunAnalyzers>false</RunAnalyzers> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Intentional? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Matches ILCompiler.ReadyToRun, there are several low value warnings and I'm honestly growing tired of the analyzers and pragma warning suppresions we're accumulating as a result and decided to just take a page from the crossgen project. |
||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
|
|
@@ -98,5 +99,9 @@ | |
|
|
||
| <Compile Include="..\ILCompiler.ReadyToRun\Compiler\ProfileData.cs" Link="Pgo\ProfileData.cs" /> | ||
|
|
||
| <Compile Include="..\ILCompiler.ReadyToRun\Compiler\PettisHansenSort\CallGraphNode.cs" Link="Compiler\PettisHansenSort\CallGraphNode.cs" /> | ||
| <Compile Include="..\ILCompiler.ReadyToRun\Compiler\PettisHansenSort\DisjointSetForest.cs" Link="Compiler\PettisHansenSort\DisjointSetForest.cs" /> | ||
| <Compile Include="..\ILCompiler.ReadyToRun\Compiler\PettisHansenSort\PettisHansen.cs" Link="Compiler\PettisHansenSort\PettisHansen.cs" /> | ||
| <Compile Include="..\ILCompiler.ReadyToRun\Compiler\ReadyToRunFileLayoutOptimizer.cs" Link="Compiler\ReadyToRunFileLayoutOptimizer.cs" /> | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to drop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, just wanted to keep the diff small |
||
| </ItemGroup> | ||
| </Project> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -27,6 +27,10 @@ internal sealed class ILCompilerRootCommand : RootCommand | |
| new("--optimize-time", "--Ot") { Description = "Enable optimizations, favor code speed" }; | ||
| public Option<string[]> MibcFilePaths { get; } = | ||
| new("--mibc", "-m") { DefaultValueFactory = _ => Array.Empty<string>(), Description = "Mibc file(s) for profile guided optimization" }; | ||
| public Option<ReadyToRunMethodLayoutAlgorithm> MethodLayout { get; } = | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these options have the right default? Or is that a future item? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a copypaste from crossgen - this should default to 0, which means don't do it. |
||
| new("--method-layout") { CustomParser = MakeReadyToRunMethodLayoutAlgorithm, DefaultValueFactory = MakeReadyToRunMethodLayoutAlgorithm, Description = "Layout algorithm used by profile-driven optimization for arranging methods in a file.", HelpName = "arg" }; | ||
| public Option<ReadyToRunFileLayoutAlgorithm> FileLayout { get; } = | ||
| new("--file-layout") { CustomParser = MakeReadyToRunFileLayoutAlgorithm, DefaultValueFactory = MakeReadyToRunFileLayoutAlgorithm, Description = "Layout algorithm used by profile-driven optimization for arranging non-method contents in a file.", HelpName = "arg" }; | ||
| public Option<string[]> SatelliteFilePaths { get; } = | ||
| new("--satellite") { DefaultValueFactory = _ => Array.Empty<string>(), Description = "Satellite assemblies associated with inputs/references" }; | ||
| public Option<bool> EnableDebugInfo { get; } = | ||
|
|
@@ -187,6 +191,8 @@ public ILCompilerRootCommand(string[] args) : base(".NET Native IL Compiler") | |
| Options.Add(OptimizeSpace); | ||
| Options.Add(OptimizeTime); | ||
| Options.Add(MibcFilePaths); | ||
| Options.Add(MethodLayout); | ||
| Options.Add(FileLayout); | ||
| Options.Add(SatelliteFilePaths); | ||
| Options.Add(EnableDebugInfo); | ||
| Options.Add(UseDwarf5); | ||
|
|
@@ -411,6 +417,36 @@ private static int MakeParallelism(ArgumentResult result) | |
| return parallelism; | ||
| } | ||
|
|
||
| private static ReadyToRunMethodLayoutAlgorithm MakeReadyToRunMethodLayoutAlgorithm(ArgumentResult result) | ||
| { | ||
| if (result.Tokens.Count == 0) | ||
| return ReadyToRunMethodLayoutAlgorithm.DefaultSort; | ||
|
|
||
| return result.Tokens[0].Value.ToLowerInvariant() switch | ||
| { | ||
| "defaultsort" => ReadyToRunMethodLayoutAlgorithm.DefaultSort, | ||
| "exclusiveweight" => ReadyToRunMethodLayoutAlgorithm.ExclusiveWeight, | ||
| "hotcold" => ReadyToRunMethodLayoutAlgorithm.HotCold, | ||
| "hotwarmcold" => ReadyToRunMethodLayoutAlgorithm.HotWarmCold, | ||
| "pettishansen" => ReadyToRunMethodLayoutAlgorithm.PettisHansen, | ||
| "random" => ReadyToRunMethodLayoutAlgorithm.Random, | ||
| _ => throw new CommandLineException(result.Tokens[0].Value) | ||
| }; | ||
| } | ||
|
|
||
| private static ReadyToRunFileLayoutAlgorithm MakeReadyToRunFileLayoutAlgorithm(ArgumentResult result) | ||
| { | ||
| if (result.Tokens.Count == 0) | ||
| return ReadyToRunFileLayoutAlgorithm.DefaultSort; | ||
|
|
||
| return result.Tokens[0].Value.ToLowerInvariant() switch | ||
| { | ||
| "defaultsort" => ReadyToRunFileLayoutAlgorithm.DefaultSort, | ||
| "methodorder" => ReadyToRunFileLayoutAlgorithm.MethodOrder, | ||
| _ => throw new CommandLineException(result.Tokens[0].Value) | ||
| }; | ||
| } | ||
|
|
||
| #if DEBUG | ||
| private static bool DumpReproArguments(CodeGenerationFailedException ex) | ||
| { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.