GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
ipa

IPA: Fix segfault when inlining fails due to target option mismatch

Fixes a segfault when target-specific inlining restrictions cause compilation to fail.

A bug in the IPA inliner caused a segfault when a target rejected inlining for reasons other than general optimization settings. This occurred because the compiler attempted to print details about the rejected inlining even when the relevant data was null. The fix adds a null check before calling the print function, preventing the crash and improving robustness for targets like MIPS with specific inlining constraints.

In Details

The report_inline_failed_reason function in ipa-inline.cc incorrectly passed TARGET_OPTION_MISMATCH details to cl_target_option_print_diff without checking if the target_opts_for_fn argument was NULL. This commit adds a NULL check, preventing a segfault when a target-specific hook, such as MIPS's mips_can_inline_p, rejects inlining due to incompatible target attributes.

For Context
IPA
Inter-procedural Analysis. A suite of GCC optimization passes that analyze and optimize code across function boundaries.
Inlining
A compiler optimization where the code of a called function is inserted directly at the call site, potentially improving performance by reducing function call overhead.
Segfault
Segmentation Fault. A type of runtime error that occurs when a program attempts to access a memory location that it is not allowed to access.
ICE
Internal Compiler Error. A condition where the compiler encounters an unexpected state or bug during compilation, causing it to abort.
TARGET_OPTION_MISMATCH
A condition where a target's specific requirements or attributes conflict, potentially affecting optimizations like inlining.
TARGET_CAN_INLINE_P
A target-specific hook (function) that determines if a function can be inlined based on target-specific constraints.
-fdump-tree-einline
A GCC flag that enables dumping of the inliner pass's internal representation, useful for debugging inlining decisions.
Filed Under: optimizationipainliningbugfix