https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127217
Bug ID: 127217
Summary: VRP does not honor TARGET_CAN_INLINE_P
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: saaadhu at gcc dot gnu.org
Target Milestone: ---
$ cat repro.c
int __attribute__((mips16)) callee (void) { return 1; }
int __attribute__((nomips16)) caller (void) { return callee(); }
$ mips-unknown-elf-gcc /tmp/repro.c -mabi=32 -mips32r2 -Os
-fdump-tree-all-raw-details -S -o -
<snip>
caller:
<snip>
jr $31
li $2,1 # 0x1
mips.cc's TARGET_CAN_INLINE_P hook returns false if the caller/callee decl have
incompatible mips16/nomips16 attributes, and einline correctly rejects it (a
separate bug crashes the compiler if TARGET_OPTION_MISMATCH and dump_file,
patch on the way).
/tmp/repro.c:2:54: note: Considering inline candidate callee/1.
/tmp/repro.c:2:54: missed: not inlinable: caller/2 -> callee/1, target
specific option mismatch
But evrp proceeds to ignore the target hook's rejection and inlines it anyway
<snip>
Substituting values and folding statements
Folding statement: _3 = callee ();
Using return value range of callee: [irange] int [1, 1]
Using return value range of callee: [irange] int [1, 1]
Queued stmt for removal. Folds to: 1
Folding statement: return _3;
Folded into: return 1;
Removing dead stmt:_3 = callee ();
<snip>
__attribute__((nomips16))
int caller ()
{
<bb 2> :
gimple_return <1>
}
Perhaps tree-ssa-propagate.cc when checking for !gimple_has_side_effects_p,
may_propagate_copy etc.. should also check for inline-ability if
gimple_call(stmt)?