Files
TheRock/compiler/amd-llvm/llvm/test/Transforms/FunctionAttrs/atomic.ll
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

155 lines
5.7 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --version 6
; RUN: opt -passes=function-attrs -S < %s | FileCheck %s
; While it would be fine in this specific case (the alloca does not escape),
; we generally can't ignore synchronizing operations on allocas and should not
; infer readnone here. Non-escaping cases will typically be optimized by SROA.
define i32 @test1(i32 %x) uwtable ssp {
; CHECK: Function Attrs: mustprogress norecurse nounwind ssp willreturn uwtable
; CHECK-LABEL: define i32 @test1(
; CHECK-SAME: i32 [[X:%.*]]) #[[ATTR0:[0-9]+]] {
; CHECK-NEXT: [[ENTRY:.*:]]
; CHECK-NEXT: [[X_ADDR:%.*]] = alloca i32, align 4
; CHECK-NEXT: store atomic i32 [[X]], ptr [[X_ADDR]] seq_cst, align 4
; CHECK-NEXT: [[R:%.*]] = load atomic i32, ptr [[X_ADDR]] seq_cst, align 4
; CHECK-NEXT: ret i32 [[R]]
;
entry:
%x.addr = alloca i32, align 4
store atomic i32 %x, ptr %x.addr seq_cst, align 4
%r = load atomic i32, ptr %x.addr seq_cst, align 4
ret i32 %r
}
define i32 @load_monotonic(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn memory(argmem: readwrite)
; CHECK-LABEL: define i32 @load_monotonic(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR1:[0-9]+]] {
; CHECK-NEXT: [[R:%.*]] = load atomic i32, ptr [[X]] monotonic, align 4
; CHECK-NEXT: ret i32 [[R]]
;
%r = load atomic i32, ptr %x monotonic, align 4
ret i32 %r
}
define i32 @load_acquire(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn
; CHECK-LABEL: define i32 @load_acquire(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR2:[0-9]+]] {
; CHECK-NEXT: [[R:%.*]] = load atomic i32, ptr [[X]] acquire, align 4
; CHECK-NEXT: ret i32 [[R]]
;
%r = load atomic i32, ptr %x acquire, align 4
ret i32 %r
}
define i32 @load_seq_cst(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn
; CHECK-LABEL: define i32 @load_seq_cst(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: [[R:%.*]] = load atomic i32, ptr [[X]] seq_cst, align 4
; CHECK-NEXT: ret i32 [[R]]
;
%r = load atomic i32, ptr %x seq_cst, align 4
ret i32 %r
}
define void @store_monotonic(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn memory(argmem: readwrite)
; CHECK-LABEL: define void @store_monotonic(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR1]] {
; CHECK-NEXT: store atomic i32 0, ptr [[X]] monotonic, align 4
; CHECK-NEXT: ret void
;
store atomic i32 0, ptr %x monotonic, align 4
ret void
}
define void @store_release(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn
; CHECK-LABEL: define void @store_release(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: store atomic i32 0, ptr [[X]] release, align 4
; CHECK-NEXT: ret void
;
store atomic i32 0, ptr %x release, align 4
ret void
}
define void @store_seq_cst(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn
; CHECK-LABEL: define void @store_seq_cst(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: store atomic i32 0, ptr [[X]] seq_cst, align 4
; CHECK-NEXT: ret void
;
store atomic i32 0, ptr %x seq_cst, align 4
ret void
}
define void @atomicrmw_monotonic_arg(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn memory(argmem: readwrite)
; CHECK-LABEL: define void @atomicrmw_monotonic_arg(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR1]] {
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[X]], i32 1 monotonic, align 4
; CHECK-NEXT: ret void
;
atomicrmw add ptr %x, i32 1 monotonic, align 4
ret void
}
define void @atomicrmw_acq_rel_arg(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn
; CHECK-LABEL: define void @atomicrmw_acq_rel_arg(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw add ptr [[X]], i32 1 acq_rel, align 4
; CHECK-NEXT: ret void
;
atomicrmw add ptr %x, i32 1 acq_rel, align 4
ret void
}
define void @atomicrmw_monotonic_volatile_arg(ptr %x) {
; CHECK: Function Attrs: norecurse nounwind memory(argmem: readwrite, inaccessiblemem: readwrite)
; CHECK-LABEL: define void @atomicrmw_monotonic_volatile_arg(
; CHECK-SAME: ptr [[X:%.*]]) #[[ATTR3:[0-9]+]] {
; CHECK-NEXT: [[TMP1:%.*]] = atomicrmw volatile add ptr [[X]], i32 1 monotonic, align 4
; CHECK-NEXT: ret void
;
atomicrmw volatile add ptr %x, i32 1 monotonic, align 4
ret void
}
define void @cmpxchg_monotonic_arg(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn memory(argmem: readwrite)
; CHECK-LABEL: define void @cmpxchg_monotonic_arg(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR1]] {
; CHECK-NEXT: [[TMP1:%.*]] = cmpxchg ptr [[X]], i32 0, i32 1 monotonic monotonic, align 4
; CHECK-NEXT: ret void
;
cmpxchg ptr %x, i32 0, i32 1 monotonic monotonic
ret void
}
define void @cmpxchg_acq_rel_arg(ptr %x) {
; CHECK: Function Attrs: mustprogress norecurse nounwind willreturn
; CHECK-LABEL: define void @cmpxchg_acq_rel_arg(
; CHECK-SAME: ptr captures(none) [[X:%.*]]) #[[ATTR2]] {
; CHECK-NEXT: [[TMP1:%.*]] = cmpxchg ptr [[X]], i32 0, i32 1 acq_rel monotonic, align 4
; CHECK-NEXT: ret void
;
cmpxchg ptr %x, i32 0, i32 1 acq_rel monotonic
ret void
}
define void @cmpxchg_monotonic_volatile_arg(ptr %x) {
; CHECK: Function Attrs: norecurse nounwind memory(argmem: readwrite, inaccessiblemem: readwrite)
; CHECK-LABEL: define void @cmpxchg_monotonic_volatile_arg(
; CHECK-SAME: ptr [[X:%.*]]) #[[ATTR3]] {
; CHECK-NEXT: [[TMP1:%.*]] = cmpxchg volatile ptr [[X]], i32 0, i32 1 monotonic monotonic, align 4
; CHECK-NEXT: ret void
;
cmpxchg volatile ptr %x, i32 0, i32 1 monotonic monotonic
ret void
}