Skip to content
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

[JIT] CodeGen verification testing #75102

Merged
merged 110 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
3ba6b4e
Add test
markples Aug 23, 2022
2d9514c
Add CHECKs
markples Aug 23, 2022
919bd32
Build scripts and test settings
markples Aug 24, 2022
a6ca583
COMPlus -> DOTNET
markples Aug 24, 2022
9703ef1
Fix filenames
markples Aug 24, 2022
b2c390d
Missing >
markples Aug 24, 2022
be61d44
Missing quotes
markples Aug 24, 2022
0a24211
use %scriptPath%
markples Aug 24, 2022
49cd2e2
Rework properties, start two examples
markples Aug 25, 2022
755434a
Arch demo
markples Aug 25, 2022
9bd8688
Cleanup
markples Aug 25, 2022
d2d0c42
Remove tab
markples Aug 25, 2022
ebeba17
Easier environment variables. Undo precommand changes.
markples Aug 26, 2022
41a50ab
undo blank line
markples Aug 26, 2022
703ca31
clean CHECKs
markples Aug 26, 2022
2c7bd7c
Draft of bash
markples Aug 30, 2022
d83d5a9
Bash, conditionals
markples Aug 31, 2022
350479c
More variables, start on run.cmd/sh/py
markples Aug 31, 2022
6f38dc4
another output
markples Aug 31, 2022
f85898d
Support in cmd/bash for RunningDisasmChecks
markples Sep 1, 2022
c0b8e48
copy, factor, formatting
markples Sep 1, 2022
e03f671
Initial work to include FileCheck. Added SuperFileCheck.
TIHan Sep 1, 2022
d428d5a
Able to build SuperFileCheck
TIHan Sep 1, 2022
55bd334
Do not DisasmCheck TypeEquality_r for now. Update some FileChecks to …
TIHan Sep 1, 2022
cddc870
Partially wiring up SuperFileCheck to tests
TIHan Sep 1, 2022
b08e73b
Piping list of method names from SuperFileCheck to JitDisasm
TIHan Sep 2, 2022
09873fd
Handling bash a little bit
TIHan Sep 2, 2022
aa2c670
Moving SuperFileCheck to tests/Common
TIHan Sep 2, 2022
1b711a6
Few tweaks
TIHan Sep 2, 2022
3114c5c
Building SuperFileCheck as part of the test build
TIHan Sep 2, 2022
c661505
Tweaking a few things
TIHan Sep 2, 2022
fbb248d
Fixed a bug
TIHan Sep 2, 2022
5dd1122
Moving SuperFileCheck back to src\coreclr\tools. Removed checks from …
TIHan Sep 2, 2022
68b708c
Restore original logic in Runtime_73681
markples Sep 2, 2022
f894efc
Merge pull request #1 from markples/patch-1
TIHan Sep 2, 2022
7248bbc
Trying to add CI leg for disasmchecks
TIHan Sep 6, 2022
b377ff3
Use x64 package if x86 platform detected for JIT tools package
TIHan Sep 7, 2022
c0dbc2d
Remove innerloop for disasmchecks
TIHan Sep 7, 2022
b56da5d
Merging with main
TIHan Sep 7, 2022
a508dd8
Trying to fix build. Only run in Windows for now.
TIHan Sep 9, 2022
6a92a11
Update Runtime_73681.cs
TIHan Sep 9, 2022
b159d3f
Trying to fix build
TIHan Sep 9, 2022
8960885
Update Runtime_73681.cs
TIHan Sep 9, 2022
0a779d3
Update Runtime_73681.cs
TIHan Sep 9, 2022
a30d018
Fixing a few issues
TIHan Sep 10, 2022
820821e
Trying to run disasmchecks as part of CI
TIHan Sep 13, 2022
c1a2829
Trying to run disasmchecks
TIHan Sep 14, 2022
c976b5b
Trying to run disasmchecks
TIHan Sep 14, 2022
4d29828
Trying to run disasmchecks
TIHan Sep 14, 2022
39f843b
Revert a change
TIHan Sep 14, 2022
63591b1
Trying to run disasmchecks
TIHan Sep 14, 2022
a04e20b
Trying to run disasmchecks
TIHan Sep 14, 2022
3b2f546
build SuperFileCheck on non-windows
TIHan Sep 14, 2022
ac01d79
few tweaks
TIHan Sep 14, 2022
e6a66cf
Trying to fix CI
TIHan Sep 14, 2022
b09a1e9
Including SuperFileCheck for tests
TIHan Sep 14, 2022
9b394f3
Cleanup
TIHan Sep 14, 2022
2696054
More cleanup
TIHan Sep 14, 2022
2647059
Merge remote-tracking branch 'upstream/main' into super-filecheck
TIHan Sep 14, 2022
8023757
Cleanup
TIHan Sep 15, 2022
e6b28ca
Changed SuperFileCheck to not publish everything. Changed SuperFileCh…
TIHan Sep 15, 2022
a3d2f8a
Invoking SuperFileCheck using dotnet
TIHan Sep 15, 2022
6627f61
Making the test pass
TIHan Sep 15, 2022
04c7fcf
Only run disasm checks for coreclr and not mono
TIHan Sep 15, 2022
6c5d35e
Using HasBatchDisasmCheck and HasBashDisasmCheck to determine to run …
TIHan Sep 15, 2022
07810d1
Enabling filecheck on linux and osx
TIHan Sep 15, 2022
881c41c
Added more comments
TIHan Sep 15, 2022
e0838e1
Added ARM64 specific test. Do not run SuperFileCheck if no methods we…
TIHan Sep 15, 2022
025ed95
Added documentation. Changed disasm-output.
TIHan Sep 15, 2022
f6ee949
Minor doc tweak
TIHan Sep 15, 2022
27553a5
Minor doc tweak
TIHan Sep 15, 2022
67b1ca8
Minor doc tweak
TIHan Sep 15, 2022
015349e
Minor doc tweak
TIHan Sep 15, 2022
2e0516b
Minor doc tweak
TIHan Sep 15, 2022
8261543
Cleanup. Trying to fix linux
TIHan Sep 16, 2022
5034c53
Fixing test
TIHan Sep 16, 2022
94db653
Add information on additional functionality
markples Sep 16, 2022
c7f8ebb
cleanup
markples Sep 16, 2022
d51f799
Add FileCheck snippet
markples Sep 16, 2022
15b8f05
Undo environment variable changes
markples Sep 2, 2022
241b52a
Merge pull request #2 from markples/test/super-filecheck-md
TIHan Sep 16, 2022
c7b9ae4
Feedback from Mark
TIHan Sep 16, 2022
6c68af5
Cleanup
TIHan Sep 16, 2022
c30dfaf
Trying to fix linux test run
TIHan Sep 17, 2022
b3733bc
Trying to fix linux test run
TIHan Sep 17, 2022
0756cbc
A few missing changes from the original branch
markples Sep 19, 2022
e795bcd
Merge remote-tracking branch 'tihan/super-filecheck' into test/super-…
markples Sep 19, 2022
ec5fcea
Merge remote-tracking branch 'upstream/main' into super-filecheck
TIHan Sep 19, 2022
bd0c141
Enable OSX for disasm checks
TIHan Sep 19, 2022
78798c8
cleanup / comment
markples Sep 19, 2022
55e3750
Force test failure
TIHan Sep 20, 2022
fb4e569
Update Runtime_73681.cs
TIHan Sep 20, 2022
bd12e2f
Merge pull request #3 from markples/test/super-filecheck-more
TIHan Sep 20, 2022
557149e
Set env vars after errorlevel check
TIHan Sep 20, 2022
5388c2e
Reverting back on setting environment variables in test. Added new Fi…
TIHan Sep 20, 2022
e04322a
Force a failure by changing the register
TIHan Sep 20, 2022
5951aeb
Ignore native binaries for superpmi collect
TIHan Sep 20, 2022
de3ca4d
Update Runtime_34937.cs
TIHan Sep 21, 2022
9232708
Force the correct failure
TIHan Sep 21, 2022
3539236
Update Runtime_34937.cs
TIHan Sep 21, 2022
5546eca
Update Runtime_34937.cs
TIHan Sep 21, 2022
e07876a
Merge branch 'super-filecheck' of github.com:TIHan/runtime into super…
TIHan Sep 21, 2022
ecb67eb
Adding specific OS check prefixes. Changed dump-input context amount
TIHan Sep 21, 2022
5a958c2
Added getting fully qualified method names with wildcards for SuperFi…
TIHan Sep 21, 2022
a8e7135
More tests. Fixed a few issues with generics.
TIHan Sep 22, 2022
a375ac7
Disabling generic support
TIHan Sep 22, 2022
b184a5d
Error if it cannot find enclosing type declaration
TIHan Sep 22, 2022
45317a3
Fixing build
TIHan Sep 22, 2022
4674729
Remove namespac
TIHan Sep 22, 2022
bf1bf7f
Bring generics back, but in a limited form
TIHan Sep 23, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 85 additions & 0 deletions docs/workflow/testing/coreclr/disasm-checks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Disassembly output verification checks
There are tests that the runtime executes that will be able to verify X64/ARM64 assembly output from the JIT.
The tools used to accomplish this are LLVM FileCheck, SuperFileCheck, and the JIT's ability to output disassembly using `DOTNET_JitDisasm`. LLVM FileCheck is built in https://www.github.com/dotnet/llvm-project and provides several packages for the various platforms. See more about LLVM FileCheck and its syntax here: https://llvm.org/docs/CommandGuide/FileCheck.html. SuperFileCheck is a custom tool located in https://www.github.com/dotnet/runtime. It wraps LLVM FileCheck and provides a simplified workflow for writing these tests in a C# file by leveraging Roslyn's syntax tree APIs.
# What is FileCheck?
From https://www.llvm.org/docs/CommandGuide/FileCheck.html:

> **FileCheck** reads two files (one from standard input, and one specified on the command line) and uses one
to verify the other. This behavior is particularly useful for the testsuite, which wants to verify that the
output of some tool (e.g. **llc**) contains the expected information (for example, a movsd from esp or
whatever is interesting). This is similar to using **grep**, but it is optimized for matching multiple
different inputs in one file in a specific order.
# Converting an existing test to use disassembly checking
We will use the existing test `JIT\Regression\JitBlue\Runtime_33972` as an example. The test's intent is to verify that on ARM64, the method `AdvSimd.CompareEqual` behaves correctly when a zero vector is passed as the second argument. Below are snippets of its use:
```csharp
static Vector64<byte> AdvSimd_CompareEqual_Vector64_Byte_Zero(Vector64<byte> left)
{
return AdvSimd.CompareEqual(left, Vector64<byte>.Zero);
}
...
...
if (!ValidateResult_Vector64<byte>(AdvSimd_CompareEqual_Vector64_Byte_Zero(Vector64<byte>.Zero), Byte.MaxValue))
result = -1;
```
Currently, the test only verifies that the behavior is correct. It does not verify that the optimal ARM64 instruction was actually used. So now we will add this verification.
First we need to modify the project file `Runtime_33972.csproj`:
```xml
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
</PropertyGroup>
<PropertyGroup>
<DebugType>None</DebugType>
<Optimize>True</Optimize>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>
```
Looking at the `ItemGroup`:
```xml
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
```
We want to add `<HasDisasmCheck>true</HasDisasmCheck>` as a child of the `Compile` tag:
```xml
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs">
<HasDisasmCheck>true</HasDisasmCheck>
</Compile>
</ItemGroup>
```
Doing this lets the test builder and runner know that this test has assembly that needs to be verified. Finally, we need to write the assembly check and put the `[MethodImpl(MethodImplOptions.NoInlining)]` attribute on the method `AdvSimd_CompareEqual_Vector64_Byte_Zero`:
```csharp
[MethodImpl(MethodImplOptions.NoInlining)]
static Vector64<byte> AdvSimd_CompareEqual_Vector64_Byte_Zero(Vector64<byte> left)
{
// ARM64-FULL-LINE: cmeq v0.8b, v0.8b, #0
return AdvSimd.CompareEqual(left, Vector64<byte>.Zero);
}
```
And that is it. A few notes about the above example:
- `ARM64-FULL-LINE` checks to see if there is an exact line that matches the disassembly output of the method `AdvSimd_CompareEqual_Vector64_Byte_Zero` - leading and trailing spaces are ignored.
- Method bodies that have FileCheck syntax, e.g. `ARM64-FULL-LINE:`/`X64:`/etc, must have the attribute `[MethodImpl(MethodImplOptions.NoInlining)]`. If it does not, then an error is reported.
- FileCheck syntax outside of a method body will also report an error.
# Additional functionality
LLVM has a different setup where each test file is passed to `lit`, and `RUN:` lines inside the test specify
configuration details such as architectures to run, FileCheck prefixes to use, etc. In our case, the build
files handle a lot of this with build conditionals and `.cmd`/`.sh` file generation. Additionally, LLVM tests
rely on the order of the compiler output corresponding to the order of the input functions in the test file.
When running under the JIT, the compilation order is dependent on execution, not the source order.

Functionality that has been added or moved to MSBuild:
- Conditionals controlling test execution
- Automatic specificiation of `CHECK` and `<architecture>` as check prefixes

Functionality that has been added or moved to SuperFileCheck:
- Each function is run under a separate invocation of FileCheck. SuperFileCheck adds additional `CHECK` lines
that search for the beginning and end of the output for each function. This ensures that output from
different functions don't contaminate each other. The separate invocations remove any dependency on the
order of the functions.
- `<check-prefix>-FULL-LINE:` - same as using FileCheck's `<check-prefix>:`, but checks that the line matches exactly; leading and trailing whitespace is ignored.
- `<check-prefix>-FULL-LINE-NEXT:` - same as using FileCheck's `<check-prefix>-NEXT:`, but checks that the line matches exactly; leading and trailing whitespace is ignored.
2 changes: 2 additions & 0 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,8 @@

<ProjectToBuild Condition="'$(NativeAotSupported)' == 'true' and '$(TargetArchitecture)' != '$(BuildArchitecture)'" Include="$(CoreClrProjectRoot)tools\aot\ILCompiler\ILCompiler_crossarch.csproj" Category="clr" />
<ProjectToBuild Condition="'$(TargetArchitecture)' != '$(BuildArchitecture)'" Include="$(CoreClrProjectRoot)tools\aot\crossgen2\crossgen2_crossarch.csproj" Category="clr" />

<ProjectToBuild Condition="'$(TargetOS)' == 'windows' or ('$(TargetOS)' == 'Linux' and ('$(TargetArchitecture)' == 'x64' or '$(TargetArchitecture)' == 'arm64')) or '$(TargetOS)' == 'OSX'" Include="$(CoreClrProjectRoot)tools\SuperFileCheck\SuperFileCheck.csproj" Category="clr" />
</ItemGroup>

<ItemGroup Condition="$(_subset.Contains('+clr.toolstests+'))">
Expand Down
32 changes: 32 additions & 0 deletions eng/Version.Details.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,38 @@
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>8688ea2538ef1287c6619d35a26b5750d355cc18</Sha>
</Dependency>
<Dependency Name="runtime.linux-arm64.Microsoft.NETCore.Runtime.JIT.Tools" Version="1.0.0-alpha.1.22431.4">
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>c1304304028d603e34f6803b0740c34441f80d2e</Sha>
</Dependency>
<Dependency Name="runtime.linux-x64.Microsoft.NETCore.Runtime.JIT.Tools" Version="1.0.0-alpha.1.22431.4">
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>c1304304028d603e34f6803b0740c34441f80d2e</Sha>
</Dependency>
<Dependency Name="runtime.linux-musl-arm64.Microsoft.NETCore.Runtime.JIT.Tools" Version="1.0.0-alpha.1.22431.4">
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>c1304304028d603e34f6803b0740c34441f80d2e</Sha>
</Dependency>
<Dependency Name="runtime.linux-musl-x64.Microsoft.NETCore.Runtime.JIT.Tools" Version="1.0.0-alpha.1.22431.4">
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>754d13817d834b716d339183e21aac7d2489c496</Sha>
</Dependency>
<Dependency Name="runtime.win-arm64.Microsoft.NETCore.Runtime.JIT.Tools" Version="1.0.0-alpha.1.22431.4">
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>c1304304028d603e34f6803b0740c34441f80d2e</Sha>
</Dependency>
<Dependency Name="runtime.win-x64.Microsoft.NETCore.Runtime.JIT.Tools" Version="1.0.0-alpha.1.22431.4">
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>c1304304028d603e34f6803b0740c34441f80d2e</Sha>
</Dependency>
<Dependency Name="runtime.osx.11.0-arm64.Microsoft.NETCore.Runtime.JIT.Tools" Version="1.0.0-alpha.1.22431.4">
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>c1304304028d603e34f6803b0740c34441f80d2e</Sha>
</Dependency>
<Dependency Name="runtime.osx.10.12-x64.Microsoft.NETCore.Runtime.JIT.Tools" Version="1.0.0-alpha.1.22431.4">
<Uri>https://github.com/dotnet/llvm-project</Uri>
<Sha>c1304304028d603e34f6803b0740c34441f80d2e</Sha>
</Dependency>
<Dependency Name="System.CommandLine" Version="2.0.0-beta4.22355.1">
<Uri>https://github.com/dotnet/command-line-api</Uri>
<Sha>5618b2d243ccdeb5c7e50a298b33b13036b4351b</Sha>
Expand Down
9 changes: 9 additions & 0 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,14 @@
<SwixPackageVersion>1.1.87-gba258badda</SwixPackageVersion>
<WixPackageVersion>1.0.0-v3.14.0.5722</WixPackageVersion>
<MonoWorkloadManifestVersion>6.0.0-preview.5.21275.7</MonoWorkloadManifestVersion>
<!-- JIT Tools -->
<runtimelinuxarm64MicrosoftNETCoreRuntimeJITToolsVersion>1.0.0-alpha.1.22431.4</runtimelinuxarm64MicrosoftNETCoreRuntimeJITToolsVersion>
<runtimelinuxx64MicrosoftNETCoreRuntimeJITToolsVersion>1.0.0-alpha.1.22431.4</runtimelinuxx64MicrosoftNETCoreRuntimeJITToolsVersion>
<runtimelinuxmuslarm64MicrosoftNETCoreRuntimeJITToolsVersion>1.0.0-alpha.1.22431.4</runtimelinuxmuslarm64MicrosoftNETCoreRuntimeJITToolsVersion>
<runtimelinuxmuslx64MicrosoftNETCoreRuntimeJITToolsVersion>1.0.0-alpha.1.22431.4</runtimelinuxmuslx64MicrosoftNETCoreRuntimeJITToolsVersion>
<runtimewinarm64MicrosoftNETCoreRuntimeJITToolsVersion>1.0.0-alpha.1.22431.4</runtimewinarm64MicrosoftNETCoreRuntimeJITToolsVersion>
<runtimewinx64MicrosoftNETCoreRuntimeJITToolsVersion>1.0.0-alpha.1.22431.4</runtimewinx64MicrosoftNETCoreRuntimeJITToolsVersion>
<runtimeosx110arm64MicrosoftNETCoreRuntimeJITToolsVersion>1.0.0-alpha.1.22431.4</runtimeosx110arm64MicrosoftNETCoreRuntimeJITToolsVersion>
<runtimeosx1012x64MicrosoftNETCoreRuntimeJITToolsVersion>1.0.0-alpha.1.22431.4</runtimeosx1012x64MicrosoftNETCoreRuntimeJITToolsVersion>
</PropertyGroup>
</Project>
3 changes: 3 additions & 0 deletions src/coreclr/scripts/superpmi_collect_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@
"vcruntime140_1.dll",
"R2RDump.exe",
"R2RTest.exe",
"FileCheck.exe",
"SuperFileCheck.exe",
"llvm-mca.exe",
"superpmi.exe",
"superpmi-shim-collector.dll",
"superpmi-shim-counter.dll",
Expand Down
Loading