mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-12-30 14:35:11 +08:00
middle-end/102518 - avoid invalid GIMPLE during inlining
When inlining we have to avoid mapping a non-lvalue parameter value into a context that prevents the parameter to be a register. Formerly the register were TREE_ADDRESSABLE but now it can be just DECL_NOT_GIMPLE_REG_P. 2021-09-30 Richard Biener <rguenther@suse.de> PR middle-end/102518 * tree-inline.c (setup_one_parameter): Avoid substituting an invariant into contexts where a GIMPLE register is not valid. * gcc.dg/torture/pr102518.c: New testcase.
This commit is contained in:
parent
ea0b5b656a
commit
3a7f20ed26
12
gcc/testsuite/gcc.dg/torture/pr102518.c
Normal file
12
gcc/testsuite/gcc.dg/torture/pr102518.c
Normal file
@ -0,0 +1,12 @@
|
||||
/* { dg-do compile } */
|
||||
|
||||
struct A {
|
||||
int *x;
|
||||
};
|
||||
int i;
|
||||
int f(int *const c) {
|
||||
struct A * b = (struct A *)(&c);
|
||||
return b->x != 0;
|
||||
}
|
||||
void g() { f(&i); }
|
||||
|
@ -3490,7 +3490,11 @@ setup_one_parameter (copy_body_data *id, tree p, tree value, tree fn,
|
||||
/* We may produce non-gimple trees by adding NOPs or introduce invalid
|
||||
sharing when the value is not constant or DECL. And we need to make
|
||||
sure that it cannot be modified from another path in the callee. */
|
||||
if ((is_gimple_min_invariant (value)
|
||||
if (((is_gimple_min_invariant (value)
|
||||
/* When the parameter is used in a context that forces it to
|
||||
not be a GIMPLE register avoid substituting something that
|
||||
is not a decl there. */
|
||||
&& ! DECL_NOT_GIMPLE_REG_P (p))
|
||||
|| (DECL_P (value) && TREE_READONLY (value))
|
||||
|| (auto_var_in_fn_p (value, id->dst_fn)
|
||||
&& !TREE_ADDRESSABLE (value)))
|
||||
|
Loading…
Reference in New Issue
Block a user