Recreate references with call statements in target clone pass
Fixes an ICE in the target clone pass by correctly creating references for call statements.
This commit addresses an ICE (Internal Compiler Error) in GCC’s target clone pass that occurred due to incorrect reference creation. When redirecting edges, the pass failed to associate references with their corresponding call statements. This patch modifies create_dispatcher_calls in multiple_target.cc to use the call statement variant of create_reference, ensuring that references are properly linked. A new test case pr127023.c is added to cover this specific scenario.
In Details
In the multiple_target.cc file, the create_dispatcher_calls function is responsible for generating dispatch code, which involves creating references. The bug in PR127023 arose because the create_reference function was called without its call_stmt argument, leading to an ODR violation or an invalid reference. This patch ensures that the correct overload of create_reference that accepts a call_stmt is used, thereby fixing the ICE.
- IPA
- Interprocedural Analysis, a phase in GCC that analyzes and optimizes code across function boundaries.
- Target Clone Pass
- A GCC optimization pass that duplicates functions or code sections to enable target-specific optimizations or to create dispatch mechanisms.
- ICE
- Internal Compiler Error, a fatal error that occurs when the compiler encounters an unexpected internal state or inconsistency.
- Reference
- In GCC's internal representation (GENERIC/GIMPLE), a reference can denote an object or a value. Here, it likely refers to a reference to a call statement or function.
- Call Statement
- An internal representation of a function call within GCC's GIMPLE intermediate language.
- ODR
- One Definition Rule, a C++ rule stating that an entity can have at most one definition in a program. Violations can lead to link-time or runtime errors, especially with LTO.