Coverage Report

Created: 2017-03-27 23:01

/Users/buildslave/jenkins/sharedspace/clang-stage2-coverage-R@2/llvm/tools/polly/lib/External/isl/isl_union_single.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
 * Copyright 2010      INRIA Saclay
3
 * Copyright 2013      Ecole Normale Superieure
4
 *
5
 * Use of this software is governed by the MIT license
6
 *
7
 * Written by Sven Verdoolaege, INRIA Saclay - Ile-de-France,
8
 * Parc Club Orsay Universite, ZAC des vignes, 4 rue Jacques Monod,
9
 * 91893 Orsay, France
10
 * and Ecole Normale Superieure, 45 rue d'Ulm, 75230 Paris, France
11
 */
12
13
#include <isl_hash_private.h>
14
#include <isl_union_macro.h>
15
16
/* A union of expressions defined over different domain spaces.
17
 * "space" describes the parameters.
18
 * The entries of "table" are keyed on the domain space of the entry.
19
 */
20
struct UNION {
21
  int ref;
22
#ifdef HAS_TYPE
23
  enum isl_fold type;
24
#endif
25
  isl_space *space;
26
27
  struct isl_hash_table table;
28
};
29
30
/* Return the number of base expressions in "u".
31
 */
32
int FN(FN(UNION,n),PARTS)(__isl_keep UNION *u)
33
34
{
34
34
  return u ? 
u->table.n34
:
00
;
35
34
}
isl_union_pw_qpolynomial_n_pw_qpolynomial
Line
Count
Source
33
2
{
34
2
  return u ? 
u->table.n2
:
00
;
35
2
}
Unexecuted instantiation: isl_union_pw_qpolynomial_fold_n_pw_qpolynomial_fold
isl_union_pw_aff_n_pw_aff
Line
Count
Source
33
32
{
34
32
  return u ? 
u->table.n32
:
00
;
35
32
}
36
37
S(UNION,foreach_data)
38
{
39
  isl_stat (*fn)(__isl_take PART *part, void *user);
40
  void *user;
41
};
42
43
static isl_stat FN(UNION,call_on_copy)(void **entry, void *user)
44
14.6k
{
45
14.6k
  PART *part = *entry;
46
14.6k
  S(UNION,foreach_data) *data = (S(UNION,foreach_data) *)user;
47
14.6k
48
14.6k
  part = FN(PART,copy)(part);
49
14.6k
  if (!part)
50
0
    return isl_stat_error;
51
14.6k
  return data->fn(part, data->user);
52
14.6k
}
isl_polynomial.c:isl_union_pw_qpolynomial_call_on_copy
Line
Count
Source
44
3
{
45
3
  PART *part = *entry;
46
3
  S(UNION,foreach_data) *data = (S(UNION,foreach_data) *)user;
47
3
48
3
  part = FN(PART,copy)(part);
49
3
  if (!part)
50
0
    return isl_stat_error;
51
3
  return data->fn(part, data->user);
52
3
}
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_call_on_copy
isl_aff.c:isl_union_pw_aff_call_on_copy
Line
Count
Source
44
14.6k
{
45
14.6k
  PART *part = *entry;
46
14.6k
  S(UNION,foreach_data) *data = (S(UNION,foreach_data) *)user;
47
14.6k
48
14.6k
  part = FN(PART,copy)(part);
49
14.6k
  if (!part)
50
0
    return isl_stat_error;
51
14.6k
  return data->fn(part, data->user);
52
14.6k
}
53
54
isl_stat FN(FN(UNION,foreach),PARTS)(__isl_keep UNION *u,
55
  isl_stat (*fn)(__isl_take PART *part, void *user), void *user)
56
9.31k
{
57
9.31k
  S(UNION,foreach_data) data = { fn, user };
58
9.31k
59
9.31k
  if (!u)
60
0
    return isl_stat_error;
61
9.31k
62
9.31k
  return isl_hash_table_foreach(u->space->ctx, &u->table,
63
9.31k
              &FN(UNION,call_on_copy), &data);
64
9.31k
}
Unexecuted instantiation: isl_union_pw_qpolynomial_fold_foreach_pw_qpolynomial_fold
isl_union_pw_qpolynomial_foreach_pw_qpolynomial
Line
Count
Source
56
3
{
57
3
  S(UNION,foreach_data) data = { fn, user };
58
3
59
3
  if (!u)
60
0
    return isl_stat_error;
61
3
62
3
  return isl_hash_table_foreach(u->space->ctx, &u->table,
63
3
              &FN(UNION,call_on_copy), &data);
64
3
}
isl_union_pw_aff_foreach_pw_aff
Line
Count
Source
56
9.31k
{
57
9.31k
  S(UNION,foreach_data) data = { fn, user };
58
9.31k
59
9.31k
  if (!u)
60
0
    return isl_stat_error;
61
9.31k
62
9.31k
  return isl_hash_table_foreach(u->space->ctx, &u->table,
63
9.31k
              &FN(UNION,call_on_copy), &data);
64
9.31k
}
65
66
/* Is the domain space of "entry" equal to the domain of "space"?
67
 */
68
static int FN(UNION,has_same_domain_space)(const void *entry, const void *val)
69
261
{
70
261
  PART *part = (PART *)entry;
71
261
  isl_space *space = (isl_space *) val;
72
261
73
261
  if (isl_space_is_set(space))
74
0
    return isl_space_is_set(part->dim);
75
261
76
261
  return isl_space_tuple_is_equal(part->dim, isl_dim_in,
77
261
          space, isl_dim_in);
78
261
}
isl_aff.c:isl_union_pw_aff_has_same_domain_space
Line
Count
Source
69
260
{
70
260
  PART *part = (PART *)entry;
71
260
  isl_space *space = (isl_space *) val;
72
260
73
260
  if (isl_space_is_set(space))
74
0
    return isl_space_is_set(part->dim);
75
260
76
260
  return isl_space_tuple_is_equal(part->dim, isl_dim_in,
77
260
          space, isl_dim_in);
78
260
}
isl_polynomial.c:isl_union_pw_qpolynomial_has_same_domain_space
Line
Count
Source
69
1
{
70
1
  PART *part = (PART *)entry;
71
1
  isl_space *space = (isl_space *) val;
72
1
73
1
  if (isl_space_is_set(space))
74
0
    return isl_space_is_set(part->dim);
75
1
76
1
  return isl_space_tuple_is_equal(part->dim, isl_dim_in,
77
1
          space, isl_dim_in);
78
1
}
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_has_same_domain_space
79
80
/* Return the entry, if any, in "u" that lives in "space".
81
 * If "reserve" is set, then an entry is created if it does not exist yet.
82
 * Return NULL on error and isl_hash_table_entry_none if no entry was found.
83
 * Note that when "reserve" is set, the function will never return
84
 * isl_hash_table_entry_none.
85
 *
86
 * First look for the entry (if any) with the same domain space.
87
 * If it exists, then check if the range space also matches.
88
 */
89
static struct isl_hash_table_entry *FN(UNION,find_part_entry)(
90
  __isl_keep UNION *u, __isl_keep isl_space *space, int reserve)
91
4.54k
{
92
4.54k
  isl_ctx *ctx;
93
4.54k
  uint32_t hash;
94
4.54k
  struct isl_hash_table_entry *entry;
95
4.54k
  isl_bool equal;
96
4.54k
  PART *part;
97
4.54k
98
4.54k
  if (
!u || 4.54k
!space4.54k
)
99
0
    return NULL;
100
4.54k
101
4.54k
  
ctx = 4.54k
FN4.54k
(UNION,get_ctx)(u);
102
4.54k
  hash = isl_space_get_domain_hash(space);
103
4.54k
  entry = isl_hash_table_find(ctx, &u->table, hash,
104
4.54k
      &FN(UNION,has_same_domain_space), space, reserve);
105
4.54k
  if (!entry)
106
0
    
return reserve ? NULL : 0
isl_hash_table_entry_none0
;
107
4.54k
  
if (4.54k
reserve && 4.54k
!entry->data4.28k
)
108
4.28k
    return entry;
109
261
  part = entry->data;
110
261
  equal = isl_space_tuple_is_equal(part->dim, isl_dim_out,
111
261
              space, isl_dim_out);
112
261
  if (equal < 0)
113
0
    return NULL;
114
261
  
if (261
equal261
)
115
261
    return entry;
116
0
  
if (0
!reserve0
)
117
0
    return isl_hash_table_entry_none;
118
0
  
isl_die0
(FN(UNION,get_ctx)(u), isl_error_invalid,0
119
0
    "union expression can only contain a single "
120
0
    "expression over a given domain", return NULL);
121
0
}
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_find_part_entry
isl_polynomial.c:isl_union_pw_qpolynomial_find_part_entry
Line
Count
Source
91
6
{
92
6
  isl_ctx *ctx;
93
6
  uint32_t hash;
94
6
  struct isl_hash_table_entry *entry;
95
6
  isl_bool equal;
96
6
  PART *part;
97
6
98
6
  if (
!u || 6
!space6
)
99
0
    return NULL;
100
6
101
6
  
ctx = 6
FN6
(UNION,get_ctx)(u);
102
6
  hash = isl_space_get_domain_hash(space);
103
6
  entry = isl_hash_table_find(ctx, &u->table, hash,
104
6
      &FN(UNION,has_same_domain_space), space, reserve);
105
6
  if (!entry)
106
0
    
return reserve ? NULL : 0
isl_hash_table_entry_none0
;
107
6
  
if (6
reserve && 6
!entry->data5
)
108
5
    return entry;
109
1
  part = entry->data;
110
1
  equal = isl_space_tuple_is_equal(part->dim, isl_dim_out,
111
1
              space, isl_dim_out);
112
1
  if (equal < 0)
113
0
    return NULL;
114
1
  
if (1
equal1
)
115
1
    return entry;
116
0
  
if (0
!reserve0
)
117
0
    return isl_hash_table_entry_none;
118
0
  
isl_die0
(FN(UNION,get_ctx)(u), isl_error_invalid,0
119
0
    "union expression can only contain a single "
120
0
    "expression over a given domain", return NULL);
121
0
}
isl_aff.c:isl_union_pw_aff_find_part_entry
Line
Count
Source
91
4.54k
{
92
4.54k
  isl_ctx *ctx;
93
4.54k
  uint32_t hash;
94
4.54k
  struct isl_hash_table_entry *entry;
95
4.54k
  isl_bool equal;
96
4.54k
  PART *part;
97
4.54k
98
4.54k
  if (
!u || 4.54k
!space4.54k
)
99
0
    return NULL;
100
4.54k
101
4.54k
  
ctx = 4.54k
FN4.54k
(UNION,get_ctx)(u);
102
4.54k
  hash = isl_space_get_domain_hash(space);
103
4.54k
  entry = isl_hash_table_find(ctx, &u->table, hash,
104
4.54k
      &FN(UNION,has_same_domain_space), space, reserve);
105
4.54k
  if (!entry)
106
0
    
return reserve ? NULL : 0
isl_hash_table_entry_none0
;
107
4.54k
  
if (4.54k
reserve && 4.54k
!entry->data4.28k
)
108
4.28k
    return entry;
109
260
  part = entry->data;
110
260
  equal = isl_space_tuple_is_equal(part->dim, isl_dim_out,
111
260
              space, isl_dim_out);
112
260
  if (equal < 0)
113
0
    return NULL;
114
260
  
if (260
equal260
)
115
260
    return entry;
116
0
  
if (0
!reserve0
)
117
0
    return isl_hash_table_entry_none;
118
0
  
isl_die0
(FN(UNION,get_ctx)(u), isl_error_invalid,0
119
0
    "union expression can only contain a single "
120
0
    "expression over a given domain", return NULL);
121
0
}
122
123
/* Remove "part_entry" from the hash table of "u".
124
 */
125
static __isl_give UNION *FN(UNION,remove_part_entry)(__isl_take UNION *u,
126
  struct isl_hash_table_entry *part_entry)
127
0
{
128
0
  isl_ctx *ctx;
129
0
130
0
  if (
!u || 0
!part_entry0
)
131
0
    
return 0
FN0
(UNION,free)(u);
132
0
133
0
  
ctx = 0
FN0
(UNION,get_ctx)(u);
134
0
  isl_hash_table_remove(ctx, &u->table, part_entry);
135
0
  FN(PART,free)(part_entry->data);
136
0
137
0
  return u;
138
0
}
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_remove_part_entry
Unexecuted instantiation: isl_aff.c:isl_union_pw_aff_remove_part_entry
Unexecuted instantiation: isl_polynomial.c:isl_union_pw_qpolynomial_remove_part_entry
139
140
/* Check that the domain of "part" is disjoint from the domain of the entries
141
 * in "u" that are defined on the same domain space, but have a different
142
 * target space.
143
 * Since a UNION with a single entry per domain space is not allowed
144
 * to contain two entries with the same domain space, there cannot be
145
 * any such other entry.
146
 */
147
static isl_stat FN(UNION,check_disjoint_domain_other)(__isl_keep UNION *u,
148
  __isl_keep PART *part)
149
4.28k
{
150
4.28k
  return isl_stat_ok;
151
4.28k
}
isl_aff.c:isl_union_pw_aff_check_disjoint_domain_other
Line
Count
Source
149
4.28k
{
150
4.28k
  return isl_stat_ok;
151
4.28k
}
isl_polynomial.c:isl_union_pw_qpolynomial_check_disjoint_domain_other
Line
Count
Source
149
5
{
150
5
  return isl_stat_ok;
151
5
}
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_check_disjoint_domain_other
152
153
/* Check that the domain of "part1" is disjoint from the domain of "part2".
154
 * This check is performed before "part2" is added to a UNION to ensure
155
 * that the UNION expression remains a function.
156
 * Since a UNION with a single entry per domain space is not allowed
157
 * to contain two entries with the same domain space, fail unconditionally.
158
 */
159
static isl_stat FN(UNION,check_disjoint_domain)(__isl_keep PART *part1,
160
  __isl_keep PART *part2)
161
0
{
162
0
  isl_die(FN(PART,get_ctx)(part1), isl_error_invalid,
163
0
    "additional part should live on separate space",
164
0
    return isl_stat_error);
165
0
}
Unexecuted instantiation: isl_polynomial.c:isl_union_pw_qpolynomial_check_disjoint_domain
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_check_disjoint_domain
Unexecuted instantiation: isl_aff.c:isl_union_pw_aff_check_disjoint_domain
166
167
/* Call "fn" on each part entry of "u".
168
 */
169
static isl_stat FN(UNION,foreach_inplace)(__isl_keep UNION *u,
170
  isl_stat (*fn)(void **part, void *user), void *user)
171
1.93k
{
172
1.93k
  isl_ctx *ctx;
173
1.93k
174
1.93k
  if (!u)
175
0
    return isl_stat_error;
176
1.93k
  
ctx = 1.93k
FN1.93k
(UNION,get_ctx)(u);
177
1.93k
  return isl_hash_table_foreach(ctx, &u->table, fn, user);
178
1.93k
}
isl_polynomial.c:isl_union_pw_qpolynomial_foreach_inplace
Line
Count
Source
171
1
{
172
1
  isl_ctx *ctx;
173
1
174
1
  if (!u)
175
0
    return isl_stat_error;
176
1
  
ctx = 1
FN1
(UNION,get_ctx)(u);
177
1
  return isl_hash_table_foreach(ctx, &u->table, fn, user);
178
1
}
isl_aff.c:isl_union_pw_aff_foreach_inplace
Line
Count
Source
171
1.93k
{
172
1.93k
  isl_ctx *ctx;
173
1.93k
174
1.93k
  if (!u)
175
0
    return isl_stat_error;
176
1.93k
  
ctx = 1.93k
FN1.93k
(UNION,get_ctx)(u);
177
1.93k
  return isl_hash_table_foreach(ctx, &u->table, fn, user);
178
1.93k
}
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_foreach_inplace
179
180
/* Does "u" have a single reference?
181
 * That is, can we change "u" inplace?
182
 */
183
static isl_bool FN(UNION,has_single_reference)(__isl_keep UNION *u)
184
2.22k
{
185
2.22k
  if (!u)
186
0
    return isl_bool_error;
187
2.22k
  return u->ref == 1;
188
2.22k
}
isl_aff.c:isl_union_pw_aff_has_single_reference
Line
Count
Source
184
2.22k
{
185
2.22k
  if (!u)
186
0
    return isl_bool_error;
187
2.22k
  return u->ref == 1;
188
2.22k
}
Unexecuted instantiation: isl_polynomial.c:isl_union_pw_qpolynomial_has_single_reference
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_has_single_reference
189
190
static isl_stat FN(UNION,free_u_entry)(void **entry, void *user)
191
4.28k
{
192
4.28k
  PART *part = *entry;
193
4.28k
  FN(PART,free)(part);
194
4.28k
  return isl_stat_ok;
195
4.28k
}
Unexecuted instantiation: isl_fold.c:isl_union_pw_qpolynomial_fold_free_u_entry
isl_polynomial.c:isl_union_pw_qpolynomial_free_u_entry
Line
Count
Source
191
5
{
192
5
  PART *part = *entry;
193
5
  FN(PART,free)(part);
194
5
  return isl_stat_ok;
195
5
}
isl_aff.c:isl_union_pw_aff_free_u_entry
Line
Count
Source
191
4.28k
{
192
4.28k
  PART *part = *entry;
193
4.28k
  FN(PART,free)(part);
194
4.28k
  return isl_stat_ok;
195
4.28k
}
196
197
#include <isl_union_templ.c>