libgomp: Fix up bootstrap in libgomp/target.c due to false positive warning
authorJakub Jelinek <jakub@redhat.com>
Tue, 20 Oct 2020 14:38:24 +0000 (16:38 +0200)
committerJakub Jelinek <jakub@redhat.com>
Tue, 20 Oct 2020 14:38:24 +0000 (16:38 +0200)
commit35f258f4bbba7fa044f90b4f14d1bc942db58089
treea2902ab3016de36a8cef088607d373eb30f9bb1a
parent953277ba3fa39a9285cf89f59932b0169e7f6b9d
libgomp: Fix up bootstrap in libgomp/target.c due to false positive warning

> On 10/20/20 2:11 PM, Tobias Burnus wrote:
>
> > Unfortunately, the committed patch
> > (r11-4121-g1bfc07d150790fae93184a79a7cce897655cb37b)
> > causes build errors.
> >
> > The error seems to be provoked by function cloning – as the code
> > itself looks fine:
> > ...
> >  struct gomp_device_descr *devices_s
> >     = malloc (num_devices * sizeof (struct gomp_device_descr));
> > ...
> >   for (i = 0; i < num_devices; i++)
> >     if (!(devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
> >       devices_s[num_devices_after_openmp++] = devices[i];
>
> gomp_target_init.part.0 ()
> {
> ...
> <bb 2>
>   devices_s_1 = malloc (0);
> ...
>   num_devices.16_67 = num_devices;
> ...
>   if (num_devices.16_67 > 0)
>     goto <bb 3>; [89.00%]
>   else
>     goto <bb 18>; [11.00%]
>
> Which seems to have an ordering problem.

This patch fixes the warning that breaks the bootstrap.

2020-10-20  Jakub Jelinek  <jakub@redhat.com>

* target.c (gomp_target_init): Inside of the function, use automatic
variables corresponding to num_devices, num_devices_openmp and devices
global variables and update the globals only at the end of the
function.
libgomp/target.c