; 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-annotate-decl-cs -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
; PR 32917
@b = common local_unnamed_addr global i32 0, align 4
@a = common local_unnamed_addr global i32 0, align 4
;.
; CHECK: @b = common local_unnamed_addr global i32 0, align 4
; CHECK: @a = common local_unnamed_addr global i32 0, align 4
;.
define i32 @fn2() local_unnamed_addr {
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
; TUNIT-LABEL: define {{[^@]+}}@fn2
; TUNIT-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
; TUNIT-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
; TUNIT-NEXT: [[TMP2:%.*]] = sext i32 [[TMP1]] to i64
; TUNIT-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
; TUNIT-NEXT: call fastcc void @fn1(ptr nocapture nofree readonly align 4 [[TMP3]]) #[[ATTR1:[0-9]+]]
; TUNIT-NEXT: ret i32 undef
;
; CGSCC: Function Attrs: mustprogress nofree nosync nounwind willreturn
; CGSCC-LABEL: define {{[^@]+}}@fn2
; CGSCC-SAME: () local_unnamed_addr #[[ATTR0:[0-9]+]] {
; CGSCC-NEXT: [[TMP1:%.*]] = load i32, ptr @b, align 4
; CGSCC-NEXT: [[TMP2:%.*]] = sext i32 [[TMP1]] to i64
; CGSCC-NEXT: [[TMP3:%.*]] = inttoptr i64 [[TMP2]] to ptr
; CGSCC-NEXT: call fastcc void @fn1(ptr nocapture nofree nonnull readonly align 4 [[TMP3]]) #[[ATTR2:[0-9]+]]
; CGSCC-NEXT: ret i32 undef
;
%1 = load i32, ptr @b, align 4
%2 = sext i32 %1 to i64
%3 = inttoptr i64 %2 to ptr
call fastcc void @fn1(ptr %3)
ret i32 undef
}
define internal fastcc void @fn1(ptr nocapture readonly) unnamed_addr {
; TUNIT: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
; TUNIT-LABEL: define {{[^@]+}}@fn1
; TUNIT-SAME: (ptr nocapture nofree nonnull readonly align 4 [[TMP0:%.*]]) unnamed_addr #[[ATTR0]] {
; TUNIT-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 -1
; TUNIT-NEXT: [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
; TUNIT-NEXT: store i32 [[TMP3]], ptr @a, align 4
; TUNIT-NEXT: ret void
;
; CGSCC: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn
; CGSCC-LABEL: define {{[^@]+}}@fn1
; CGSCC-SAME: (ptr nocapture nofree nonnull readonly align 4 [[TMP0:%.*]]) unnamed_addr #[[ATTR1:[0-9]+]] {
; CGSCC-NEXT: [[TMP2:%.*]] = getelementptr inbounds i32, ptr [[TMP0]], i64 -1
; CGSCC-NEXT: [[TMP3:%.*]] = load i32, ptr [[TMP2]], align 4
; CGSCC-NEXT: store i32 [[TMP3]], ptr @a, align 4
; CGSCC-NEXT: ret void
;
%2 = getelementptr inbounds i32, ptr %0, i64 -1
%3 = load i32, ptr %2, align 4
store i32 %3, ptr @a, align 4
ret void
}
;.
; TUNIT: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn }
; TUNIT: attributes #[[ATTR1]] = { nofree nosync nounwind willreturn }
;.
; CGSCC: attributes #[[ATTR0]] = { mustprogress nofree nosync nounwind willreturn }
; CGSCC: attributes #[[ATTR1]] = { mustprogress nofree norecurse nosync nounwind willreturn }
; CGSCC: attributes #[[ATTR2]] = { nofree nounwind willreturn }
;.
;; NOTE: These prefixes are unused and the list is autogenerated. Do not add tests below this line:
; CHECK: {{.*}}