Before the fix for PR 20100 and PR 20115, const and pure calls were both treated
as "const". After the fix, both are treated as "pure" by that fix, but
a .GLOBAL_VAR is unnecessarily created because of the bambam call in:
extern int constfun (void) __attribute__ ((__const__));
extern void bambam (void);
int x (void)
int a = constfun ();
return a + constfun ();
Changing this for Diego.
It deserves mentioning (for the audience) that the right thing happens for
the generated code in the test-case; this problem is mainly an internal
<dnovillo> now, the problem is that if there is a mix of regular and 'const'
functions, we will have created .GLOBAL_VAR
unnecessarily. that's bad.
<dnovillo> testing for !TREE_SIDE_EFFECTS is too broad. We don't want to
consider 'const' functions.
<hp> yes, but I don't know how to create a test-case for *that*
<dnovillo> hp: this one is good enough. we created .GLOBAL_VAR. we shouldn't
have created it.
<dnovillo> the call to bambam shouldn't have a V_MAY_DEF for .GLOBAL_VAR
Fixed in 4.2.
Huh, I still get a .global_var as of yesterday:
# .GLOBAL_VAR_6 = V_MAY_DEF <.GLOBAL_VAR_5>;
Insofar something that doesn't exist anymore can be considered broken, this bug is FIXED:
;; Function x (x)
# BLOCK 2 freq:10000
# PRED: ENTRY [100.0%] (fallthru,exec)
aD.1233_1 = constfunD.1227 ();
# .MEMD.1986_5 = VDEF <.MEMD.1986_4(D)>
# USE = nonlocal
# CLB = nonlocal
D.1983_3 = aD.1233_1 + aD.1233_1;
# SUCC: EXIT [100.0%]