[Mesa-dev] [PATCH 10/11] radeonsi: implement streamout shader support

Marek Olšák maraeo at gmail.com
Thu Sep 5 06:02:26 PDT 2013


The warning is wrong and my gcc 4.7.3 doesn't show it. This code at
the beginning of the block where vdata is declared ensures vdata is
always initialized:

if (!num_comps || num_comps > 4)
    continue;

You might be seeing one of these bugs:

http://gcc.gnu.org/bugzilla/buglist.cgi?quicksearch=may%20be%20uninitialized

That said, I'm gonna set vdata to NULL anyway.

Marek

On Thu, Sep 5, 2013 at 11:38 AM, Michel Dänzer <daenzer at debian.org> wrote:
> On Die, 2013-09-03 at 15:23 +0200, Marek Olšák wrote:
>> The shader is responsible for writing to streamout buffers using
>> the TBUFFER_STORE_FORMAT_* instructions.
>>
>> The locations of some input SGPRs and VGPRs are assigned dynamically, because
>> the input SGPRs controlling streamout are not declared if they are not needed,
>> decreasing the indices of all following inputs.
>> ---
>>  src/gallium/drivers/radeonsi/radeonsi_shader.c | 279 ++++++++++++++++++++++++-
>>  src/gallium/drivers/radeonsi/radeonsi_shader.h |   5 +-
>>  src/gallium/drivers/radeonsi/si_state_draw.c   |   7 +-
>>  3 files changed, 276 insertions(+), 15 deletions(-)
>>
>> diff --git a/src/gallium/drivers/radeonsi/radeonsi_shader.c b/src/gallium/drivers/radeonsi/radeonsi_shader.c
>> index 335cd79..92f7cf5 100644
>> --- a/src/gallium/drivers/radeonsi/radeonsi_shader.c
>> +++ b/src/gallium/drivers/radeonsi/radeonsi_shader.c
>
> [...]
>
>> +                     /* Pack the output. */
>> +                     LLVMValueRef vdata;
>> +
>> +                     switch (num_comps) {
>> +                     case 1: /* as i32 */
>> +                             vdata = out[0];
>> +                             break;
>> +                     case 2: /* as v2i32 */
>> +                     case 3: /* as v4i32 (aligned to 4) */
>> +                     case 4: /* as v4i32 */
>> +                             vdata = LLVMGetUndef(LLVMVectorType(i32, util_next_power_of_two(num_comps)));
>> +                             for (j = 0; j < num_comps; j++) {
>> +                                     vdata = LLVMBuildInsertElement(builder, vdata, out[j],
>> +                                                                    LLVMConstInt(i32, j, 0), "");
>> +                             }
>> +                             break;
>> +                     }
>
> This introduces a warning:
>
> .../radeonsi_shader.c: In function 'si_llvm_emit_epilogue':
> .../radeonsi_shader.c:708:15: warning: 'vdata' may be used uninitialized in this function [-Wmaybe-uninitialized]
>   LLVMValueRef args[] = {
>                ^
> .../radeonsi_shader.c:840:17: note: 'vdata' was declared here
>     LLVMValueRef vdata;
>                  ^
>
> Other than that, the series looks good to me.
>
>
> --
> Earthling Michel Dänzer           |                   http://www.amd.com
> Libre software enthusiast         |          Debian, X and DRI developer


More information about the mesa-dev mailing list