1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,TUNIT
3 ; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,CGSCC
6 ; thread_local int gtl = 0;
9 ; static int callee(int *thread_local_ptr, int *shared_ptr) {
10 ; return *thread_local_ptr + *shared_ptr;
13 ; void broker(int *, int (*callee)(int *, int *), int *);
16 ; broker(>l, callee, &gsh);
19 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
21 @gtl = dso_local thread_local global i32 0, align 4
22 @gsh = dso_local global i32 0, align 4
25 ; CHECK: @[[GTL:[a-zA-Z0-9_$"\\.-]+]] = dso_local thread_local global i32 0, align 4
26 ; CHECK: @[[GSH:[a-zA-Z0-9_$"\\.-]+]] = dso_local global i32 0, align 4
28 define internal i32 @callee(ptr %thread_local_ptr, ptr %shared_ptr) {
29 ; CHECK: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(read)
30 ; CHECK-LABEL: define {{[^@]+}}@callee
31 ; CHECK-SAME: (ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[THREAD_LOCAL_PTR:%.*]], ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[SHARED_PTR:%.*]]) #[[ATTR0:[0-9]+]] {
33 ; CHECK-NEXT: [[TMP:%.*]] = load i32, ptr @gtl, align 4
34 ; CHECK-NEXT: [[TRUETMP1:%.*]] = load i32, ptr @gsh, align 4
35 ; CHECK-NEXT: [[ADD:%.*]] = add nsw i32 [[TMP]], [[TRUETMP1]]
36 ; CHECK-NEXT: ret i32 [[ADD]]
39 %tmp = load i32, ptr %thread_local_ptr, align 4
40 %tmp1 = load i32, ptr %shared_ptr, align 4
41 %add = add nsw i32 %tmp, %tmp1
45 define dso_local void @caller() {
46 ; TUNIT-LABEL: define {{[^@]+}}@caller() {
48 ; TUNIT-NEXT: call void @broker(ptr nocapture nofree nonnull readonly align 4 dereferenceable(4) undef, ptr noundef nonnull @callee, ptr nocapture nofree nonnull readonly align 4 dereferenceable(4) undef)
49 ; TUNIT-NEXT: ret void
51 ; CGSCC-LABEL: define {{[^@]+}}@caller() {
53 ; CGSCC-NEXT: call void @broker(ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) @gtl, ptr noundef nonnull @callee, ptr nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) @gsh)
54 ; CGSCC-NEXT: ret void
57 call void @broker(ptr nonnull @gtl, ptr nonnull @callee, ptr nonnull @gsh)
61 declare !callback !0 dso_local void @broker(ptr, ptr, ptr)
63 !1 = !{i64 1, i64 0, i64 2, i1 false}
66 ; CHECK: attributes #[[ATTR0]] = { mustprogress nofree norecurse nosync nounwind willreturn memory(read) }
68 ; CHECK: [[META0:![0-9]+]] = !{!1}
69 ; CHECK: [[META1:![0-9]+]] = !{i64 1, i64 0, i64 2, i1 false}