-
Notifications
You must be signed in to change notification settings - Fork 14.3k
RegisterCoalescer: Fix producing malformed IMPLICIT_DEFs #73784
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
arsenm
merged 2 commits into
llvm:main
from
arsenm:coalescer-broken-implicit-def-subreg-to-reg
Dec 4, 2023
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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
120 changes: 120 additions & 0 deletions
120
llvm/test/CodeGen/AArch64/coalescer-drop-subreg-to-reg-imm-ops.mir
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 |
---|---|---|
@@ -0,0 +1,120 @@ | ||
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4 | ||
# RUN: llc -mtriple=arm64-apple-macosx -mcpu=apple-m1 -verify-coalescing -run-pass=register-coalescer -o - %s | FileCheck %s | ||
|
||
# Hits assert "Trying to add an operand to a machine instr that is | ||
# already done!" when rematerializing during greedy. This was because | ||
# an IMPLICIT_DEF ended up with some immediate operands during | ||
# coalescing. A SUBREG_TO_REG was not dropping the immediate operands | ||
# when mutating to IMPLICIT_DEF, and would later fail the assert when | ||
# creating a new IMPLICIT_DEF copy during rematerialization. | ||
|
||
--- | | ||
define void @_ZN38SanitizerCommonInterceptors_Scanf_Test8TestBodyEv() { | ||
ret void | ||
} | ||
|
||
declare void @_ZL9testScanfPKcjz(ptr, i32, ...) | ||
|
||
... | ||
--- | ||
name: _ZN38SanitizerCommonInterceptors_Scanf_Test8TestBodyEv | ||
alignment: 4 | ||
tracksRegLiveness: true | ||
frameInfo: | ||
maxAlignment: 8 | ||
adjustsStack: true | ||
hasCalls: true | ||
maxCallFrameSize: 24 | ||
body: | | ||
bb.0: | ||
liveins: $x0, $x1, $x2, $x3, $x4, $x5, $x6 | ||
|
||
; CHECK-LABEL: name: _ZN38SanitizerCommonInterceptors_Scanf_Test8TestBodyEv | ||
; CHECK: liveins: $x0, $x1, $x2, $x3, $x4, $x5, $x6 | ||
; CHECK-NEXT: {{ $}} | ||
; CHECK-NEXT: [[DEF:%[0-9]+]]:gpr64sp = IMPLICIT_DEF | ||
; CHECK-NEXT: dead [[DEF1:%[0-9]+]]:gpr32 = IMPLICIT_DEF | ||
; CHECK-NEXT: [[DEF2:%[0-9]+]]:gpr64common = IMPLICIT_DEF | ||
; CHECK-NEXT: [[COPY:%[0-9]+]]:gpr64 = COPY $x5 | ||
; CHECK-NEXT: [[COPY1:%[0-9]+]]:gpr64 = COPY $x4 | ||
; CHECK-NEXT: [[COPY2:%[0-9]+]]:gpr64 = COPY $x3 | ||
; CHECK-NEXT: [[COPY3:%[0-9]+]]:gpr64 = COPY $x2 | ||
; CHECK-NEXT: [[COPY4:%[0-9]+]]:gpr64 = COPY $x1 | ||
; CHECK-NEXT: [[COPY5:%[0-9]+]]:gpr64 = COPY $x0 | ||
; CHECK-NEXT: [[DEF3:%[0-9]+]]:gpr64 = IMPLICIT_DEF | ||
; CHECK-NEXT: [[DEF4:%[0-9]+]]:gpr64 = IMPLICIT_DEF | ||
; CHECK-NEXT: [[DEF5:%[0-9]+]]:gpr64 = IMPLICIT_DEF | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 16, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: BL @_ZL9testScanfPKcjz, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
; CHECK-NEXT: ADJCALLSTACKUP 16, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: STRXui [[DEF3]], [[DEF]], 0 :: (store (s64) into stack) | ||
; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: STRWui undef [[DEF1]], [[DEF2]], 0 :: (store (s32)) | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: STRXui [[DEF4]], undef [[DEF]], 0 :: (store (s64) into stack) | ||
; CHECK-NEXT: $x0 = COPY [[COPY5]] | ||
; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: $x0 = COPY [[COPY4]] | ||
; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: $x0 = COPY [[COPY3]] | ||
; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: $x0 = COPY [[COPY2]] | ||
; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: $x0 = COPY [[COPY1]] | ||
; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: $x0 = COPY [[COPY]] | ||
; CHECK-NEXT: ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: ADJCALLSTACKDOWN 24, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: STRXui [[DEF5]], undef [[DEF]], 1 :: (store (s64) into stack + 8) | ||
; CHECK-NEXT: ADJCALLSTACKUP 24, 0, implicit-def dead $sp, implicit $sp | ||
; CHECK-NEXT: RET_ReallyLR | ||
%0:gpr64sp = IMPLICIT_DEF | ||
%1:gpr32 = IMPLICIT_DEF | ||
%2:gpr64common = IMPLICIT_DEF | ||
%3:gpr64 = COPY killed $x5 | ||
%4:gpr64 = COPY killed $x4 | ||
%5:gpr64 = COPY killed $x3 | ||
%6:gpr64 = COPY killed $x2 | ||
%7:gpr64 = COPY killed $x1 | ||
%8:gpr64 = COPY killed $x0 | ||
%9:gpr64 = IMPLICIT_DEF | ||
%10:gpr64 = IMPLICIT_DEF | ||
%11:gpr64 = SUBREG_TO_REG 0, killed undef %1, %subreg.sub_32 | ||
ADJCALLSTACKDOWN 16, 0, implicit-def dead $sp, implicit $sp | ||
BL @_ZL9testScanfPKcjz, csr_darwin_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp | ||
ADJCALLSTACKUP 16, 0, implicit-def dead $sp, implicit $sp | ||
ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
STRXui %9, killed %0, 0 :: (store (s64) into stack) | ||
ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
STRWui undef %1, killed %2, 0 :: (store (s32)) | ||
ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
STRXui killed %10, killed undef %0, 0 :: (store (s64) into stack) | ||
$x0 = COPY killed %8 | ||
ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
$x0 = COPY killed %7 | ||
ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
$x0 = COPY killed %6 | ||
ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
$x0 = COPY killed %5 | ||
ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
$x0 = COPY killed %4 | ||
ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
ADJCALLSTACKDOWN 8, 0, implicit-def dead $sp, implicit $sp | ||
$x0 = COPY killed %3 | ||
ADJCALLSTACKUP 8, 0, implicit-def dead $sp, implicit $sp | ||
ADJCALLSTACKDOWN 24, 0, implicit-def dead $sp, implicit $sp | ||
STRXui killed %11, undef %0, 1 :: (store (s64) into stack + 8) | ||
ADJCALLSTACKUP 24, 0, implicit-def dead $sp, implicit $sp | ||
RET_ReallyLR | ||
|
||
... |
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.
Uh oh!
There was an error while loading. Please reload this page.
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 know this isn't a part of your changes, but the excess of parentheses is bugging me.