xref: /llvm-project/llvm/test/Transforms/FunctionAttrs/atomic.ll (revision 304f1d59ca41872c094def3aee0a8689df6aa398)
1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
2; RUN: opt -passes=function-attrs -S < %s | FileCheck %s
3
4; Atomic load/store to local doesn't affect whether a function is
5; readnone/readonly.
6define i32 @test1(i32 %x) uwtable ssp {
7; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind ssp willreturn memory(none) uwtable
8; CHECK-LABEL: @test1(
9; CHECK-NEXT:  entry:
10; CHECK-NEXT:    [[X_ADDR:%.*]] = alloca i32, align 4
11; CHECK-NEXT:    store atomic i32 [[X:%.*]], ptr [[X_ADDR]] seq_cst, align 4
12; CHECK-NEXT:    [[R:%.*]] = load atomic i32, ptr [[X_ADDR]] seq_cst, align 4
13; CHECK-NEXT:    ret i32 [[R]]
14;
15entry:
16  %x.addr = alloca i32, align 4
17  store atomic i32 %x, ptr %x.addr seq_cst, align 4
18  %r = load atomic i32, ptr %x.addr seq_cst, align 4
19  ret i32 %r
20}
21
22; A function with an Acquire load is not readonly.
23define i32 @test2(ptr %x) uwtable ssp {
24; CHECK: Function Attrs: mustprogress nofree norecurse nounwind ssp willreturn memory(argmem: readwrite) uwtable
25; CHECK-LABEL: @test2(
26; CHECK-NEXT:  entry:
27; CHECK-NEXT:    [[R:%.*]] = load atomic i32, ptr [[X:%.*]] seq_cst, align 4
28; CHECK-NEXT:    ret i32 [[R]]
29;
30entry:
31  %r = load atomic i32, ptr %x seq_cst, align 4
32  ret i32 %r
33}
34