https://gcc.gnu.org/bugzilla/show_bug.cgi?id=121936
--- Comment #14 from Andrew Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Smith from comment #12)
> But LLVM has (to the best of my
> knowledge) fully addressed this and it doesn't seem to have been a problem
> at scale.
I can reproduce the same issue under LLVM trunk at -O3 with:
```
class Counter {
int count = 0;
public:
int nextCount() { return ++count; }
};
// Will return true if args are evaluated L => R.
[[gnu::used]]
inline bool
check_arg_1_value (int a, int b)
{
return a == 1;
}
[[gnu::used, gnu::noinline,gnu::noipa]]
void g();
#define ll g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g();
g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g(); g();
g(); g(); g();
// Will abort if x == 0 and args are evaluated L => R.
[[gnu::used]]
inline int
depends_on_unpsecified_content (int x)
{
Counter c;
if (check_arg_1_value (c.nextCount(), c.nextCount())
&& x == 0)
__builtin_abort();
ll;
return x;
}
int
m ()
{
if (depends_on_unpsecified_content(0) == 0)
return 5;
return 20;
}
```
Note I needed the large number of calls because LLVM treats gnu::noinline not
as only no inline but rather noipa.
We get:
depends_on_unpsecified_content(int):
stp x29, x30, [sp, #-32]!
str x19, [sp, #16]
mov x29, sp
cbz w0, .LBB1_2
mov w19, w0
If we used gnu::noipa, then GCC does the same as LLVM does on the original
testcase.