blob: 9d0dd9dcb370dc88282c9e51785dedc01a85b7c1 [file]
; 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 nofree 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 nofree 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 nofree 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 nofree 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 nofree 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 nofree 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 nofree 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 nofree 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 nofree captures(address) [[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 nofree 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 nofree 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 nofree captures(address) [[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
}