Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-08 Thread Jason Merrill
On 1/8/25 10:16 AM, Jan Hubicka wrote: On Wed, 8 Jan 2025, Jan Hubicka wrote: On Tue, 10 Dec 2024, Jan Hubicka wrote: Hi, int: struct foo { int a; void bar() const; ~foo() { if (a != 42) __builtin_abort (); } }; __attribute__ ((noinline)) void test(const struct foo a

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-08 Thread Jan Hubicka
> On Wed, 8 Jan 2025, Jan Hubicka wrote: > > > > On Tue, 10 Dec 2024, Jan Hubicka wrote: > > > > > > > Hi, > > > > int: > > > > struct foo > > > > { > > > > int a; > > > > void bar() const; > > > > ~foo() > > > > { > > > > if (a != 42) > > > > __builtin_abort (); > > > > } > >

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-08 Thread Richard Biener
On Wed, 8 Jan 2025, Jan Hubicka wrote: > > On Tue, 10 Dec 2024, Jan Hubicka wrote: > > > > > Hi, > > > int: > > > struct foo > > > { > > > int a; > > > void bar() const; > > > ~foo() > > > { > > > if (a != 42) > > > __builtin_abort (); > > > } > > > }; > > > __attribute__ ((no

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-08 Thread Jan Hubicka
> On Tue, 10 Dec 2024, Jan Hubicka wrote: > > > Hi, > > int: > > struct foo > > { > > int a; > > void bar() const; > > ~foo() > > { > > if (a != 42) > > __builtin_abort (); > > } > > }; > > __attribute__ ((noinline)) > > void test(const struct foo a) > > { > > int b = a

Re: Mark const parameters passed by invisible reference as readonly in the function body

2025-01-07 Thread Richard Biener
On Tue, 10 Dec 2024, Jan Hubicka wrote: > Hi, > int: > struct foo > { > int a; > void bar() const; > ~foo() > { > if (a != 42) > __builtin_abort (); > } > }; > __attribute__ ((noinline)) > void test(const struct foo a) > { > int b = a.a; > a.bar(); > if

Mark const parameters passed by invisible reference as readonly in the function body

2024-12-10 Thread Jan Hubicka
Hi, int: struct foo { int a; void bar() const; ~foo() { if (a != 42) __builtin_abort (); } }; __attribute__ ((noinline)) void test(const struct foo a) { int b = a.a; a.bar(); if (a.a != b) __builtin_printf ("optimize me away"); } struct foo is p