Skip to content

Add Three Codegen Tests #134626

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

veera-sivarajan
Copy link
Contributor

@veera-sivarajan veera-sivarajan commented Dec 21, 2024

Closes #123216
Closes #49572
Closes #93514

This PR adds three codegen tests.

@rustbot
Copy link
Collaborator

rustbot commented Dec 21, 2024

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Dec 21, 2024
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@Mark-Simulacrum
Copy link
Member

@bors r+ rollup=iffy

@bors
Copy link
Collaborator

bors commented Dec 26, 2024

📌 Commit 62fedef has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 26, 2024
@bors
Copy link
Collaborator

bors commented Dec 27, 2024

⌛ Testing commit 62fedef with merge 655cf53...

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 27, 2024
…r=Mark-Simulacrum

Add Four Codegen Tests

Closes rust-lang#74615
Closes rust-lang#123216
Closes rust-lang#49572
Closes rust-lang#93514

This PR adds four codegen tests. The FileCheck assertions were generated with the help of `update_test_checks.py` and `update_llc_test_checks.py` from the LLVM project.
@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Dec 27, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 27, 2024
@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Jan 11, 2025

📌 Commit 0ec717b has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 11, 2025
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 12, 2025
…r=Mark-Simulacrum

Add Four Codegen Tests

Closes rust-lang#74615
Closes rust-lang#123216
Closes rust-lang#49572
Closes rust-lang#93514

This PR adds four codegen tests. The FileCheck assertions were generated with the help of `update_test_checks.py` and `update_llc_test_checks.py` from the LLVM project.
@bors
Copy link
Collaborator

bors commented Jan 12, 2025

⌛ Testing commit 0ec717b with merge 159ccc2...

@rust-log-analyzer

This comment has been minimized.

@bors
Copy link
Collaborator

bors commented Jan 12, 2025

💔 Test failed - checks-actions

@bors bors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 11, 2025
@veera-sivarajan
Copy link
Contributor Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 12, 2025
Copy link
Member

@dianqk dianqk left a comment

Choose a reason for hiding this comment

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

This PR adds four codegen tests. The FileCheck assertions were generated with the help of update_test_checks.py and update_llc_test_checks.py from the LLVM project.

Should we use them? Or should we add so many CHECK?

Unlike LLVM, we test multiple platforms in Rust, and this IR also comes from codegen. These IRs can vary.

// CHECK: andl $1, %eax
// CHECK: shll $4, %eax
// CHECK: orb $1, (%rcx,%rax)
// CHECK-NOT: jmp
Copy link
Member

Choose a reason for hiding this comment

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

Just a question: should this be an assembly test?
The IR change was introduced by llvm/llvm-project#84628, and this is not a backend change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I think assembly test would be better because there isn't a big difference in the IR: https://rust.godbolt.org/z/sd7G1rsa7

Thanks

Noratrieb added a commit to Noratrieb/rust that referenced this pull request Mar 6, 2025
…, r=Mark-Simulacrum

Add Four Codegen Tests

Closes rust-lang#74615
Closes rust-lang#123216
Closes rust-lang#49572
Closes rust-lang#93514

This PR adds four codegen tests. The FileCheck assertions were generated with the help of `update_test_checks.py` and `update_llc_test_checks.py` from the LLVM project.
@Dylan-DPC
Copy link
Member

@veera-sivarajan any updates on this? thanks

@veera-sivarajan
Copy link
Contributor Author

Should we use them? Or should we add so many CHECK?

Yeah, I realized we don't need such stringent checks. Thanks for letting me know.

@veera-sivarajan veera-sivarajan changed the title Add Four Codegen Tests Add Three Codegen Tests Mar 11, 2025
@veera-sivarajan
Copy link
Contributor Author

Removed a test since it regressed in nightly: https://godbolt.org/z/G3989xP1G

@veera-sivarajan
Copy link
Contributor Author

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 11, 2025
@Mark-Simulacrum
Copy link
Member

@bors r+

@bors
Copy link
Collaborator

bors commented Mar 15, 2025

📌 Commit 8c80d2e has been approved by Mark-Simulacrum

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 15, 2025
@bors
Copy link
Collaborator

bors commented Mar 15, 2025

⌛ Testing commit 8c80d2e with merge 1035592...

bors added a commit to rust-lang-ci/rust that referenced this pull request Mar 15, 2025
…r=Mark-Simulacrum

Add Three Codegen Tests

Closes rust-lang#123216
Closes rust-lang#49572
Closes rust-lang#93514

This PR adds three codegen tests.
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-msvc-1 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
failures:

---- [assembly] tests\assembly\indexing-with-bools-no-redundant-instructions.rs stdout ----

error: verification with 'FileCheck' failed
status: exit code: 1
command: PATH=";C:\Program Files (x86)\Windows Kits\10\bin\x64;C:\Program Files (x86)\Windows Kits\10\bin\10.0.26100.0\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64;D:\a\rust\rust\build\x86_64-pc-windows-msvc\stage0-bootstrap-tools\x86_64-pc-windows-msvc\release\deps;D:\a\rust\rust\build\x86_64-pc-windows-msvc\stage0\bin;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Users\runneradmin\bin;D:\a\rust\rust\ninja;D:\a\rust\rust\sccache;C:\Program Files\MongoDB\Server\7.0\bin;C:\vcpkg;C:\tools\zstd;C:\hostedtoolcache\windows\stack\3.3.1\x64;C:\cabal\bin;C:\ghcup\bin;C:\mingw64\bin;C:\Program Files\dotnet;C:\Program Files\MySQL\MySQL Server 8.0\bin;C:\Program Files\R\R-4.4.2\bin\x64;C:\SeleniumWebDrivers\GeckoDriver;C:\SeleniumWebDrivers\EdgeDriver;C:\SeleniumWebDrivers\ChromeDriver;C:\Program Files (x86)\sbt\bin;C:\Program Files (x86)\GitHub CLI;C:\Program Files\Git\usr\bin;C:\Program Files (x86)\pipx_bin;C:\npm\prefix;C:\hostedtoolcache\windows\go\1.23.7\x64\bin;C:\hostedtoolcache\windows\Python\3.9.13\x64\Scripts;C:\hostedtoolcache\windows\Python\3.9.13\x64;C:\hostedtoolcache\windows\Ruby\3.3.7\x64\bin;C:\Program Files\OpenSSL\bin;C:\tools\kotlinc\bin;C:\hostedtoolcache\windows\Java_Temurin-Hotspot_jdk\17.0.14-7\x64\bin;C:\Program Files\ImageMagick-7.1.1-Q16-HDRI;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\ProgramData\kind;C:\ProgramData\Chocolatey\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Windows\System32\OpenSSH;C:\Program Files\PowerShell\7;C:\Program Files\Microsoft\Web Platform Installer;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn;C:\Program Files\Microsoft SQL Server\150\Tools\Binn;C:\Program Files\dotnet;C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit;C:\Program Files (x86)\WiX Toolset v3.14\bin;C:\Program Files\Microsoft SQL Server\130\DTS\Binn;C:\Program Files\Microsoft SQL Server\140\DTS\Binn;C:\Program Files\Microsoft SQL Server\150\DTS\Binn;C:\Program Files\Microsoft SQL Server\160\DTS\Binn;C:\ProgramData\chocolatey\lib\pulumi\tools\Pulumi\bin;C:\Program Files\CMake\bin;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\ProgramData\chocolatey\lib\maven\apache-maven-3.9.9\bin;C:\Program Files\Microsoft Service Fabric\bin\Fabric\Fabric.Code;C:\Program Files\Microsoft SDKs\Service Fabric\Tools\ServiceFabricLocalClusterManager;C:\Program Files\nodejs;C:\Program Files\Git\cmd;C:\Program Files\Git\mingw64\bin;C:\Program Files\Git\usr\bin;C:\Program Files\GitHub CLI;C:\tools\php;C:\Program Files (x86)\sbt\bin;C:\Program Files\Amazon\AWSCLIV2;C:\Program Files\Amazon\SessionManagerPlugin\bin;C:\Program Files\Amazon\AWSSAMCLI\bin;C:\Program Files\Microsoft SQL Server\130\Tools\Binn;C:\Program Files\mongosh;C:\Program Files\LLVM\bin;C:\Program Files (x86)\LLVM\bin;C:\Users\runneradmin\.dotnet\tools;C:\Users\runneradmin\.cargo\bin;C:\Users\runneradmin\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft Visual Studio\2022\Enterprise\VC\Tools\MSVC\14.43.34808\bin\HostX64\x64" "D:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\llvm\\build\\bin\\FileCheck.exe" "--input-file" "D:\\a\\rust\\rust\\build\\x86_64-pc-windows-msvc\\test\\assembly\\indexing-with-bools-no-redundant-instructions\\indexing-with-bools-no-redundant-instructions.s" "D:\\a\\rust\\rust\\tests\\assembly\\indexing-with-bools-no-redundant-instructions.rs" "--check-prefix=CHECK" "--allow-unused-prefixes" "--dump-input-context" "100"
stdout: none
--- stderr -------------------------------
D:\a\rust\rust\tests\assembly\indexing-with-bools-no-redundant-instructions.rs:14:12: error: CHECK: expected string not found in input
 // CHECK: testl %esi, %esi
           ^
D:\a\rust\rust\build\x86_64-pc-windows-msvc\test\assembly\indexing-with-bools-no-redundant-instructions\indexing-with-bools-no-redundant-instructions.s:15:3: note: scanning from here
f:
  ^
D:\a\rust\rust\build\x86_64-pc-windows-msvc\test\assembly\indexing-with-bools-no-redundant-instructions\indexing-with-bools-no-redundant-instructions.s:16:2: note: possible intended match here
 testb %dl, %dl
 ^

Input file: D:\a\rust\rust\build\x86_64-pc-windows-msvc\test\assembly\indexing-with-bools-no-redundant-instructions\indexing-with-bools-no-redundant-instructions.s
Check file: D:\a\rust\rust\tests\assembly\indexing-with-bools-no-redundant-instructions.rs

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            1:  .def @feat.00; 
            2:  .scl 3; 
            3:  .type 0; 
            4:  .endef 
            5:  .globl @feat.00 
            6: .set @feat.00, 0 
            7:  .file "indexing_with_bools_no_redundant_instructions.43d038d86a482d16-cgu.0" 
            8:  .def f; 
            9:  .scl 2; 
           10:  .type 32; 
           11:  .endef 
           12:  .section .text,"xr",one_only,f 
           13:  .globl f 
           14:  .p2align 4 
           15: f: 
check:14'0       X error: no match found
           16:  testb %dl, %dl 
check:14'0     ~~~~~~~~~~~~~~~~
check:14'1      ?               possible intended match
           17:  je .LBB0_2 
check:14'0     ~~~~~~~~~~~~
           18:  xorb %r8b, %cl 
check:14'0     ~~~~~~~~~~~~~~~~
           19:  orb $1, (%r9) 
check:14'0     ~~~~~~~~~~~~~~~
           20: .LBB0_2: 
check:14'0     ~~~~~~~~~
           21:  movzbl %cl, %eax 
check:14'0     ~~~~~~~~~~~~~~~~~~
           22:  andl $1, %eax 
check:14'0     ~~~~~~~~~~~~~~~
           23:  shll $4, %eax 
check:14'0     ~~~~~~~~~~~~~~~
           24:  orb $1, (%r9,%rax) 
check:14'0     ~~~~~~~~~~~~~~~~~~~~
           25:  retq 
check:14'0     ~~~~~~
           26:  
check:14'0     ~
>>>>>>
------------------------------------------

---
test result: FAILED. 495 passed; 1 failed; 40 ignored; 0 measured; 0 filtered out; finished in 27.52s

Some tests failed in compiletest suite=assembly mode=assembly host=x86_64-pc-windows-msvc target=x86_64-pc-windows-msvc
Build completed unsuccessfully in 1:34:06
make: *** [Makefile:113: ci-msvc-py] Error 1
  local time: Sat Mar 15 16:25:18 CUT 2025
  network time: Sat, 15 Mar 2025 16:25:18 GMT
##[error]Process completed with exit code 2.
Post job cleanup.
[command]"C:\Program Files\Git\bin\git.exe" version

@bors
Copy link
Collaborator

bors commented Mar 15, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Mar 15, 2025
@veera-sivarajan
Copy link
Contributor Author

@rustbot author

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 18, 2025
Comment on lines +25 to +30
let mut a = a & 1 != 0;
if b {
a ^= c;
d[0] |= 1;
}
d[a as usize] |= 1;
Copy link
Member

Choose a reason for hiding this comment

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

This is a bunch of kinda-random unjustified code. What's special about it? What makes it worth us having a test for it? Can we focus it way more somehow?

I ask because this is the kind of test that tends to rot -- people look at it, there's one assembly instruction different, go "eh, probably fine" and just update the CHECKs, quickly leading to it not really testing anything that matters any more.

What changed? Where was it fixed? Can we add a more specific test somehow?

If we don't already have a test for "we can eliminate the bounds check for indexing with bool into a [T; 2]" that sounds like a good test. But this particular combination with xors and such? I'm just not convinced.

Copy link
Member

Choose a reason for hiding this comment

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

Especially since, as you can see by the failure in bors, doing this in assembly coupled it to the calling convention, so it can't pass on both linux and windows with hard-coded register names like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
10 participants