-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Attributor: Add baseline tests for propagating align to atomics #134836
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 1 commit into
main
from
users/arsenm/attributor/add-baseline-tests-atomic-align-propagate
Apr 8, 2025
Merged
Attributor: Add baseline tests for propagating align to atomics #134836
arsenm
merged 1 commit into
main
from
users/arsenm/attributor/add-baseline-tests-atomic-align-propagate
Apr 8, 2025
Conversation
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 stack of pull requests is managed by Graphite. Learn more about stacking. |
This was referenced Apr 8, 2025
@llvm/pr-subscribers-llvm-transforms Author: Matt Arsenault (arsenm) ChangesFull diff: https://github.com/llvm/llvm-project/pull/134836.diff 1 Files Affected:
diff --git a/llvm/test/Transforms/Attributor/align-atomic.ll b/llvm/test/Transforms/Attributor/align-atomic.ll
new file mode 100644
index 0000000000000..764ed7419a079
--- /dev/null
+++ b/llvm/test/Transforms/Attributor/align-atomic.ll
@@ -0,0 +1,64 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
+; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
+; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
+
+define i32 @atomicrmw_add_no_op(ptr align 4 %ptr, i32 %val) {
+; CHECK-LABEL: define i32 @atomicrmw_add_no_op(
+; CHECK-SAME: ptr nofree noundef nonnull align 4 captures(none) dereferenceable(4) [[PTR:%.*]], i32 [[VAL:%.*]]) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT: [[RESULT:%.*]] = atomicrmw add ptr [[PTR]], i32 [[VAL]] seq_cst, align 4
+; CHECK-NEXT: ret i32 [[RESULT]]
+;
+ %result = atomicrmw add ptr %ptr, i32 %val seq_cst, align 4
+ ret i32 %result
+}
+
+; Check that the aligment increases to 8
+define i32 @atomicrmw_add_propagate(ptr align 8 %ptr, i32 %val) {
+; CHECK-LABEL: define i32 @atomicrmw_add_propagate(
+; CHECK-SAME: ptr nofree noundef nonnull align 8 captures(none) dereferenceable(4) [[PTR:%.*]], i32 [[VAL:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: [[RESULT:%.*]] = atomicrmw add ptr [[PTR]], i32 [[VAL]] seq_cst, align 2
+; CHECK-NEXT: ret i32 [[RESULT]]
+;
+ %result = atomicrmw add ptr %ptr, i32 %val seq_cst, align 2
+ ret i32 %result
+}
+
+; Should increase alignment to 8, not 16.
+define ptr @atomicrmw_non_ptr_op_no_propagate(ptr %ptr, ptr align 16 %val) {
+; CHECK-LABEL: define ptr @atomicrmw_non_ptr_op_no_propagate(
+; CHECK-SAME: ptr nofree noundef nonnull align 2 captures(none) dereferenceable(8) [[PTR:%.*]], ptr nofree align 16 [[VAL:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: [[RESULT:%.*]] = atomicrmw xchg ptr [[PTR]], ptr [[VAL]] seq_cst, align 2
+; CHECK-NEXT: ret ptr [[RESULT]]
+;
+ %result = atomicrmw xchg ptr %ptr, ptr %val seq_cst, align 2
+ ret ptr %result
+}
+
+define i32 @cmpxchg_propagate(ptr align 8 %ptr, i32 %cmp, i32 %val) {
+; CHECK-LABEL: define i32 @cmpxchg_propagate(
+; CHECK-SAME: ptr nofree noundef nonnull align 8 captures(none) dereferenceable(4) [[PTR:%.*]], i32 [[CMP:%.*]], i32 [[VAL:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: [[PAIR:%.*]] = cmpxchg ptr [[PTR]], i32 [[CMP]], i32 [[VAL]] seq_cst monotonic, align 2
+; CHECK-NEXT: [[RESULT:%.*]] = extractvalue { i32, i1 } [[PAIR]], 0
+; CHECK-NEXT: ret i32 [[RESULT]]
+;
+ %pair = cmpxchg ptr %ptr, i32 %cmp, i32 %val seq_cst monotonic, align 2
+ %result = extractvalue { i32, i1 } %pair, 0
+ ret i32 %result
+}
+
+; Should not increase alignment
+define ptr @cmpxchg_no_propagate(ptr %ptr, ptr align 16 %cmp, ptr align 32 %val) {
+; CHECK-LABEL: define ptr @cmpxchg_no_propagate(
+; CHECK-SAME: ptr nofree noundef nonnull align 2 captures(none) dereferenceable(8) [[PTR:%.*]], ptr nofree align 16 [[CMP:%.*]], ptr nofree align 32 [[VAL:%.*]]) #[[ATTR0]] {
+; CHECK-NEXT: [[PAIR:%.*]] = cmpxchg ptr [[PTR]], ptr [[CMP]], ptr [[VAL]] seq_cst monotonic, align 2
+; CHECK-NEXT: [[RESULT:%.*]] = extractvalue { ptr, i1 } [[PAIR]], 0
+; CHECK-NEXT: ret ptr [[RESULT]]
+;
+ %pair = cmpxchg ptr %ptr, ptr %cmp, ptr %val seq_cst monotonic, align 2
+ %result = extractvalue { ptr, i1 } %pair, 0
+ ret ptr %result
+}
+
+;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
+; CGSCC: {{.*}}
+; TUNIT: {{.*}}
|
shiltian
approved these changes
Apr 8, 2025
Merge activity
|
4e2ff83
to
5fa7aac
Compare
5fa7aac
to
639fefd
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No description provided.