Intrinsics analyzer and fixes (#85481)
authorDavid Wrighton <davidwr@microsoft.com>
Tue, 16 May 2023 02:20:01 +0000 (19:20 -0700)
committerGitHub <noreply@github.com>
Tue, 16 May 2023 02:20:01 +0000 (19:20 -0700)
commit8a2aec1be77b2fbaea232758582fc932308fdec2
tree2fea937231e8344cfc88b6415ce7aac9ddb50238
parent42425673bf16345b1a876eab137093d140a67a16
Intrinsics analyzer and fixes (#85481)

* Implement analyzer for platform intrinsics use in System.Private.CoreLib

This analyzer detects the use of all platform intrinsics and checks to
ensure that they are all used either protected by an if statement OR
ternary operator which checks an appropriate IsSupported flag, or that
the intrinsic is used within a method where the behavior of platform
support for the intrinsic is not allowed to vary between compile time
and runtime. The analyzer attempts to be conservative about allowed patterns.

All existing code in System.Private.CoreLib has been annotated to avoid producing
errors.

See the markdown document for details.

Co-authored-by: Jeremy Koritzinsky <jkoritzinsky@gmail.com>
39 files changed:
docs/design/coreclr/botr/vectors-and-intrinsics.md
src/coreclr/tools/Common/JitInterface/CorInfoInstructionSet.cs
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetDesc.txt
src/coreclr/tools/Common/JitInterface/ThunkGenerator/InstructionSetGenerator.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/Compiler/ReadyToRunLibraryRootProvider.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunProfilingRootProvider.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunVisibilityRootProvider.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/Compiler/ReadyToRunXmlRootProvider.cs
src/coreclr/tools/aot/ILCompiler.ReadyToRun/JitInterface/CorInfoImpl.ReadyToRun.cs
src/coreclr/tools/aot/crossgen2/Program.cs
src/libraries/Common/src/System/HexConverter.cs
src/libraries/System.Private.CoreLib/gen/IntrinsicsInSystemPrivateCoreLibAnalyzer.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/gen/System.Private.CoreLib.Generators.csproj
src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems
src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Decoder.cs
src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Base64Encoder.cs
src/libraries/System.Private.CoreLib/src/System/Guid.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/Matrix4x4.Impl.cs
src/libraries/System.Private.CoreLib/src/System/Numerics/VectorMath.cs
src/libraries/System.Private.CoreLib/src/System/Runtime/BypassReadyToRunAttribute.cs [deleted file]
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompExactlyDependsOn.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/CompExactlyDependsOnAttribute.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/src/System/Runtime/Intrinsics/Vector128.cs
src/libraries/System.Private.CoreLib/src/System/SearchValues/IndexOfAnyAsciiSearcher.cs
src/libraries/System.Private.CoreLib/src/System/SearchValues/ProbabilisticMap.cs
src/libraries/System.Private.CoreLib/src/System/SpanHelpers.Packed.cs
src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Equality.cs
src/libraries/System.Private.CoreLib/src/System/Text/Ascii.Utility.cs
src/libraries/System.Private.CoreLib/src/System/Text/Ascii.cs
src/libraries/System.Private.CoreLib/src/System/Text/Latin1Utility.cs
src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf16Utility.Validation.cs
src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Transcoding.cs
src/libraries/System.Private.CoreLib/src/System/Text/Unicode/Utf8Utility.Validation.cs
src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1+Test.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/CSharpAnalyzerVerifier`1.cs [new file with mode: 0644]
src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLib.Tests.csproj [new file with mode: 0644]
src/libraries/System.Private.CoreLib/tests/IntrinsicsInSystemPrivatecoreLibAnalyzer.Tests/IntrinsicsInSystemPrivateCoreLibUnitTests.cs [new file with mode: 0644]