Skip to content

Ensure we don't print duplicate entries for the instruction-set help#119368

Merged
tannergooding merged 1 commit intodotnet:mainfrom
tannergooding:fix-119353
Sep 9, 2025
Merged

Ensure we don't print duplicate entries for the instruction-set help#119368
tannergooding merged 1 commit intodotnet:mainfrom
tannergooding:fix-119353

Conversation

@tannergooding
Copy link
Copy Markdown
Member

This fixes the command line output to ensure we don't get base, base, base, base or similar listed as detailed in #119353

Copy link
Copy Markdown
Contributor

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 fixes duplicate entries in command-line help output for instruction sets by ensuring each instruction set is only listed once per architecture. The changes prevent scenarios where the same instruction set name appears multiple times (like base, base, base, base) in help text.

Changes

  • Add deduplication logic to remove duplicate instruction set names when generating help text
  • Update example instruction sets in help text to use more modern examples

Reviewed Changes

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

File Description
src/coreclr/tools/aot/crossgen2/Properties/Resources.resx Update instruction set example from 'avx2,bmi,lzcnt' to 'avx,aes,apx'
src/coreclr/tools/aot/crossgen2/Crossgen2RootCommand.cs Add System.Linq import and DistinctBy() to deduplicate instruction sets
src/coreclr/tools/aot/ILCompiler/ILCompilerRootCommand.cs Add System.Linq import, DistinctBy() for deduplication, and update example

Copy link
Copy Markdown
Member

@jeffhandley jeffhandley left a comment

Choose a reason for hiding this comment

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

I'm good with this and I would support backporting it into 10.0 RC2 if the crew wants to.

@tannergooding
Copy link
Copy Markdown
Member Author

CC. @MichalStrehovsky, this is pending your sign-off for the ilc/crossgen command line help fix.

@MichalStrehovsky
Copy link
Copy Markdown
Member

CC. @MichalStrehovsky, this is pending your sign-off for the ilc/crossgen command line help fix.

Why are we ending up with multiples? I understand what the fix does, but if I am to sign off, I would like to understand what those extra entries are and why the existing if (instructionSet.Specifiable) filter doesn't work for them.

@tannergooding
Copy link
Copy Markdown
Member Author

@MichalStrehovsky because we need to maintain individual entries for R2R for back-compat (as per @jkotas in a previous PR): https://github.com/dotnet/runtime/blob/main/src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt

All while mapping relevant groups to a single InstructionSet_* entry for the JIT and a single --instruction-set * entry for NAOT/R2R command line.

Due to the relatively simplistic nature of the tooling, this generates InstructionSetInfo entries like the following:

yield return new InstructionSetInfo("base", "X86Base", InstructionSet.X64_X86Base, true);
yield return new InstructionSetInfo("base", "Sse", InstructionSet.X64_X86Base, true);
yield return new InstructionSetInfo("base", "Sse2", InstructionSet.X64_X86Base, true);
yield return new InstructionSetInfo("base", "Sse42", InstructionSet.X64_X86Base, true);
yield return new InstructionSetInfo("base", "Sse3", InstructionSet.X64_X86Base, true);
yield return new InstructionSetInfo("base", "Ssse3", InstructionSet.X64_X86Base, true);
yield return new InstructionSetInfo("base", "Sse41", InstructionSet.X64_X86Base, true);
yield return new InstructionSetInfo("base", "Popcnt", InstructionSet.X64_X86Base, true);
and so we need to deduplicate them

We could choose to note specify "base" for one of them, but then that breaks R2R and other query checks for user code (as it assumes any managed ISA is "specifiable") resulting in a much more complex (and risky) change being required.

Copy link
Copy Markdown
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

Makes sense, thanks!

@tannergooding tannergooding merged commit 61f8055 into dotnet:main Sep 9, 2025
97 checks passed
@tannergooding
Copy link
Copy Markdown
Member Author

Thanks @MichalStrehovsky. Should we backport this to .NET 10 as well to ensure a clean command line output there?

@tannergooding tannergooding deleted the fix-119353 branch September 9, 2025 22:31
@MichalStrehovsky
Copy link
Copy Markdown
Member

Thanks @MichalStrehovsky. Should we backport this to .NET 10 as well to ensure a clean command line output there?

I don't have a strong opinion on this. IlcInstructionSet is not officially documented on the ILC side and is soft-supported. Not sure where it stands on the crossgen2 side.

@tannergooding
Copy link
Copy Markdown
Member Author

I believe it's the same for crossgen2. CC. @jkotas ?

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Sep 11, 2025

I believe it's the same for crossgen2. CC. @jkotas ?

Right.

@tannergooding
Copy link
Copy Markdown
Member Author

tannergooding commented Sep 11, 2025

I'll leave it as is for now, unless someone feels strongly, and wait for a customer report then.

It's a bit odd that it prints the same name multiple times, but ultimately harmless and its unlikely many users will encounter the issue. It's been fixed in .NET 11 so will be correct moving forward.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 12, 2025
@jtschuster
Copy link
Copy Markdown
Member

We did get an issue reported here: #125730

Seems like a minor enough change to consider backporting to 10.

@jkotas
Copy link
Copy Markdown
Member

jkotas commented Mar 18, 2026

Seems like a minor enough change to consider backporting to 10.

ilc is an internal implementation detail of the NativeAOT toolset. We do not document how to run it directly.

I do not think that the backport would meet the servicing bar.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants