https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64895
Renlin Li <renlin at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |renlin at gcc dot gnu.org --- Comment #12 from Renlin Li <renlin at gcc dot gnu.org> --- The same happens for aarch64. > [hjl@gnu-tools-1 gcc]$ cat /tmp/x.c > static int __attribute__((noinline)) > bar (int x) > { > if (x > 4) > return bar (x - 3); > return 0; > } > > int __attribute__((noinline)) > foo (int y) > { > return y + bar (y); > } > There is another problem here actually. In this particular case, bar() is a static function which is not exported. Although -fpic option is provided, pic_offset_table_rtx is not used at all in function foo(). In this case, pic_offset_table_rtx may not be initialized at all. The target hook TARGET_INIT_PIC_REG can be improved to initialize pic register only when necessary. On the other hand, if pic_offset_table_rtx is not used at all, lra_risky_transformations_p should not be true. Does it make sensible? diff --git a/gcc/lra-constraints.c b/gcc/lra-constraints.c index a78edd8..d4a950f 100644 --- a/gcc/lra-constraints.c +++ b/gcc/lra-constraints.c @@ -4221,7 +4221,8 @@ lra_constraints (bool first_p) lra_constraint_iter); changed_p = false; if (pic_offset_table_rtx - && REGNO (pic_offset_table_rtx) >= FIRST_PSEUDO_REGISTER) + && (i = REGNO (pic_offset_table_rtx)) >= FIRST_PSEUDO_REGISTER + && lra_reg_info[i].nrefs > 0) lra_risky_transformations_p = true; else lra_risky_transformations_p = false;