# Copyright (c) 2021-2024 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.record A {
i32 fint
A fref
}
.function void ext_func(A a0) <external>
#! CHECKER Check optimized reference in statepoint
#! RUN_LLVM options: "--compiler-regex=_GLOBAL::foo_ref --llvm-dump-after"
#! READ_FILE "console.out"
#! LLVM_METHOD /define.*\"void _GLOBAL::foo_ref.*\d+\"/
#! INST /"gc-live"\(ptr addrspace\(271\) %a0[^,]*, ptr addrspace\(271\) %v4[^,]*\)/
#! INST_NEXT /"gc-live"\(ptr addrspace\(271\) %a0[^,]*, ptr addrspace\(271\) %v4[^,]*\)/
#! INST_NEXT_NOT "gc-live"
.function void foo_ref(A a0) {
ldobj.obj a0, A.fref
sta.obj v0
call.short ext_func, a0
lda.obj v0
stobj.obj a0, A.fref
return.void
}
#! CHECKER Check no reference in statepoint
#! RUN_LLVM options: "--compiler-regex=_GLOBAL::foo_int --llvm-dump-after"
#! READ_FILE "console.out"
#! LLVM_METHOD /define.*\"void _GLOBAL::foo_int.*\d+\"/
#! INST /"gc-live"\(ptr addrspace\(271\) %a0[^,]*\)/
#! INST_NEXT /"gc-live"\(ptr addrspace\(271\) %a0[^,]*\)/
#! INST_NEXT_NOT "gc-live"
.function void foo_int(A a0) {
ldobj a0, A.fint
sta v0
call.short ext_func, a0
lda v0
stobj a0, A.fint
return.void
}