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
118 lines
5.4 KiB
LLVM
118 lines
5.4 KiB
LLVM
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
|
|
; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=3 -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
|
|
; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
|
|
;
|
|
; Mostly check we do not crash on these uses
|
|
|
|
define internal void @internal(void (i8*)* %fp) {
|
|
;
|
|
;
|
|
; TUNIT-LABEL: define {{[^@]+}}@internal
|
|
; TUNIT-SAME: (void (i8*)* nonnull [[FP:%.*]]) {
|
|
; TUNIT-NEXT: entry:
|
|
; TUNIT-NEXT: [[A:%.*]] = alloca i32, align 4
|
|
; TUNIT-NEXT: call void @foo(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A]]) #[[ATTR1:[0-9]+]]
|
|
; TUNIT-NEXT: call void [[FP]](i8* bitcast (void (i32*)* @foo to i8*))
|
|
; TUNIT-NEXT: call void @callback1(void (i32*)* noundef nonnull @foo)
|
|
; TUNIT-NEXT: call void @callback2(void (i8*)* noundef bitcast (void (i32*)* @foo to void (i8*)*))
|
|
; TUNIT-NEXT: call void @callback2(void (i8*)* nonnull [[FP]])
|
|
; TUNIT-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to i8*
|
|
; TUNIT-NEXT: call void [[FP]](i8* [[TMP1]])
|
|
; TUNIT-NEXT: ret void
|
|
;
|
|
; CGSCC-LABEL: define {{[^@]+}}@internal
|
|
; CGSCC-SAME: (void (i8*)* noundef nonnull [[FP:%.*]]) {
|
|
; CGSCC-NEXT: entry:
|
|
; CGSCC-NEXT: [[A:%.*]] = alloca i32, align 4
|
|
; CGSCC-NEXT: call void @foo(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A]]) #[[ATTR1:[0-9]+]]
|
|
; CGSCC-NEXT: call void [[FP]](i8* bitcast (void (i32*)* @foo to i8*))
|
|
; CGSCC-NEXT: call void @callback1(void (i32*)* noundef nonnull @foo)
|
|
; CGSCC-NEXT: call void @callback2(void (i8*)* noundef bitcast (void (i32*)* @foo to void (i8*)*))
|
|
; CGSCC-NEXT: call void @callback2(void (i8*)* noundef nonnull [[FP]])
|
|
; CGSCC-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to i8*
|
|
; CGSCC-NEXT: call void [[FP]](i8* [[TMP1]])
|
|
; CGSCC-NEXT: ret void
|
|
;
|
|
entry:
|
|
%a = alloca i32, align 4
|
|
%tmp = bitcast i32* %a to i8*
|
|
call void @foo(i32* nonnull %a)
|
|
call void %fp(i8* bitcast (void (i32*)* @foo to i8*))
|
|
call void @callback1(void (i32*)* nonnull @foo)
|
|
call void @callback2(void (i8*)* bitcast (void (i32*)* @foo to void (i8*)*))
|
|
call void @callback2(void (i8*)* %fp)
|
|
%tmp1 = bitcast i32* %a to i8*
|
|
call void %fp(i8* %tmp1)
|
|
ret void
|
|
}
|
|
|
|
define void @external(void (i8*)* %fp) {
|
|
;
|
|
;
|
|
; TUNIT-LABEL: define {{[^@]+}}@external
|
|
; TUNIT-SAME: (void (i8*)* [[FP:%.*]]) {
|
|
; TUNIT-NEXT: entry:
|
|
; TUNIT-NEXT: [[A:%.*]] = alloca i32, align 4
|
|
; TUNIT-NEXT: call void @foo(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A]]) #[[ATTR1]]
|
|
; TUNIT-NEXT: call void @callback1(void (i32*)* noundef nonnull @foo)
|
|
; TUNIT-NEXT: call void @callback2(void (i8*)* noundef bitcast (void (i32*)* @foo to void (i8*)*))
|
|
; TUNIT-NEXT: call void @callback2(void (i8*)* [[FP]])
|
|
; TUNIT-NEXT: call void [[FP]](i8* bitcast (void (i32*)* @foo to i8*))
|
|
; TUNIT-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to i8*
|
|
; TUNIT-NEXT: call void [[FP]](i8* [[TMP1]])
|
|
; TUNIT-NEXT: call void @internal(void (i8*)* nonnull [[FP]])
|
|
; TUNIT-NEXT: ret void
|
|
;
|
|
; CGSCC-LABEL: define {{[^@]+}}@external
|
|
; CGSCC-SAME: (void (i8*)* [[FP:%.*]]) {
|
|
; CGSCC-NEXT: entry:
|
|
; CGSCC-NEXT: [[A:%.*]] = alloca i32, align 4
|
|
; CGSCC-NEXT: call void @foo(i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A]]) #[[ATTR2:[0-9]+]]
|
|
; CGSCC-NEXT: call void @callback1(void (i32*)* noundef nonnull @foo)
|
|
; CGSCC-NEXT: call void @callback2(void (i8*)* noundef bitcast (void (i32*)* @foo to void (i8*)*))
|
|
; CGSCC-NEXT: call void @callback2(void (i8*)* [[FP]])
|
|
; CGSCC-NEXT: call void [[FP]](i8* bitcast (void (i32*)* @foo to i8*))
|
|
; CGSCC-NEXT: [[TMP1:%.*]] = bitcast i32* [[A]] to i8*
|
|
; CGSCC-NEXT: call void [[FP]](i8* [[TMP1]])
|
|
; CGSCC-NEXT: call void @internal(void (i8*)* noundef nonnull [[FP]])
|
|
; CGSCC-NEXT: ret void
|
|
;
|
|
entry:
|
|
%a = alloca i32, align 4
|
|
%tmp = bitcast i32* %a to i8*
|
|
call void @foo(i32* nonnull %a)
|
|
call void @callback1(void (i32*)* nonnull @foo)
|
|
call void @callback2(void (i8*)* bitcast (void (i32*)* @foo to void (i8*)*))
|
|
call void @callback2(void (i8*)* %fp)
|
|
call void %fp(i8* bitcast (void (i32*)* @foo to i8*))
|
|
%tmp1 = bitcast i32* %a to i8*
|
|
call void %fp(i8* %tmp1)
|
|
call void @internal(void (i8*)* %fp)
|
|
ret void
|
|
}
|
|
|
|
define internal void @foo(i32* %a) {
|
|
;
|
|
; CHECK: Function Attrs: nofree norecurse nosync nounwind willreturn memory(argmem: write)
|
|
; CHECK-LABEL: define {{[^@]+}}@foo
|
|
; CHECK-SAME: (i32* nocapture nofree noundef nonnull writeonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR0:[0-9]+]] {
|
|
; CHECK-NEXT: entry:
|
|
; CHECK-NEXT: store i32 0, i32* [[A]], align 4
|
|
; CHECK-NEXT: ret void
|
|
;
|
|
entry:
|
|
store i32 0, i32* %a
|
|
ret void
|
|
}
|
|
|
|
declare void @callback1(void (i32*)*)
|
|
declare void @callback2(void (i8*)*)
|
|
;.
|
|
; TUNIT: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind willreturn memory(argmem: write) }
|
|
; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind willreturn }
|
|
;.
|
|
; CGSCC: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind willreturn memory(argmem: write) }
|
|
; CGSCC: attributes #[[ATTR1]] = { nounwind willreturn memory(write) }
|
|
; CGSCC: attributes #[[ATTR2]] = { nounwind willreturn }
|
|
;.
|