annotate clang/test/CodeGen/conditional.c @ 207:2e18cbf3894f

LLVM12
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 08 Jun 2021 06:07:14 +0900
parents 1d019706d866
children c4bab56944e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
150
anatofuz
parents:
diff changeset
1 // RUN: %clang_cc1 -emit-llvm %s -o - | FileCheck %s
anatofuz
parents:
diff changeset
2
anatofuz
parents:
diff changeset
3 float test1(int cond, float a, float b) {
anatofuz
parents:
diff changeset
4 return cond ? a : b;
anatofuz
parents:
diff changeset
5 }
anatofuz
parents:
diff changeset
6
anatofuz
parents:
diff changeset
7 double test2(int cond, float a, double b) {
anatofuz
parents:
diff changeset
8 return cond ? a : b;
anatofuz
parents:
diff changeset
9 }
anatofuz
parents:
diff changeset
10
anatofuz
parents:
diff changeset
11 void f();
anatofuz
parents:
diff changeset
12
anatofuz
parents:
diff changeset
13 void test3(){
anatofuz
parents:
diff changeset
14 1 ? f() : (void)0;
anatofuz
parents:
diff changeset
15 }
anatofuz
parents:
diff changeset
16
anatofuz
parents:
diff changeset
17 void test4() {
anatofuz
parents:
diff changeset
18 int i; short j;
anatofuz
parents:
diff changeset
19 float* k = 1 ? &i : &j;
anatofuz
parents:
diff changeset
20 }
anatofuz
parents:
diff changeset
21
anatofuz
parents:
diff changeset
22 void test5() {
anatofuz
parents:
diff changeset
23 const int* cip;
anatofuz
parents:
diff changeset
24 void* vp;
anatofuz
parents:
diff changeset
25 cip = 0 ? vp : cip;
anatofuz
parents:
diff changeset
26 }
anatofuz
parents:
diff changeset
27
anatofuz
parents:
diff changeset
28 void test6();
anatofuz
parents:
diff changeset
29 void test7(int);
anatofuz
parents:
diff changeset
30 void* test8() {return 1 ? test6 : test7;}
anatofuz
parents:
diff changeset
31
anatofuz
parents:
diff changeset
32
anatofuz
parents:
diff changeset
33 void _efree(void *ptr);
anatofuz
parents:
diff changeset
34
anatofuz
parents:
diff changeset
35 void _php_stream_free3() {
anatofuz
parents:
diff changeset
36 (1 ? free(0) : _efree(0));
anatofuz
parents:
diff changeset
37 }
anatofuz
parents:
diff changeset
38
anatofuz
parents:
diff changeset
39 void _php_stream_free4() {
anatofuz
parents:
diff changeset
40 1 ? _efree(0) : free(0);
anatofuz
parents:
diff changeset
41 }
anatofuz
parents:
diff changeset
42
anatofuz
parents:
diff changeset
43 // PR5526
anatofuz
parents:
diff changeset
44 struct test9 { int a; };
anatofuz
parents:
diff changeset
45 void* test9spare();
anatofuz
parents:
diff changeset
46 void test9(struct test9 *p) {
anatofuz
parents:
diff changeset
47 p ? p : test9spare();
anatofuz
parents:
diff changeset
48 }
anatofuz
parents:
diff changeset
49
anatofuz
parents:
diff changeset
50 // CHECK: @test10
anatofuz
parents:
diff changeset
51 // CHECK: select i1 {{.*}}, i32 4, i32 5
anatofuz
parents:
diff changeset
52 int test10(int c) {
anatofuz
parents:
diff changeset
53 return c ? 4 : 5;
anatofuz
parents:
diff changeset
54 }
anatofuz
parents:
diff changeset
55 enum { Gronk = 5 };
anatofuz
parents:
diff changeset
56
anatofuz
parents:
diff changeset
57 // rdar://9289603
anatofuz
parents:
diff changeset
58 // CHECK: @test11
anatofuz
parents:
diff changeset
59 // CHECK: select i1 {{.*}}, i32 4, i32 5
anatofuz
parents:
diff changeset
60 int test11(int c) {
anatofuz
parents:
diff changeset
61 return c ? 4 : Gronk;
anatofuz
parents:
diff changeset
62 }
anatofuz
parents:
diff changeset
63
anatofuz
parents:
diff changeset
64 // CHECK: @test12
anatofuz
parents:
diff changeset
65 // CHECK: select i1 {{.*}}, double 4.0{{.*}}, double 2.0
anatofuz
parents:
diff changeset
66 double test12(int c) {
anatofuz
parents:
diff changeset
67 return c ? 4.0 : 2.0;
anatofuz
parents:
diff changeset
68 }
anatofuz
parents:
diff changeset
69 // CHECK: @test13
anatofuz
parents:
diff changeset
70 // CHECK: call {{.*}} @f2(
anatofuz
parents:
diff changeset
71 int f2(void);
anatofuz
parents:
diff changeset
72 void test13() {
anatofuz
parents:
diff changeset
73 f2() ? (void)0 : (void)0;
anatofuz
parents:
diff changeset
74 }