-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[CodeGen] Correctly handle non-standard cases in RemoveLoadsIntoFakeUses #111551
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
3ce74d6
[CodeGen] Correctly handle non-standard cases in RemoveLoadsIntoFakeUses
SLTozer fd2c94e
Remove assertions, handle 0-op FAKE_USES, use RegUnits
SLTozer 0a8b5a6
Use a SmallVector of fake uses instead of a SmallDenseMap
SLTozer c9d1b6e
Use 'readsRegister'
SLTozer 52b95c7
Update test to check full output
SLTozer 6aadd23
Turn off pass when using varloc-based LDV
SLTozer a5fd7ee
Remove unnecessary isReg check
SLTozer 0d4a75b
Fix check for instr-ref enabled, update test to check disabled case
SLTozer 026fc06
Use instr-ref bit instead of high-level function
SLTozer 92c0631
Update test to be more update_test_checks-friendly
SLTozer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,8 @@ | ||
| # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5 | ||
| # Ensure that loads into FAKE_USEs are correctly removed by the | ||
| # remove-loads-into-fake-uses pass. | ||
|
||
| # RUN: llc -run-pass remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses 2>&1 -o - %s | FileCheck %s | ||
| # RUN: llc -run-pass remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses 2>&1 -o - %s | FileCheck %s --check-prefix=ENABLED | ||
| # RUN: llc -run-pass remove-loads-into-fake-uses -mtriple=x86_64-unknown-linux -debug-only=remove-loads-into-fake-uses -experimental-debug-variable-locations=false 2>&1 -o - %s | FileCheck %s --check-prefixes=DISABLED | ||
| # REQUIRES: asserts | ||
| # | ||
| ## We verify that: | ||
|
|
@@ -39,35 +40,66 @@ body: | | |
| bb.0: | ||
| liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx | ||
|
|
||
| ; CHECK-LABEL: name: _ZN1g1jEv | ||
| ; CHECK: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx | ||
| ; CHECK-NEXT: {{ $}} | ||
| ; CHECK-NEXT: $rbx = MOV64rr $rdx | ||
| ; CHECK-NEXT: $r14d = MOV32rr $esi | ||
| ; CHECK-NEXT: $r15 = MOV64rr $rdi | ||
| ; CHECK-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12 | ||
| ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax | ||
|
|
||
|
|
||
|
|
||
|
|
||
| ; ENABLED-LABEL: name: _ZN1g1jEv | ||
| ; ENABLED: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx | ||
| ; ENABLED-NEXT: {{ $}} | ||
| ; ENABLED-NEXT: $rbx = MOV64rr $rdx | ||
| ; ENABLED-NEXT: $r14d = MOV32rr $esi | ||
| ; ENABLED-NEXT: $r15 = MOV64rr $rdi | ||
| ; ENABLED-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12 | ||
| ; ENABLED-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax | ||
|
|
||
| ;; The store to the stack slot is still present. | ||
| ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0) | ||
| ; CHECK-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1) | ||
| ; CHECK-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags | ||
| ; CHECK-NEXT: $r13d = MOV32rr killed $eax | ||
| ; CHECK-NEXT: $rdi = MOV64rr $r15 | ||
| ; CHECK-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp | ||
| ; CHECK-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg | ||
| ; CHECK-NEXT: renamable $eax = MOV32ri 1 | ||
| ; CHECK-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags | ||
| ; ENABLED-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0) | ||
|
|
||
| ; ENABLED-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1) | ||
| ; ENABLED-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags | ||
| ; ENABLED-NEXT: $r13d = MOV32rr killed $eax | ||
| ; ENABLED-NEXT: $rdi = MOV64rr $r15 | ||
| ; ENABLED-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp | ||
| ; ENABLED-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg | ||
| ; ENABLED-NEXT: renamable $eax = MOV32ri 1 | ||
| ; ENABLED-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags | ||
|
|
||
| ;; First FAKE_USE and its corresponding load are removed; second FAKE_USE of | ||
| ;; a restored value that is also used is preserved. | ||
| ; CHECK-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1) | ||
| ; CHECK-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags | ||
| ; CHECK-NEXT: FAKE_USE killed renamable $r11d | ||
| ; ENABLED-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1) | ||
| ; ENABLED-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags | ||
| ; ENABLED-NEXT: FAKE_USE killed renamable $r11d | ||
|
|
||
| ; ENABLED-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags | ||
| ; ENABLED-NEXT: RET64 | ||
| ; | ||
| ; DISABLED-LABEL: name: _ZN1g1jEv | ||
| ; DISABLED: liveins: $esi, $rdi, $rdx, $r15, $r14, $r13, $r12, $r11, $rbx | ||
| ; DISABLED-NEXT: {{ $}} | ||
| ; DISABLED-NEXT: $rbx = MOV64rr $rdx | ||
| ; DISABLED-NEXT: $r14d = MOV32rr $esi | ||
| ; DISABLED-NEXT: $r15 = MOV64rr $rdi | ||
| ; DISABLED-NEXT: renamable $r12d = XOR32rr undef $r12d, undef $r12d, implicit-def dead $eflags, implicit-def $r12 | ||
| ; DISABLED-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $rax | ||
| ; DISABLED-NEXT: MOV64mr $rbp, 1, $noreg, -48, $noreg, killed renamable $rax :: (store (s64) into %stack.0) | ||
| ; DISABLED-NEXT: MOV64mr $rbp, 1, $noreg, -40, $noreg, killed renamable $r11 :: (store (s64) into %stack.1) | ||
| ; DISABLED-NEXT: renamable $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags | ||
| ; DISABLED-NEXT: $r13d = MOV32rr killed $eax | ||
| ; DISABLED-NEXT: $rdi = MOV64rr $r15 | ||
| ; DISABLED-NEXT: CALL64r renamable $r12, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp | ||
| ; DISABLED-NEXT: dead renamable $eax = MOV32rm renamable $rbx, 1, $noreg, 0, $noreg | ||
| ; DISABLED-NEXT: renamable $eax = MOV32ri 1 | ||
| ; DISABLED-NEXT: TEST8ri renamable $r14b, 1, implicit-def $eflags | ||
|
|
||
| ; CHECK-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags | ||
| ; CHECK-NEXT: RET64 | ||
| ;; Verify that when instr-ref is disabled, we do not remove fake uses. | ||
| ; DISABLED-NEXT: renamable $rax = MOV64rm $rbp, 1, $noreg, -48, $noreg :: (load (s64) from %stack.0) | ||
| ; DISABLED-NEXT: FAKE_USE renamable $eax, implicit killed $rax | ||
| ; DISABLED-NEXT: renamable $r11 = MOV64rm $rbp, 1, $noreg, -40, $noreg :: (load (s64) from %stack.1) | ||
| ; DISABLED-NEXT: renamable $r12d = XOR32rr $r12d, $r11d, implicit-def dead $eflags | ||
| ; DISABLED-NEXT: FAKE_USE killed renamable $r11d | ||
| ; DISABLED-NEXT: TEST32rr killed renamable $r13d, renamable $r13d, implicit-def $eflags | ||
| ; DISABLED-NEXT: RET64 | ||
| $rbx = MOV64rr $rdx | ||
| $r14d = MOV32rr $esi | ||
| $r15 = MOV64rr $rdi | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should call
useDebugInstrRef, which queries the bit of state that MachineFunction carries around with it. IIRC, the "should" method is testing which mode should be used given the optimisation configuration, while the bit records the actual truth of whether instr-ref is being used or not. This allows for (semi-legitimate) situations where some MIR that uses instr-ref is loaded into a configuration where we would have chosen to not use instr-ref.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And uh, that awkwardly has an effect on the test you're writing too.