1 | // RUN: %clang_cc1 -O1 %s -S -emit-llvm -o - | FileCheck %s |
2 | // RUN: %clang_cc1 -O1 %s -S -emit-llvm -o - | opt -ipconstprop -S | FileCheck --check-prefix=IPCP %s |
3 | |
4 | // CHECK: declare !callback ![[cid:[0-9]+]] {{.*}}i32 @pthread_create |
5 | // CHECK: ![[cid]] = !{![[cidb:[0-9]+]]} |
6 | // CHECK: ![[cidb]] = !{i64 2, i64 3, i1 false} |
7 | |
8 | // Taken from test/Analysis/retain-release.m |
9 | //{ |
10 | struct _opaque_pthread_t {}; |
11 | struct _opaque_pthread_attr_t {}; |
12 | typedef struct _opaque_pthread_t *__darwin_pthread_t; |
13 | typedef struct _opaque_pthread_attr_t __darwin_pthread_attr_t; |
14 | typedef __darwin_pthread_t pthread_t; |
15 | typedef __darwin_pthread_attr_t pthread_attr_t; |
16 | |
17 | int pthread_create(pthread_t *, const pthread_attr_t *, |
18 | void *(*)(void *), void *); |
19 | //} |
20 | |
21 | const int GlobalVar = 0; |
22 | |
23 | static void *callee0(void *payload) { |
24 | // IPCP: define internal i8* @callee0 |
25 | // IPCP: ret i8* null |
26 | return payload; |
27 | } |
28 | |
29 | static void *callee1(void *payload) { |
30 | // IPCP: define internal i8* @callee1 |
31 | // IPCP: ret i8* bitcast (i32* @GlobalVar to i8*) |
32 | return payload; |
33 | } |
34 | |
35 | void foo() { |
36 | pthread_t MyFirstThread; |
37 | pthread_create(&MyFirstThread, 0, callee0, 0); |
38 | |
39 | pthread_t MySecondThread; |
40 | pthread_create(&MySecondThread, 0, callee1, (void *)&GlobalVar); |
41 | } |
42 | |