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

            Bug ID: 122033
           Summary: optimize_stack_restore's comment does not match the
                    code
           Product: gcc
           Version: 16.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pinskia at gcc dot gnu.org
  Target Milestone: ---

Take:
```
void g(int*);
void h();
double t;
void f(int a, int b)
{
  {
  int array0[a];
  {
    int array1[b];
    g(array0);
    g(array1);
  }
  t = __builtin_sin(t);
  }
  h();
}
```

Right now optimize_stack_restore will remove the inner most
stack_save/stack_restore even though there is a call to sin.
The comment in front of the function says:
```
   ... Optimize it out
   if there is another __builtin_stack_restore in the same basic
   block and no calls or ASM_EXPRs are in between, or if this block's
   only outgoing edge is to EXIT_BLOCK and there are no calls or
   ASM_EXPRs after this __builtin_stack_restore.
```

But the code will allow all normal builtins except for allocas and
__scrub_leave.

The except for allocas was added due to PR 43220  but the comment was NOT
changed. 

I noticed this while looking into PR 121762.

Reply via email to