1; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --check-attributes --check-globals
2; RUN: opt -attributor -enable-new-pm=0 -attributor-manifest-internal  -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-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 -enable-new-pm=0 -attributor-manifest-internal  -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-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
26;.
27; CHECK: @[[GTL:[a-zA-Z0-9_$"\\.-]+]] = dso_local thread_local global i32 0, align 4
28; CHECK: @[[GSH:[a-zA-Z0-9_$"\\.-]+]] = dso_local global i32 0, align 4
29;.
30define internal i32 @callee(i32* %thread_local_ptr, i32* %shared_ptr) {
31; IS__TUNIT____: Function Attrs: nofree nosync nounwind readonly willreturn
32; IS__TUNIT____-LABEL: define {{[^@]+}}@callee
33; IS__TUNIT____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[THREAD_LOCAL_PTR:%.*]], i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[SHARED_PTR:%.*]]) #[[ATTR0:[0-9]+]] {
34; IS__TUNIT____-NEXT:  entry:
35; IS__TUNIT____-NEXT:    [[TMP:%.*]] = load i32, i32* [[THREAD_LOCAL_PTR]], align 4
36; IS__TUNIT____-NEXT:    [[TMP1:%.*]] = load i32, i32* @gsh, align 4
37; IS__TUNIT____-NEXT:    [[ADD:%.*]] = add nsw i32 [[TMP]], [[TMP1]]
38; IS__TUNIT____-NEXT:    ret i32 [[ADD]]
39;
40; IS__CGSCC____: Function Attrs: nofree norecurse nosync nounwind readonly willreturn
41; IS__CGSCC____-LABEL: define {{[^@]+}}@callee
42; IS__CGSCC____-SAME: (i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) [[THREAD_LOCAL_PTR:%.*]], i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) [[SHARED_PTR:%.*]]) #[[ATTR0:[0-9]+]] {
43; IS__CGSCC____-NEXT:  entry:
44; IS__CGSCC____-NEXT:    [[TMP:%.*]] = load i32, i32* [[THREAD_LOCAL_PTR]], align 4
45; IS__CGSCC____-NEXT:    [[TMP1:%.*]] = load i32, i32* @gsh, align 4
46; IS__CGSCC____-NEXT:    [[ADD:%.*]] = add nsw i32 [[TMP]], [[TMP1]]
47; IS__CGSCC____-NEXT:    ret i32 [[ADD]]
48;
49entry:
50  %tmp = load i32, i32* %thread_local_ptr, align 4
51  %tmp1 = load i32, i32* %shared_ptr, align 4
52  %add = add nsw i32 %tmp, %tmp1
53  ret i32 %add
54}
55
56define dso_local void @caller() {
57; IS__TUNIT____-LABEL: define {{[^@]+}}@caller() {
58; IS__TUNIT____-NEXT:  entry:
59; IS__TUNIT____-NEXT:    call void @broker(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) @gtl, i32 (i32*, i32*)* noundef nonnull @callee, i32* nocapture nofree nonnull readonly align 4 dereferenceable(4) undef)
60; IS__TUNIT____-NEXT:    ret void
61;
62; IS__CGSCC____-LABEL: define {{[^@]+}}@caller() {
63; IS__CGSCC____-NEXT:  entry:
64; IS__CGSCC____-NEXT:    call void @broker(i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) @gtl, i32 (i32*, i32*)* noundef nonnull @callee, i32* nocapture nofree noundef nonnull readonly align 4 dereferenceable(4) @gsh)
65; IS__CGSCC____-NEXT:    ret void
66;
67entry:
68  call void @broker(i32* nonnull @gtl, i32 (i32*, i32*)* nonnull @callee, i32* nonnull @gsh)
69  ret void
70}
71
72declare !callback !0 dso_local void @broker(i32*, i32 (i32*, i32*)*, i32*)
73
74!1 = !{i64 1, i64 0, i64 2, i1 false}
75!0 = !{!1}
76;.
77; IS__TUNIT____: attributes #[[ATTR0]] = { nofree nosync nounwind readonly willreturn }
78;.
79; IS__CGSCC____: attributes #[[ATTR0]] = { nofree norecurse nosync nounwind readonly willreturn }
80;.
81; CHECK: [[META0:![0-9]+]] = !{!1}
82; CHECK: [[META1:![0-9]+]] = !{i64 1, i64 0, i64 2, i1 false}
83;.
84