This switches everything to use the memory attribute proposed in https://discourse.llvm.org/t/rfc-unify-memory-effect-attributes/65579. The old argmemonly, inaccessiblememonly and inaccessiblemem_or_argmemonly attributes are dropped. The readnone, readonly and writeonly attributes are restricted to parameters only. The old attributes are auto-upgraded both in bitcode and IR. The bitcode upgrade is a policy requirement that has to be retained indefinitely. The IR upgrade is mainly there so it's not necessary to update all tests using memory attributes in this patch, which is already large enough. We could drop that part after migrating tests, or retain it longer term, to make it easier to import IR from older LLVM versions. High-level Function/CallBase APIs like doesNotAccessMemory() or setDoesNotAccessMemory() are mapped transparently to the memory attribute. Code that directly manipulates attributes (e.g. via AttributeList) on the other hand needs to switch to working with the memory attribute instead. Differential Revision: https://reviews.llvm.org/D135780
33 lines
912 B
LLVM
33 lines
912 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
|
|
; RUN: opt -S < %s -passes=function-attrs | FileCheck %s
|
|
|
|
declare void @llvm.sideeffect()
|
|
|
|
; Don't add readnone or similar attributes when an @llvm.sideeffect() intrinsic
|
|
; is present.
|
|
|
|
define void @test() {
|
|
; CHECK: Function Attrs: mustprogress nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite)
|
|
; CHECK-LABEL: @test(
|
|
; CHECK-NEXT: call void @llvm.sideeffect()
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
call void @llvm.sideeffect()
|
|
ret void
|
|
}
|
|
|
|
define void @loop() {
|
|
; CHECK: Function Attrs: nofree noreturn nosync nounwind memory(inaccessiblemem: readwrite)
|
|
; CHECK-LABEL: @loop(
|
|
; CHECK-NEXT: br label [[LOOP:%.*]]
|
|
; CHECK: loop:
|
|
; CHECK-NEXT: call void @llvm.sideeffect()
|
|
; CHECK-NEXT: br label [[LOOP]]
|
|
;
|
|
br label %loop
|
|
|
|
loop:
|
|
call void @llvm.sideeffect()
|
|
br label %loop
|
|
}
|