Bug Summary

File:tools/polly/lib/External/ppcg/gpu_array_tile.c
Warning:line 14, column 16
Dereference of null pointer

Annotated Source Code

1#include <isl/aff.h>
2#include <isl/map.h>
3
4#include "gpu_array_tile.h"
5
6struct gpu_array_tile *gpu_array_tile_free(struct gpu_array_tile *tile)
7{
8 int j;
9
10 if (!tile)
7
Taking false branch
11 return NULL((void*)0);
12
13 for (j = 0; j < tile->n; ++j) {
8
Assuming the condition is true
9
Loop condition is true. Entering loop body
14 isl_val_free(tile->bound[j].size);
10
Dereference of null pointer
15 isl_val_free(tile->bound[j].stride);
16 isl_aff_free(tile->bound[j].lb);
17 isl_aff_free(tile->bound[j].shift);
18 }
19 free(tile->bound);
20 isl_multi_aff_free(tile->tiling);
21 free(tile);
22
23 return NULL((void*)0);
24}
25
26/* Create a gpu_array_tile for an array of dimension "n_index".
27 */
28struct gpu_array_tile *gpu_array_tile_create(isl_ctx *ctx, int n_index)
29{
30 int i;
31 struct gpu_array_tile *tile;
32
33 tile = isl_calloc_type(ctx, struct gpu_array_tile)((struct gpu_array_tile *)isl_calloc_or_die(ctx, 1, sizeof(struct
gpu_array_tile)))
;
34 if (!tile)
1
Assuming 'tile' is non-null
2
Taking false branch
35 return NULL((void*)0);
36
37 tile->ctx = ctx;
38 tile->bound = isl_alloc_array(ctx, struct gpu_array_bound, n_index)((struct gpu_array_bound *)isl_malloc_or_die(ctx, (n_index)*sizeof
(struct gpu_array_bound)))
;
3
Value assigned to field 'bound'
39 if (!tile->bound)
4
Assuming pointer value is null
5
Taking true branch
40 return gpu_array_tile_free(tile);
6
Calling 'gpu_array_tile_free'
41
42 tile->n = n_index;
43
44 for (i = 0; i < n_index; ++i) {
45 tile->bound[i].size = NULL((void*)0);
46 tile->bound[i].lb = NULL((void*)0);
47 tile->bound[i].stride = NULL((void*)0);
48 tile->bound[i].shift = NULL((void*)0);
49 }
50
51 return tile;
52}
53
54/* Compute the size of the tile specified by "tile"
55 * in number of elements and return the result.
56 */
57__isl_give isl_val *gpu_array_tile_size(struct gpu_array_tile *tile)
58{
59 int i;
60 isl_val *size;
61
62 if (!tile)
63 return NULL((void*)0);
64
65 size = isl_val_one(tile->ctx);
66
67 for (i = 0; i < tile->n; ++i)
68 size = isl_val_mul(size, isl_val_copy(tile->bound[i].size));
69
70 return size;
71}