220 lines
13 KiB
LLVM
220 lines
13 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=7 -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
|
|
|
|
define dso_local i32 @visible(i32* noalias %A, i32* noalias %B) #0 {
|
|
; TUNIT: Function Attrs: nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
|
|
; TUNIT-LABEL: define {{[^@]+}}@visible
|
|
; TUNIT-SAME: (i32* noalias nocapture nofree readonly [[A:%.*]], i32* noalias nocapture nofree readonly align 4 [[B:%.*]]) #[[ATTR0:[0-9]+]] {
|
|
; TUNIT-NEXT: entry:
|
|
; TUNIT-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(i32* noalias nocapture nofree readonly align 4 [[A]], i32* noalias nocapture nofree readonly align 4 [[B]]) #[[ATTR3:[0-9]+]]
|
|
; TUNIT-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(i32* noalias nocapture nofree readonly align 4 [[A]], i32* noalias nocapture nofree readonly align 4 [[B]]) #[[ATTR3]]
|
|
; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]]
|
|
; TUNIT-NEXT: ret i32 [[ADD]]
|
|
;
|
|
; CGSCC: Function Attrs: nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable
|
|
; CGSCC-LABEL: define {{[^@]+}}@visible
|
|
; CGSCC-SAME: (i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0:[0-9]+]] {
|
|
; CGSCC-NEXT: entry:
|
|
; CGSCC-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]])
|
|
; CGSCC-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]])
|
|
; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]]
|
|
; CGSCC-NEXT: ret i32 [[ADD]]
|
|
;
|
|
entry:
|
|
%call1 = call i32 @noalias_args(i32* %A, i32* %B)
|
|
%call2 = call i32 @noalias_args_argmem(i32* %A, i32* %B)
|
|
%add = add nsw i32 %call1, %call2
|
|
ret i32 %add
|
|
}
|
|
|
|
define private i32 @noalias_args(i32* %A, i32* %B) #0 {
|
|
; TUNIT: Function Attrs: nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
|
|
; TUNIT-LABEL: define {{[^@]+}}@noalias_args
|
|
; TUNIT-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0]] {
|
|
; TUNIT-NEXT: entry:
|
|
; TUNIT-NEXT: [[TMP0:%.*]] = load i32, i32* [[A]], align 4
|
|
; TUNIT-NEXT: [[TMP1:%.*]] = load i32, i32* [[B]], align 4
|
|
; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
|
|
; TUNIT-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR3]]
|
|
; TUNIT-NEXT: [[ADD2:%.*]] = add nsw i32 [[ADD]], [[CALL]]
|
|
; TUNIT-NEXT: ret i32 [[ADD2]]
|
|
;
|
|
; CGSCC: Function Attrs: nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable
|
|
; CGSCC-LABEL: define {{[^@]+}}@noalias_args
|
|
; CGSCC-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0]] {
|
|
; CGSCC-NEXT: entry:
|
|
; CGSCC-NEXT: [[TMP0:%.*]] = load i32, i32* [[A]], align 4
|
|
; CGSCC-NEXT: [[TMP1:%.*]] = load i32, i32* [[B]], align 4
|
|
; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
|
|
; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR5:[0-9]+]]
|
|
; CGSCC-NEXT: [[ADD2:%.*]] = add nsw i32 [[ADD]], [[CALL]]
|
|
; CGSCC-NEXT: ret i32 [[ADD2]]
|
|
;
|
|
entry:
|
|
%0 = load i32, i32* %A, align 4
|
|
%1 = load i32, i32* %B, align 4
|
|
%add = add nsw i32 %0, %1
|
|
%call = call i32 @noalias_args_argmem(i32* %A, i32* %B)
|
|
%add2 = add nsw i32 %add, %call
|
|
ret i32 %add2
|
|
}
|
|
|
|
|
|
define internal i32 @noalias_args_argmem(i32* %A, i32* %B) #1 {
|
|
; TUNIT: Function Attrs: nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
|
|
; TUNIT-LABEL: define {{[^@]+}}@noalias_args_argmem
|
|
; TUNIT-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR0]] {
|
|
; TUNIT-NEXT: entry:
|
|
; TUNIT-NEXT: [[TMP0:%.*]] = load i32, i32* [[A]], align 4
|
|
; TUNIT-NEXT: [[TMP1:%.*]] = load i32, i32* [[B]], align 4
|
|
; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
|
|
; TUNIT-NEXT: ret i32 [[ADD]]
|
|
;
|
|
; CGSCC: Function Attrs: nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
|
|
; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem
|
|
; CGSCC-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]], i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR1:[0-9]+]] {
|
|
; CGSCC-NEXT: entry:
|
|
; CGSCC-NEXT: [[TMP0:%.*]] = load i32, i32* [[A]], align 4
|
|
; CGSCC-NEXT: [[TMP1:%.*]] = load i32, i32* [[B]], align 4
|
|
; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP0]], [[TMP1]]
|
|
; CGSCC-NEXT: ret i32 [[ADD]]
|
|
;
|
|
entry:
|
|
%0 = load i32, i32* %A, align 4
|
|
%1 = load i32, i32* %B, align 4
|
|
%add = add nsw i32 %0, %1
|
|
ret i32 %add
|
|
}
|
|
|
|
define dso_local i32 @visible_local(i32* %A) #0 {
|
|
; TUNIT: Function Attrs: nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
|
|
; TUNIT-LABEL: define {{[^@]+}}@visible_local
|
|
; TUNIT-SAME: (i32* nocapture nofree readonly [[A:%.*]]) #[[ATTR1:[0-9]+]] {
|
|
; TUNIT-NEXT: entry:
|
|
; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4
|
|
; TUNIT-NEXT: store i32 5, i32* [[B]], align 4
|
|
; TUNIT-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(i32* nocapture nofree readonly align 4 [[A]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR3]]
|
|
; TUNIT-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(i32* nocapture nofree readonly align 4 [[A]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]]) #[[ATTR3]]
|
|
; TUNIT-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]]
|
|
; TUNIT-NEXT: ret i32 [[ADD]]
|
|
;
|
|
; CGSCC: Function Attrs: nofree noinline nosync nounwind willreturn memory(argmem: readwrite) uwtable
|
|
; CGSCC-LABEL: define {{[^@]+}}@visible_local
|
|
; CGSCC-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A:%.*]]) #[[ATTR2:[0-9]+]] {
|
|
; CGSCC-NEXT: entry:
|
|
; CGSCC-NEXT: [[B:%.*]] = alloca i32, align 4
|
|
; CGSCC-NEXT: store i32 5, i32* [[B]], align 4
|
|
; CGSCC-NEXT: [[CALL1:%.*]] = call i32 @noalias_args(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]])
|
|
; CGSCC-NEXT: [[CALL2:%.*]] = call i32 @noalias_args_argmem(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[A]], i32* noalias nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[B]])
|
|
; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[CALL1]], [[CALL2]]
|
|
; CGSCC-NEXT: ret i32 [[ADD]]
|
|
;
|
|
entry:
|
|
%B = alloca i32, align 4
|
|
store i32 5, i32* %B, align 4
|
|
%call1 = call i32 @noalias_args(i32* %A, i32* nonnull %B)
|
|
%call2 = call i32 @noalias_args_argmem(i32* %A, i32* nonnull %B)
|
|
%add = add nsw i32 %call1, %call2
|
|
ret i32 %add
|
|
}
|
|
|
|
define internal i32 @noalias_args_argmem_ro(i32* %A, i32* %B) #1 {
|
|
; CGSCC: Function Attrs: nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable
|
|
; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem_ro
|
|
; CGSCC-SAME: (i32 [[TMP0:%.*]], i32 [[TMP1:%.*]]) #[[ATTR1]] {
|
|
; CGSCC-NEXT: [[B_PRIV:%.*]] = alloca i32, align 4
|
|
; CGSCC-NEXT: store i32 [[TMP1]], i32* [[B_PRIV]], align 4
|
|
; CGSCC-NEXT: [[A_PRIV:%.*]] = alloca i32, align 4
|
|
; CGSCC-NEXT: store i32 [[TMP0]], i32* [[A_PRIV]], align 4
|
|
; CGSCC-NEXT: [[T0:%.*]] = load i32, i32* [[A_PRIV]], align 4
|
|
; CGSCC-NEXT: [[T1:%.*]] = load i32, i32* [[B_PRIV]], align 4
|
|
; CGSCC-NEXT: [[ADD:%.*]] = add nsw i32 [[T0]], [[T1]]
|
|
; CGSCC-NEXT: ret i32 [[ADD]]
|
|
;
|
|
%t0 = load i32, i32* %A, align 4
|
|
%t1 = load i32, i32* %B, align 4
|
|
%add = add nsw i32 %t0, %t1
|
|
ret i32 %add
|
|
}
|
|
|
|
define i32 @visible_local_2() {
|
|
; TUNIT: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
|
|
; TUNIT-LABEL: define {{[^@]+}}@visible_local_2
|
|
; TUNIT-SAME: () #[[ATTR2:[0-9]+]] {
|
|
; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4
|
|
; TUNIT-NEXT: ret i32 10
|
|
;
|
|
; CGSCC: Function Attrs: nofree nosync nounwind willreturn memory(none)
|
|
; CGSCC-LABEL: define {{[^@]+}}@visible_local_2
|
|
; CGSCC-SAME: () #[[ATTR3:[0-9]+]] {
|
|
; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_ro(i32 noundef 5, i32 noundef 5) #[[ATTR6:[0-9]+]]
|
|
; CGSCC-NEXT: ret i32 [[CALL]]
|
|
;
|
|
%B = alloca i32, align 4
|
|
store i32 5, i32* %B, align 4
|
|
%call = call i32 @noalias_args_argmem_ro(i32* %B, i32* %B)
|
|
ret i32 %call
|
|
}
|
|
|
|
define internal i32 @noalias_args_argmem_rn(i32* %A, i32* %B) #1 {
|
|
; TUNIT: Function Attrs: nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
|
|
; TUNIT-LABEL: define {{[^@]+}}@noalias_args_argmem_rn
|
|
; TUNIT-SAME: (i32* noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR1]] {
|
|
; TUNIT-NEXT: [[T0:%.*]] = load i32, i32* [[B]], align 4
|
|
; TUNIT-NEXT: ret i32 [[T0]]
|
|
;
|
|
; CGSCC: Function Attrs: nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable
|
|
; CGSCC-LABEL: define {{[^@]+}}@noalias_args_argmem_rn
|
|
; CGSCC-SAME: (i32* noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[B:%.*]]) #[[ATTR4:[0-9]+]] {
|
|
; CGSCC-NEXT: [[T0:%.*]] = load i32, i32* [[B]], align 4
|
|
; CGSCC-NEXT: store i32 0, i32* [[B]], align 4
|
|
; CGSCC-NEXT: ret i32 [[T0]]
|
|
;
|
|
%t0 = load i32, i32* %B, align 4
|
|
store i32 0, i32* %B
|
|
ret i32 %t0
|
|
}
|
|
|
|
define i32 @visible_local_3() {
|
|
; TUNIT: Function Attrs: nofree norecurse nosync nounwind willreturn memory(none)
|
|
; TUNIT-LABEL: define {{[^@]+}}@visible_local_3
|
|
; TUNIT-SAME: () #[[ATTR2]] {
|
|
; TUNIT-NEXT: [[B:%.*]] = alloca i32, align 4
|
|
; TUNIT-NEXT: store i32 5, i32* [[B]], align 4
|
|
; TUNIT-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_rn(i32* noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[B]]) #[[ATTR4:[0-9]+]]
|
|
; TUNIT-NEXT: ret i32 [[CALL]]
|
|
;
|
|
; CGSCC: Function Attrs: nofree nosync nounwind willreturn memory(none)
|
|
; CGSCC-LABEL: define {{[^@]+}}@visible_local_3
|
|
; CGSCC-SAME: () #[[ATTR3]] {
|
|
; CGSCC-NEXT: [[B:%.*]] = alloca i32, align 4
|
|
; CGSCC-NEXT: store i32 5, i32* [[B]], align 4
|
|
; CGSCC-NEXT: [[CALL:%.*]] = call i32 @noalias_args_argmem_rn(i32* noalias nocapture nofree noundef nonnull align 4 dereferenceable(4) [[B]]) #[[ATTR7:[0-9]+]]
|
|
; CGSCC-NEXT: ret i32 [[CALL]]
|
|
;
|
|
%B = alloca i32, align 4
|
|
store i32 5, i32* %B, align 4
|
|
%call = call i32 @noalias_args_argmem_rn(i32* %B, i32* %B)
|
|
ret i32 %call
|
|
}
|
|
|
|
attributes #0 = { noinline nounwind uwtable willreturn }
|
|
attributes #1 = { argmemonly noinline nounwind uwtable willreturn}
|
|
;.
|
|
; TUNIT: attributes #[[ATTR0]] = { nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable }
|
|
; TUNIT: attributes #[[ATTR1]] = { nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable }
|
|
; TUNIT: attributes #[[ATTR2]] = { nofree norecurse nosync nounwind willreturn memory(none) }
|
|
; TUNIT: attributes #[[ATTR3]] = { nofree nosync nounwind }
|
|
; TUNIT: attributes #[[ATTR4]] = { nofree nosync nounwind willreturn }
|
|
;.
|
|
; CGSCC: attributes #[[ATTR0]] = { nofree noinline nosync nounwind willreturn memory(argmem: read) uwtable }
|
|
; CGSCC: attributes #[[ATTR1]] = { nofree noinline norecurse nosync nounwind willreturn memory(argmem: read) uwtable }
|
|
; CGSCC: attributes #[[ATTR2]] = { nofree noinline nosync nounwind willreturn memory(argmem: readwrite) uwtable }
|
|
; CGSCC: attributes #[[ATTR3]] = { nofree nosync nounwind willreturn memory(none) }
|
|
; CGSCC: attributes #[[ATTR4]] = { nofree noinline norecurse nosync nounwind willreturn memory(argmem: readwrite) uwtable }
|
|
; CGSCC: attributes #[[ATTR5]] = { memory(read) }
|
|
; CGSCC: attributes #[[ATTR6]] = { willreturn }
|
|
; CGSCC: attributes #[[ATTR7]] = { nounwind willreturn }
|
|
;.
|