https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117298

            Bug ID: 117298
           Summary: ICF won't fold unprotoyped function before C23
           Product: gcc
           Version: 15.0
            Status: UNCONFIRMED
          Keywords: missed-optimization
          Severity: normal
          Priority: P3
         Component: ipa
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sjames at gcc dot gnu.org
                CC: jsm28 at gcc dot gnu.org
            Blocks: 87332
  Target Milestone: ---

Joseph mentioned this in
https://inbox.sourceware.org/gcc-patches/9a8c3137-db22-9217-2307-6dffe964a...@redhat.com/.

ICF won't fold an unprototyped function with one that is, e.g.

```
int dup1(void) {
        return 100;
}

int dup2() {
        return 100;
}

int main() {
        __builtin_printf("%d, %d\n", dup1(), dup2());
}
```

With -std=gnu23, because () is treated as (void), ICF recognises they're
duplicates and transforms dup2 into a tail call to dup1:
```
 local analysis of dup2/1
   scanning: retval.3_1 = dup1 (); [tail call]
  scanning: return retval.3_1;
Function is locally const.
```

But with -std=gnu17, we don't.

How much this matters is another question...


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=87332
[Bug 87332] [meta-bug] Issues related to Identical Code Folding (ICF) and Tail
Merging (-ftree-tail-merge)

Reply via email to