
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
35 lines
878 B
LLVM
35 lines
878 B
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes
|
|
; RUN: opt < %s -passes=function-attrs -S | FileCheck %s
|
|
|
|
@x = global i32 0
|
|
|
|
declare i32 @e() readnone
|
|
|
|
define i32 @f() {
|
|
; CHECK: Function Attrs: nofree nosync memory(none)
|
|
; CHECK-LABEL: @f(
|
|
; CHECK-NEXT: [[TMP:%.*]] = call i32 @e()
|
|
; CHECK-NEXT: ret i32 [[TMP]]
|
|
;
|
|
%tmp = call i32 @e()
|
|
ret i32 %tmp
|
|
}
|
|
|
|
define i32 @g() readonly {
|
|
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
|
|
; CHECK-LABEL: @g(
|
|
; CHECK-NEXT: ret i32 0
|
|
;
|
|
ret i32 0
|
|
}
|
|
|
|
define i32 @h() readnone {
|
|
; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none)
|
|
; CHECK-LABEL: @h(
|
|
; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr @x, align 4
|
|
; CHECK-NEXT: ret i32 [[TMP]]
|
|
;
|
|
%tmp = load i32, ptr @x
|
|
ret i32 %tmp
|
|
}
|