GAP Message - remark #30760: (DTRANS) Remove unused field(s) 'e1' from the struct 'str'...

Message



Remove unused field(s) 'e1' from the struct 'str'. The fields: 'f1' were conservatively assumed by the compiler as referenced since their address is taken. [VERIFY] The suggestion is based on the field references in the current compilation. Please make sure that there are no references to these fields across the entire application.
Message emitted even without whole-program recognition in advanced mode

Description

Some unused fields were seen in a class or structure type. If the unused fields can be removed from the structure definition, it will lead to reduced memory usage and better cache utilization since the cache will no longer be filled with unused data.
You must verify that the fields that are reported as unused are not accessed elsewhere in the application. You also need to be careful when removing unused fields if the code relies on the structure fields to be laid out in a specific order.
For example, if the application code uses the address of a field to access other fields, it may stop working once unused fields are removed. Note that such code is not considered valid in the first place.
The unused field analysis considers address taken fields as used. It will report address taken fields also when reporting any unused fields.
The message is emitted if "level of analysis" = extreme or -[Q]guide=4

Example

//unused_field_4.c
struct str {
    int a1, b1, c1, d1, e1, f1;
};

extern struct str sp[];

int hot_func1() {
    int i, ret = 0;

    for (i = 0; i < 1000000; i++) {
        ret += sp[i].a1;
        ret += sp[i].b1;
    }
    return ret;
}

int hot_func2() {
    int ret = 0, i;
    for (i = 0; i < 1000000; i++) {
        ret += sp[i].a1;
        ret -= sp[i].c1;
    }
    return ret;
}

int *gip;

int hot_func3() {
    int ret = 0, i;
    for (i = 0; i < 1000000; i++) {
        ret += sp[i].d1;
    }

    gip = &(sp->f1);
    return ret;
}

For the above example, the compiler generates the following advice with
'icl -Qguide=4 -c unused_field_4.c'. The following advice is emitted only in advanced mode since whole-program is not detected.

 

unused_field_4.c(2): remark #30760: (DTRANS) Remove unused field(s) 'e1' from the struct 'str'. The fields: 'f1' were conservatively assumed by the compiler as referenced since their address is taken. [VERIFY] The suggestion is based on the field references in the current compilation. Please make sure that there are no references to these fields across the entire application.

 

For the above example, if the unused fields can be removed, the only source change needed would be the following:

//unused_field_4.c
struct str {
    int a1, b1, c1, d1, f1;
};

...
...

Optimization Notice in English

标签:
如需更全面地了解编译器优化,请参阅优化注意事项