1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
2; RUN: opt -attributor -attributor-manifest-internal -attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_NPM,NOT_CGSCC_OPM,NOT_TUNIT_NPM,IS__TUNIT____,IS________OPM,IS__TUNIT_OPM
3; RUN: opt -aa-pipeline=basic-aa -passes=attributor -attributor-manifest-internal -attributor-disable=false -attributor-max-iterations-verify -attributor-annotate-decl-cs -attributor-max-iterations=1 -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_CGSCC_OPM,NOT_CGSCC_NPM,NOT_TUNIT_OPM,IS__TUNIT____,IS________NPM,IS__TUNIT_NPM
4; RUN: opt -attributor-cgscc -attributor-manifest-internal -attributor-disable=false -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_NPM,IS__CGSCC____,IS________OPM,IS__CGSCC_OPM
5; RUN: opt -aa-pipeline=basic-aa -passes=attributor-cgscc -attributor-manifest-internal -attributor-disable=false -attributor-annotate-decl-cs -S < %s | FileCheck %s --check-prefixes=CHECK,NOT_TUNIT_NPM,NOT_TUNIT_OPM,NOT_CGSCC_OPM,IS__CGSCC____,IS________NPM,IS__CGSCC_NPM
6;
7;    #include <threads.h>
8;    thread_local int gtl = 0;
9;    int gsh = 0;
10;
11;    static int callee(int *thread_local_ptr, int *shared_ptr) {
12;      return *thread_local_ptr + *shared_ptr;
13;    }
14;
15;    void broker(int *, int (*callee)(int *, int *), int *);
16;
17;    void caller() {
18;      broker(&gtl, callee, &gsh);
19;    }
20;
21target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
22
23@gtl = dso_local thread_local global i32 0, align 4
24@gsh = dso_local global i32 0, align 4
25
26define internal i32 @callee(i32* %thread_local_ptr, i32* %shared_ptr) {
27; CHECK-LABEL: define {{[^@]+}}@callee
28; CHECK-SAME: (i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[THREAD_LOCAL_PTR:%.*]], i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[SHARED_PTR:%.*]])
29; CHECK-NEXT:  entry:
30; CHECK-NEXT:    [[TMP:%.*]] = load i32, i32* [[THREAD_LOCAL_PTR]], align 4
31; CHECK-NEXT:    [[TMP1:%.*]] = load i32, i32* @gsh, align 4
32; CHECK-NEXT:    [[ADD:%.*]] = add nsw i32 [[TMP]], [[TMP1]]
33; CHECK-NEXT:    ret i32 [[ADD]]
34;
35entry:
36  %tmp = load i32, i32* %thread_local_ptr, align 4
37  %tmp1 = load i32, i32* %shared_ptr, align 4
38  %add = add nsw i32 %tmp, %tmp1
39  ret i32 %add
40}
41
42define dso_local void @caller() {
43; IS__TUNIT____-LABEL: define {{[^@]+}}@caller()
44; IS__TUNIT____-NEXT:  entry:
45; IS__TUNIT____-NEXT:    call void @broker(i32* nofree nonnull readonly align 4 dereferenceable(4) @gtl, i32 (i32*, i32*)* nonnull @callee, i32* nofree nonnull readonly align 4 dereferenceable(4) undef)
46; IS__TUNIT____-NEXT:    ret void
47;
48; IS__CGSCC____-LABEL: define {{[^@]+}}@caller()
49; IS__CGSCC____-NEXT:  entry:
50; IS__CGSCC____-NEXT:    call void @broker(i32* nofree nonnull readonly align 4 dereferenceable(4) @gtl, i32 (i32*, i32*)* nonnull @callee, i32* nofree nonnull readonly align 4 dereferenceable(4) @gsh)
51; IS__CGSCC____-NEXT:    ret void
52;
53entry:
54  call void @broker(i32* nonnull @gtl, i32 (i32*, i32*)* nonnull @callee, i32* nonnull @gsh)
55  ret void
56}
57
58declare !callback !0 dso_local void @broker(i32*, i32 (i32*, i32*)*, i32*)
59
60!1 = !{i64 1, i64 0, i64 2, i1 false}
61!0 = !{!1}
62