-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[IR] Check identical alignment for atomic instructions #155349
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 all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
e687f1f
Check identical alignment for atomic instrs
ellishg 77440a9
use ptr
ellishg d34d65c
Merge branch 'main' into fix-align-atomics
ellishg e44fabf
add iroutliner test
ellishg e17d7ec
Remove new unittests
ellishg f6dcf10
Merge branch 'main' into fix-align-atomics
ellishg 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
163 changes: 163 additions & 0 deletions
163
llvm/test/Transforms/IROutliner/outlining-special-state.ll
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,163 @@ | ||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --include-generated-funcs | ||
; RUN: opt -S -passes=verify,iroutliner -ir-outlining-no-cost < %s | FileCheck %s | ||
|
||
declare void @foo(); | ||
|
||
define void @atomicrmw_base(ptr %p) { | ||
entry: | ||
%1 = atomicrmw add ptr %p, i32 1 acquire, align 8 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @atomicrmw_copy(ptr %p) { | ||
entry: | ||
%1 = atomicrmw add ptr %p, i32 1 acquire, align 8 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @atomicrmw_wrong_type(ptr %p) { | ||
entry: | ||
%1 = atomicrmw add ptr %p, i64 1 acquire, align 8 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @atomicrmw_wrong_align(ptr %p) { | ||
entry: | ||
%1 = atomicrmw add ptr %p, i32 1 acquire, align 4 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @atomicrmw_wrong_volatile(ptr %p) { | ||
entry: | ||
%1 = atomicrmw volatile add ptr %p, i32 1 acquire, align 8 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @cmpxchg_base(ptr %p) { | ||
entry: | ||
%1 = cmpxchg ptr %p, i32 0, i32 1 monotonic monotonic, align 8 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @cmpxchg_copy(ptr %p) { | ||
entry: | ||
%1 = cmpxchg ptr %p, i32 0, i32 1 monotonic monotonic, align 8 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @cmpxchg_wrong_type(ptr %p) { | ||
entry: | ||
%1 = cmpxchg ptr %p, i64 0, i64 1 monotonic monotonic, align 8 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @cmpxchg_wrong_align(ptr %p) { | ||
entry: | ||
%1 = cmpxchg ptr %p, i32 0, i32 1 monotonic monotonic, align 4 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
define void @cmpxchg_wrong_volatile(ptr %p) { | ||
entry: | ||
%1 = cmpxchg volatile ptr %p, i32 0, i32 1 monotonic monotonic, align 8 | ||
call void @foo() | ||
ret void | ||
} | ||
|
||
|
||
; CHECK-LABEL: @atomicrmw_base( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: call void @outlined_ir_func_1(ptr [[P:%.*]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @atomicrmw_copy( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: call void @outlined_ir_func_1(ptr [[P:%.*]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @atomicrmw_wrong_type( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TMP0:%.*]] = atomicrmw add ptr [[P:%.*]], i64 1 acquire, align 8 | ||
; CHECK-NEXT: call void @foo() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @atomicrmw_wrong_align( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TMP0:%.*]] = atomicrmw add ptr [[P:%.*]], i32 1 acquire, align 4 | ||
; CHECK-NEXT: call void @foo() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @atomicrmw_wrong_volatile( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TMP0:%.*]] = atomicrmw volatile add ptr [[P:%.*]], i32 1 acquire, align 8 | ||
; CHECK-NEXT: call void @foo() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @cmpxchg_base( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[P:%.*]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @cmpxchg_copy( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: call void @outlined_ir_func_0(ptr [[P:%.*]]) | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @cmpxchg_wrong_type( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TMP0:%.*]] = cmpxchg ptr [[P:%.*]], i64 0, i64 1 monotonic monotonic, align 8 | ||
; CHECK-NEXT: call void @foo() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @cmpxchg_wrong_align( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TMP0:%.*]] = cmpxchg ptr [[P:%.*]], i32 0, i32 1 monotonic monotonic, align 4 | ||
; CHECK-NEXT: call void @foo() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @cmpxchg_wrong_volatile( | ||
; CHECK-NEXT: entry: | ||
; CHECK-NEXT: [[TMP0:%.*]] = cmpxchg volatile ptr [[P:%.*]], i32 0, i32 1 monotonic monotonic, align 8 | ||
; CHECK-NEXT: call void @foo() | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @outlined_ir_func_0( | ||
; CHECK-NEXT: newFuncRoot: | ||
; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]] | ||
; CHECK: entry_to_outline: | ||
; CHECK-NEXT: [[TMP1:%.*]] = cmpxchg ptr [[TMP0:%.*]], i32 0, i32 1 monotonic monotonic, align 8 | ||
; CHECK-NEXT: call void @foo() | ||
; CHECK-NEXT: br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]] | ||
; CHECK: entry_after_outline.exitStub: | ||
; CHECK-NEXT: ret void | ||
; | ||
; | ||
; CHECK-LABEL: @outlined_ir_func_1( | ||
; CHECK-NEXT: newFuncRoot: | ||
; CHECK-NEXT: br label [[ENTRY_TO_OUTLINE:%.*]] | ||
; CHECK: entry_to_outline: | ||
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[TMP0:%.*]], i32 1 acquire, align 8 | ||
; CHECK-NEXT: call void @foo() | ||
; CHECK-NEXT: br label [[ENTRY_AFTER_OUTLINE_EXITSTUB:%.*]] | ||
; CHECK: entry_after_outline.exitStub: | ||
; CHECK-NEXT: ret void | ||
; |
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
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.
Can we test this via SimplifyCFG lit tests for sink or hoist instead? IR based unit tests are a pain.
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 created a test in
Transforms/IROutliner
. Should I remove these new unittests?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.
Yeah, no point in having both.
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 ended up removing the tests I added. I didn't want to translate the existing tests to LIT because I thought that was the beyond the scope of this PR, but I did add a TODO comment. I'll land this Monday if there are no other concerns.