1  /* Verify that IPA-CP can clone mark_cell without miscompiling it despite its
       2     type_attributes.  */
       3  /* { dg-do run } */
       4  /* { dg-options "-O3 -fdump-ipa-cp" } */
       5  
       6  
       7  struct PMC {
       8      unsigned flags;
       9  };
      10  
      11  typedef struct Pcc_cell
      12  {
      13      struct PMC *p;
      14      long bla;
      15      long type;
      16  } Pcc_cell;
      17  
      18  int gi;
      19  
      20  extern void abort ();
      21  extern void never_ever(int * interp, struct PMC *pmc)
      22       __attribute__((noinline));
      23  
      24  void never_ever (int * interp, struct PMC *pmc)
      25  {
      26    abort ();
      27  }
      28  
      29  static void mark_cell(int * interp, Pcc_cell *c)
      30          __attribute__((__nonnull__(1)))
      31          __attribute__((noinline));
      32  
      33  static void
      34  mark_cell(int * interp, Pcc_cell *c)
      35  {
      36    if (c && c->type == 4 && c->p
      37        && !(c->p->flags & (1<<14)))
      38      never_ever(interp, c->p);
      39  }
      40  
      41  static void foo(int * interp, Pcc_cell *c)
      42    __attribute__((noinline));
      43  
      44  static void
      45  foo(int * interp, Pcc_cell *c)
      46  {
      47    mark_cell(interp, c);
      48  }
      49  
      50  static struct Pcc_cell *
      51  __attribute__((noinline,noclone))
      52  getnull(void)
      53  {
      54    return (struct Pcc_cell *) 0;
      55  }
      56  
      57  
      58  int main()
      59  {
      60    int i;
      61  
      62    for (i = 0; i < 100; i++)
      63      foo (&gi, getnull ());
      64    return 0;
      65  }
      66  
      67  
      68  /* { dg-final { scan-ipa-dump "Creating a specialized node of mark_cell" "cp" } } */
      69