xref: /aosp_15_r20/external/llvm/test/Transforms/FunctionAttrs/atomic.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -basicaa -functionattrs -S < %s | FileCheck %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; Atomic load/store to local doesn't affect whether a function is
4*9880d681SAndroid Build Coastguard Worker; readnone/readonly.
5*9880d681SAndroid Build Coastguard Workerdefine i32 @test1(i32 %x) uwtable ssp {
6*9880d681SAndroid Build Coastguard Worker; CHECK: define i32 @test1(i32 %x) #0 {
7*9880d681SAndroid Build Coastguard Workerentry:
8*9880d681SAndroid Build Coastguard Worker  %x.addr = alloca i32, align 4
9*9880d681SAndroid Build Coastguard Worker  store atomic i32 %x, i32* %x.addr seq_cst, align 4
10*9880d681SAndroid Build Coastguard Worker  %r = load atomic i32, i32* %x.addr seq_cst, align 4
11*9880d681SAndroid Build Coastguard Worker  ret i32 %r
12*9880d681SAndroid Build Coastguard Worker}
13*9880d681SAndroid Build Coastguard Worker
14*9880d681SAndroid Build Coastguard Worker; A function with an Acquire load is not readonly.
15*9880d681SAndroid Build Coastguard Workerdefine i32 @test2(i32* %x) uwtable ssp {
16*9880d681SAndroid Build Coastguard Worker; CHECK: define i32 @test2(i32* nocapture readonly %x) #1 {
17*9880d681SAndroid Build Coastguard Workerentry:
18*9880d681SAndroid Build Coastguard Worker  %r = load atomic i32, i32* %x seq_cst, align 4
19*9880d681SAndroid Build Coastguard Worker  ret i32 %r
20*9880d681SAndroid Build Coastguard Worker}
21*9880d681SAndroid Build Coastguard Worker
22*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #0 = { norecurse readnone ssp uwtable }
23*9880d681SAndroid Build Coastguard Worker; CHECK: attributes #1 = { norecurse ssp uwtable }
24