From: Jonas Hansen <[email protected]>
The name recorded by .DEFERRED_INIT can stop identifying its destination
after inlining or LTO renumbers anonymous declarations. This makes
warn_uninit diagnose an artificial initialization store as an
uninitialized read, notably with sanitizers and -ftrivial-auto-var-init.
Use the initialized declaration's address as diagnostic metadata instead
of a name string. Preserve its identity through declaration remapping
and LTO streaming, and compare declarations in warn_uninit. Keep this
operand unevaluated and avoid making the object addressable or preventing
SSA promotion. Update scalar replacement, nested-function lowering,
parallelization and offload handling accordingly.
Prevent conditional operation factoring from turning the diagnostic
address into a computed pointer, and omit metadata-only references from
declaration enumeration used by debug comparison. Document the operand
contract and add coverage for inlining, cloning, LTO, SSA promotion,
parallelization, nested functions, debug comparison and both factoring
paths, with zero and pattern initialization.
gcc/ChangeLog:
PR middle-end/124380
* config/avr/avr-passes.cc (avr_pass_has::execute): Initialize
walk_stmt_info completely.
* doc/ifn.texi (IFN_DEFERRED_INIT): Document operands, semantics
and diagnostic declaration-address handling.
* gimple-match-exports.cc (factor_operation_ok): Preserve the
diagnostic object address when factoring deferred initialization.
* gimple-walk.cc (walk_gimple_op): Support skipping diagnostic
operands.
(walk_stmt_load_store_addr_ops): Ignore the diagnostic operand
of deferred initialization.
* gimple-walk.h (walk_stmt_info): Add skip_diagnostic_operands.
* gimplify-me.cc (gimple_regimplify_operands): Preserve the
diagnostic object address.
* gimplify.cc (gimple_add_init_for_auto_var): Pass the declaration
address instead of its name.
(warn_switch_unreachable_and_auto_init_r): Diagnose the declaration.
(gimplify_call_expr, gimplify_modify_expr): Do not gimplify the
diagnostic address operand.
* internal-fn.cc (expand_DEFERRED_INIT): Update the operand comment.
* omp-offload.cc (execute_oacc_device_lower): Avoid pointer
conversion for deferred initialization metadata.
* tree-cfg.cc (verify_gimple_call): Verify the diagnostic object
argument to deferred initialization.
* tree-dfa.cc (dump_enumerated_decls): Skip diagnostic operands.
* tree-nested.cc (walk_body): Likewise.
* tree-parloops.cc (eliminate_local_variables_stmt): Likewise.
(separate_decls_in_region_stmt): Remap deferred initialization's
diagnostic declaration to its parallel-region copy.
* tree-sra.cc (scan_function): Ignore diagnostic object addresses.
(generate_subtree_deferred_init, sra_modify_deferred_init): Use
the scalar replacement's declaration address.
* tree-ssa-operands.cc (operands_scanner::parse_ssa_operands): Do
not mark deferred initialization's diagnostic object addressable.
* tree-ssa-uninit.cc (warn_uninit): Identify deferred initialization
objects by declaration instead of name strings. Recognize nested
frame initialization stores through DECL_VALUE_EXPR.
(check_defs): Update the deferred initialization example.
gcc/cp/ChangeLog:
PR middle-end/124380
* decl.cc (build_deferred_init_call): Pass the declaration address
instead of its name. Update related examples.
gcc/testsuite/ChangeLog:
PR middle-end/124380
* c-c++-common/auto-init-1.c: Adjust dump expectations.
* c-c++-common/auto-init-2.c: Likewise.
* c-c++-common/auto-init-3.c: Likewise.
* c-c++-common/auto-init-4.c: Likewise.
* c-c++-common/auto-init-5.c: Likewise.
* c-c++-common/auto-init-6.c: Likewise.
* c-c++-common/auto-init-7.c: Likewise.
* c-c++-common/auto-init-8.c: Likewise.
* c-c++-common/auto-init-9.c: Likewise.
* c-c++-common/auto-init-10.c: Likewise.
* c-c++-common/auto-init-11.c: Likewise.
* c-c++-common/auto-init-12.c: Likewise.
* c-c++-common/auto-init-13.c: Likewise.
* c-c++-common/auto-init-14.c: Likewise.
* c-c++-common/auto-init-15.c: Likewise.
* c-c++-common/auto-init-16.c: Likewise.
* c-c++-common/auto-init-esra.c: Likewise. Check SSA promotion.
* c-c++-common/auto-init-padding-1.c: Adjust dump expectations.
* c-c++-common/auto-init-ifcvt-1.c: New test.
* c-c++-common/auto-init-ifcvt-2.c: New test.
* c-c++-common/auto-init-phiopt-1.c: New test.
* c-c++-common/auto-init-phiopt-2.c: New test.
* g++.dg/asan/auto-init-uninit-1.C: New test.
* g++.dg/asan/auto-init-uninit-2.C: New test.
* g++.dg/asan/auto-init-uninit-3.C: New test.
* g++.dg/lto/auto-init-uninit_0.C: New test.
* g++.dg/opt/auto-init-debug-1.C: New test.
* g++.dg/opt/auto-init-debug-2.C: New test.
* g++.dg/tree-ssa/auto-init-parloops-1.C: New test.
* g++.dg/tree-ssa/auto-init-parloops-2.C: New test.
* g++.dg/uninit-pr124380.C: New test.
* gcc.dg/auto-init-nested-1.c: New test.
* gcc.dg/auto-init-nested-2.c: New test.
* gcc.dg/auto-init-nested-3.c: New test.
Signed-off-by: Jonas Hansen <[email protected]>
---
Fixes the false uninitialized warning in [PR
middle-end/124380](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124380).
Replace the name-string operand of `.DEFERRED_INIT` with a declaration address
used only as diagnostic metadata. Declaration remapping and LTO streaming
preserve its identity, allowing `warn_uninit` to distinguish artificial
initialization stores from genuine uninitialized uses.
The metadata address is never evaluated and does not make the object
addressable or prevent SSA promotion.
Changes since v2:
- Replace string/UID remapping with declaration identity, following Richard
Biener's suggested direction.
- Handle gimplification, scalar replacement, nested functions, parallelization
and offload transformations.
- Preserve the metadata through conditional factoring and loop if-conversion.
- Document the IL contract and add regression coverage, including zero and
pattern initialization.
Validation on x86_64-pc-linux-gnu:
- Fresh three-stage bootstraps of this revision and its parent with all default
languages and `--disable-multilib`; both stage comparisons pass.
- Full compiler/runtime regression suite: 629,527 passes versus 629,463 in the
baseline. The same 84 failures and 24 unexpected passes remain; no new
regressions.
- `check-c++-all`: 622,180 passes versus 622,060 in the baseline, with the same
14 failures and one unexpected pass. Module-harness coverage differences were
checked separately: all 35 affected CMI checks pass on both compilers, with 110
passes per compiler in the isolated reruns.
- All 536 Automake results match: 535 passes and one unchanged skip
(`t-addaddmul`).
- Info and DVI manuals build successfully.
- Twelve focused suites: 4,057 passes, 30 expected failures, 16 unsupported
tests, and no unexpected results.
- All 144 reproducer configurations pass.
- Genuine warnings remain preserved across 192 configurations; machine-code
comparisons found no differences.
- Numeric assembly comparisons at O2/Os, with and without sanitizers, found no
differences.
This is a forge pull request published on the gcc-patches mailing list mailing
list
as requested by Jonas Hansen via Sourceware Forge
<[email protected]>.
Forge discussion: https://forge.sourceware.org/gcc/gcc/pulls/252
Get it locally using:
```
git fetch forge-upstream "+refs/versioned_pull/252/*:refs/versioned_pull/252/*"
git switch -c "pr-252-v3" "refs/versioned_pull/252/3/head"
```
Or, download the patch at: https://forge.sourceware.org/gcc/gcc/pulls/252.diff
Created on: 2026-10-22 05:19:48+00:00
Latest update: 2026-10-30 11:50:05+00:00
Changes: 51 changed files, 440 additions, 178 deletions
Head revision: hrjonashansen/gcc ref fix-uninit-inlined-temporary commit
7923ab0cfa2f4f697a88df45d84de270a026c11d
Base revision: gcc/gcc ref trunk commit
2d1f1bc18a59c0f106c551304ac459ad7781a711 r17-5299-g2d1f1bc18a59c0
Merge base: 2d1f1bc18a59c0f106c551304ac459ad7781a711
Requested Reviewers: RichardBiener, pinskia
Changed files:
- A: gcc/testsuite/c-c++-common/auto-init-ifcvt-1.c
- A: gcc/testsuite/c-c++-common/auto-init-ifcvt-2.c
- A: gcc/testsuite/c-c++-common/auto-init-phiopt-1.c
- A: gcc/testsuite/c-c++-common/auto-init-phiopt-2.c
- A: gcc/testsuite/g++.dg/asan/auto-init-uninit-1.C
- A: gcc/testsuite/g++.dg/asan/auto-init-uninit-2.C
- A: gcc/testsuite/g++.dg/asan/auto-init-uninit-3.C
- A: gcc/testsuite/g++.dg/lto/auto-init-uninit_0.C
- A: gcc/testsuite/g++.dg/opt/auto-init-debug-1.C
- A: gcc/testsuite/g++.dg/opt/auto-init-debug-2.C
- A: gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-1.C
- A: gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-2.C
- A: gcc/testsuite/g++.dg/uninit-pr124380.C
- A: gcc/testsuite/gcc.dg/auto-init-nested-1.c
- A: gcc/testsuite/gcc.dg/auto-init-nested-2.c
- A: gcc/testsuite/gcc.dg/auto-init-nested-3.c
- M: gcc/config/avr/avr-passes.cc
- M: gcc/cp/decl.cc
- M: gcc/doc/ifn.texi
- M: gcc/gimple-match-exports.cc
- M: gcc/gimple-walk.cc
- M: gcc/gimple-walk.h
- M: gcc/gimplify-me.cc
- M: gcc/gimplify.cc
- M: gcc/internal-fn.cc
- M: gcc/omp-offload.cc
- M: gcc/testsuite/c-c++-common/auto-init-1.c
- M: gcc/testsuite/c-c++-common/auto-init-10.c
- M: gcc/testsuite/c-c++-common/auto-init-11.c
- M: gcc/testsuite/c-c++-common/auto-init-12.c
- M: gcc/testsuite/c-c++-common/auto-init-13.c
- M: gcc/testsuite/c-c++-common/auto-init-14.c
- M: gcc/testsuite/c-c++-common/auto-init-15.c
- M: gcc/testsuite/c-c++-common/auto-init-16.c
- M: gcc/testsuite/c-c++-common/auto-init-2.c
- M: gcc/testsuite/c-c++-common/auto-init-3.c
- M: gcc/testsuite/c-c++-common/auto-init-4.c
- M: gcc/testsuite/c-c++-common/auto-init-5.c
- M: gcc/testsuite/c-c++-common/auto-init-6.c
- M: gcc/testsuite/c-c++-common/auto-init-7.c
- M: gcc/testsuite/c-c++-common/auto-init-8.c
- M: gcc/testsuite/c-c++-common/auto-init-9.c
- M: gcc/testsuite/c-c++-common/auto-init-esra.c
- M: gcc/testsuite/c-c++-common/auto-init-padding-1.c
- M: gcc/tree-cfg.cc
- M: gcc/tree-dfa.cc
- M: gcc/tree-nested.cc
- M: gcc/tree-parloops.cc
- M: gcc/tree-sra.cc
- M: gcc/tree-ssa-operands.cc
- M: gcc/tree-ssa-uninit.cc
gcc/config/avr/avr-passes.cc | 2 +-
gcc/cp/decl.cc | 20 +---
gcc/doc/ifn.texi | 24 ++++-
gcc/gimple-match-exports.cc | 7 ++
gcc/gimple-walk.cc | 7 ++
gcc/gimple-walk.h | 5 +
gcc/gimplify-me.cc | 5 +
gcc/gimplify.cc | 41 ++++----
gcc/internal-fn.cc | 2 +-
gcc/omp-offload.cc | 8 +-
gcc/testsuite/c-c++-common/auto-init-1.c | 20 ++--
gcc/testsuite/c-c++-common/auto-init-10.c | 2 +-
gcc/testsuite/c-c++-common/auto-init-11.c | 2 +-
gcc/testsuite/c-c++-common/auto-init-12.c | 2 +-
gcc/testsuite/c-c++-common/auto-init-13.c | 4 +-
gcc/testsuite/c-c++-common/auto-init-14.c | 4 +-
gcc/testsuite/c-c++-common/auto-init-15.c | 2 +-
gcc/testsuite/c-c++-common/auto-init-16.c | 2 +-
gcc/testsuite/c-c++-common/auto-init-2.c | 20 ++--
gcc/testsuite/c-c++-common/auto-init-3.c | 6 +-
gcc/testsuite/c-c++-common/auto-init-4.c | 6 +-
gcc/testsuite/c-c++-common/auto-init-5.c | 6 +-
gcc/testsuite/c-c++-common/auto-init-6.c | 6 +-
gcc/testsuite/c-c++-common/auto-init-7.c | 8 +-
gcc/testsuite/c-c++-common/auto-init-8.c | 8 +-
gcc/testsuite/c-c++-common/auto-init-9.c | 4 +-
gcc/testsuite/c-c++-common/auto-init-esra.c | 15 ++-
.../c-c++-common/auto-init-ifcvt-1.c | 24 +++++
.../c-c++-common/auto-init-ifcvt-2.c | 5 +
.../c-c++-common/auto-init-padding-1.c | 2 +-
.../c-c++-common/auto-init-phiopt-1.c | 18 ++++
.../c-c++-common/auto-init-phiopt-2.c | 4 +
.../g++.dg/asan/auto-init-uninit-1.C | 24 +++++
.../g++.dg/asan/auto-init-uninit-2.C | 4 +
.../g++.dg/asan/auto-init-uninit-3.C | 26 ++++++
gcc/testsuite/g++.dg/lto/auto-init-uninit_0.C | 28 ++++++
gcc/testsuite/g++.dg/opt/auto-init-debug-1.C | 5 +
gcc/testsuite/g++.dg/opt/auto-init-debug-2.C | 4 +
.../g++.dg/tree-ssa/auto-init-parloops-1.C | 23 +++++
.../g++.dg/tree-ssa/auto-init-parloops-2.C | 8 ++
gcc/testsuite/g++.dg/uninit-pr124380.C | 27 ++++++
gcc/testsuite/gcc.dg/auto-init-nested-1.c | 23 +++++
gcc/testsuite/gcc.dg/auto-init-nested-2.c | 4 +
gcc/testsuite/gcc.dg/auto-init-nested-3.c | 12 +++
gcc/tree-cfg.cc | 10 +-
gcc/tree-dfa.cc | 2 +
gcc/tree-nested.cc | 1 +
gcc/tree-parloops.cc | 13 +++
gcc/tree-sra.cc | 15 +--
gcc/tree-ssa-operands.cc | 5 +-
gcc/tree-ssa-uninit.cc | 93 +++++--------------
51 files changed, 440 insertions(+), 178 deletions(-)
create mode 100644 gcc/testsuite/c-c++-common/auto-init-ifcvt-1.c
create mode 100644 gcc/testsuite/c-c++-common/auto-init-ifcvt-2.c
create mode 100644 gcc/testsuite/c-c++-common/auto-init-phiopt-1.c
create mode 100644 gcc/testsuite/c-c++-common/auto-init-phiopt-2.c
create mode 100644 gcc/testsuite/g++.dg/asan/auto-init-uninit-1.C
create mode 100644 gcc/testsuite/g++.dg/asan/auto-init-uninit-2.C
create mode 100644 gcc/testsuite/g++.dg/asan/auto-init-uninit-3.C
create mode 100644 gcc/testsuite/g++.dg/lto/auto-init-uninit_0.C
create mode 100644 gcc/testsuite/g++.dg/opt/auto-init-debug-1.C
create mode 100644 gcc/testsuite/g++.dg/opt/auto-init-debug-2.C
create mode 100644 gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-1.C
create mode 100644 gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-2.C
create mode 100644 gcc/testsuite/g++.dg/uninit-pr124380.C
create mode 100644 gcc/testsuite/gcc.dg/auto-init-nested-1.c
create mode 100644 gcc/testsuite/gcc.dg/auto-init-nested-2.c
create mode 100644 gcc/testsuite/gcc.dg/auto-init-nested-3.c
diff --git a/gcc/config/avr/avr-passes.cc b/gcc/config/avr/avr-passes.cc
index d2b2d8421e083..072c25a884f56 100644
--- a/gcc/config/avr/avr-passes.cc
+++ b/gcc/config/avr/avr-passes.cc
@@ -5635,7 +5635,7 @@ public:
unsigned int execute (function *func) final override
{
- walk_stmt_info wi;
+ walk_stmt_info wi = {};
hash_set<tree> hset;
wi.pset = &hset;
diff --git a/gcc/cp/decl.cc b/gcc/cp/decl.cc
index 593e67fd03b3e..af576cf8614d5 100644
--- a/gcc/cp/decl.cc
+++ b/gcc/cp/decl.cc
@@ -4019,21 +4019,11 @@ build_deferred_init_call (tree decl)
tree init_type_arg = build_int_cst (integer_type_node,
(int) flag_auto_var_init);
location_t loc = DECL_SOURCE_LOCATION (decl);
- tree decl_name;
-
- if (DECL_NAME (decl))
- decl_name = build_string_literal (DECL_NAME (decl));
- else
- {
- char decl_name_anonymous[3 + (HOST_BITS_PER_INT + 2) / 3];
- sprintf (decl_name_anonymous, "D.%u", DECL_UID (decl));
- decl_name = build_string_literal (decl_name_anonymous);
- }
tree call = build_call_expr_internal_loc (loc, IFN_DEFERRED_INIT,
TREE_TYPE (decl), 3,
decl_size_arg, init_type_arg,
- decl_name);
+ build_fold_addr_expr (decl));
tree ret = build2_loc (loc, MODIFY_EXPR, void_type_node, decl, call);
return build_stmt (loc, EXPR_STMT, ret);
}
@@ -4042,10 +4032,10 @@ build_deferred_init_call (tree decl)
if (0)
{
l1:
- v4 = .DEFERRED_INIT (sizeof (v4), ?, "v4");
- v3 = .DEFERRED_INIT (sizeof (v3), ?, "v3");
- v2 = .DEFERRED_INIT (sizeof (v2), ?, "v2");
- v1 = .DEFERRED_INIT (sizeof (v1), ?, "v1");
+ v4 = .DEFERRED_INIT (sizeof (v4), ?, &v4);
+ v3 = .DEFERRED_INIT (sizeof (v3), ?, &v3);
+ v2 = .DEFERRED_INIT (sizeof (v2), ?, &v2);
+ v1 = .DEFERRED_INIT (sizeof (v1), ?, &v1);
}
and return l1 label, or if it already exists, assert it has the
.DEFERRED_INIT calls for the right decls in the right order and
diff --git a/gcc/doc/ifn.texi b/gcc/doc/ifn.texi
index d80e089685a3c..39cc9c81bf602 100644
--- a/gcc/doc/ifn.texi
+++ b/gcc/doc/ifn.texi
@@ -1389,8 +1389,28 @@ lowered to PHI nodes.
@cindex @code{IFN_DEFERRED_INIT} internal function
@item @samp{IFN_DEFERRED_INIT}
-The @code{IFN_DEFERRED_INIT} internal function is expanded by the
-@code{expand_DEFERRED_INIT} function.
+@smallexample
+@var{lhs} = .DEFERRED_INIT (@var{size}, @var{init_type}, @var{object})
+@end smallexample
+
+Represent initialization for @option{-ftrivial-auto-var-init} or C++26.
+@var{size} is the object's size in bytes; @var{init_type} encodes an
+@code{auto_init_type} selecting zero or pattern initialization.
+The @code{AUTO_INIT_CXX26} flag requires all uses of the result to have the
+same value; otherwise optimizers can treat the result as undefined.
+The result is still treated as uninitialized for diagnostics.
+The call is expanded by @code{expand_DEFERRED_INIT}.
+
+@var{object} is the address of the initialized declaration. It preserves
+the variable's identity for diagnostics and identifies the artificial
+initialization store. This operand is diagnostic metadata, is not
+evaluated, and must not set @code{TREE_ADDRESSABLE} or
+@code{DECL_NOT_GIMPLE_REG_P}, or inhibit SSA promotion.
+
+Declaration remapping, LTO streaming and scalar replacement must preserve
+or update this reference. Storage-lowering walks must not materialize
+its address. Nested-function lowering retains the original declaration,
+whose @code{DECL_VALUE_EXPR} describes its location in the frame.
@cindex @code{IFN_ACCESS_WITH_SIZE} internal function
@item @samp{IFN_ACCESS_WITH_SIZE}
diff --git a/gcc/gimple-match-exports.cc b/gcc/gimple-match-exports.cc
index 8077bbad165a1..f7a96a2808cdf 100644
--- a/gcc/gimple-match-exports.cc
+++ b/gcc/gimple-match-exports.cc
@@ -1581,6 +1581,13 @@ factor_operation_ok (code_helper code, int opnum,
&& code.is_internal_fn ())
switch (internal_fn (code))
{
+ /* The object address is diagnostic metadata and must remain an
+ address of a declaration rather than a computed pointer. */
+ case IFN_DEFERRED_INIT:
+ if (opnum == 2)
+ return false;
+ break;
+
/* For these internal functions, gimple_location is an implicit
parameter, which will be used explicitly after expansion.
Merging these statements may cause confusing line numbers in
diff --git a/gcc/gimple-walk.cc b/gcc/gimple-walk.cc
index e36d9f2a0083c..eaf391f0e4af6 100644
--- a/gcc/gimple-walk.cc
+++ b/gcc/gimple-walk.cc
@@ -258,6 +258,9 @@ walk_gimple_op (gimple *stmt, walk_tree_fn callback_op,
for (i = 0; i < gimple_call_num_args (stmt); i++)
{
+ if (wi && wi->skip_diagnostic_operands && i == 2
+ && gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
+ continue;
if (wi)
wi->val_only
= is_gimple_reg_type (TREE_TYPE (gimple_call_arg (stmt, i)));
@@ -854,6 +857,10 @@ walk_stmt_load_store_addr_ops (gimple *stmt, void *data,
if (visit_load || visit_addr)
for (i = 0; i < gimple_call_num_args (call_stmt); ++i)
{
+ /* The third .DEFERRED_INIT operand only identifies the object
+ for diagnostics. It is neither a load nor an address escape. */
+ if (gimple_call_internal_p (call_stmt, IFN_DEFERRED_INIT) && i == 2)
+ continue;
tree arg = gimple_call_arg (call_stmt, i);
if (visit_addr
&& TREE_CODE (arg) == ADDR_EXPR)
diff --git a/gcc/gimple-walk.h b/gcc/gimple-walk.h
index 983494fac4a42..4847f74ed51cc 100644
--- a/gcc/gimple-walk.h
+++ b/gcc/gimple-walk.h
@@ -69,6 +69,11 @@ struct walk_stmt_info
/* True if we're interested in location information. */
bool want_locations : 1;
+ /* Do not walk operands that only identify an object for diagnostics,
+ such as the third .DEFERRED_INIT argument. Storage-lowering walks
+ should set this; declaration-copying walks must still remap them. */
+ bool skip_diagnostic_operands : 1;
+
/* True if we've removed the statement that was processed. */
bool removed_stmt : 1;
};
diff --git a/gcc/gimplify-me.cc b/gcc/gimplify-me.cc
index 145d8daff7c7d..941a1e172079d 100644
--- a/gcc/gimplify-me.cc
+++ b/gcc/gimplify-me.cc
@@ -225,6 +225,11 @@ gimple_regimplify_operands (gimple *stmt,
gimple_stmt_iterator *gsi_p)
num_ops = gimple_num_ops (stmt);
for (i = num_ops; i > 0; i--)
{
+ /* Do not make the diagnostic object address in .DEFERRED_INIT
+ addressable when regimplifying a copied or modified call. */
+ if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT)
+ && gimple_op_ptr (stmt, i - 1) == gimple_call_arg_ptr (stmt, 2))
+ continue;
tree op = gimple_op (stmt, i - 1);
if (op == NULL_TREE)
continue;
diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc
index 94d71d71fc27a..a2f6cecdad72e 100644
--- a/gcc/gimplify.cc
+++ b/gcc/gimplify.cc
@@ -1901,9 +1901,9 @@ force_labels_r (tree *tp, int *walk_subtrees, void *data
ATTRIBUTE_UNUSED)
Build a call to internal const function DEFERRED_INIT:
1st argument: SIZE of the DECL;
2nd argument: INIT_TYPE;
- 3rd argument: NAME of the DECL;
+ 3rd argument: address of the DECL, for diagnostics only.
- as LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the DECL). */
+ as LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, &DECL). */
static void
gimple_add_init_for_auto_var (tree decl,
@@ -1916,21 +1916,11 @@ gimple_add_init_for_auto_var (tree decl,
const location_t loc = DECL_SOURCE_LOCATION (decl);
tree decl_size = TYPE_SIZE_UNIT (TREE_TYPE (decl));
tree init_type_node = build_int_cst (integer_type_node, (int) init_type);
- tree decl_name;
-
- if (DECL_NAME (decl))
- decl_name = build_string_literal (DECL_NAME (decl));
- else
- {
- char decl_name_anonymous[3 + (HOST_BITS_PER_INT + 2) / 3];
- sprintf (decl_name_anonymous, "D.%u", DECL_UID (decl));
- decl_name = build_string_literal (decl_name_anonymous);
- }
tree call = build_call_expr_internal_loc (loc, IFN_DEFERRED_INIT,
TREE_TYPE (decl), 3,
decl_size, init_type_node,
- decl_name);
+ build_fold_addr_expr (decl));
gimplify_assign (decl, call, seq_p);
}
@@ -2266,7 +2256,7 @@ warn_switch_unreachable_and_auto_init_r
(gimple_stmt_iterator *gsi_p,
present and non-zero;
case 3: a gimple assign store right after the call to .DEFERRED_INIT
that has the LHS of .DEFERRED_INIT as the RHS as following:
- _1 = .DEFERRED_INIT (4, 2, &"i1"[0]);
+ _1 = .DEFERRED_INIT (4, 2, &i1);
i1 = _1.
case 3 is handled above in the GIMPLE_ASSIGN case. */
if (flag_auto_var_init > AUTO_INIT_UNINITIALIZED
@@ -2274,14 +2264,11 @@ warn_switch_unreachable_and_auto_init_r
(gimple_stmt_iterator *gsi_p,
{
if (warn_trivial_auto_var_init)
{
- /* Get the variable name from the 3rd argument of call. */
- tree var_name = gimple_call_arg (stmt, 2);
- var_name = TREE_OPERAND (TREE_OPERAND (var_name, 0), 0);
- const char *var_name_str = TREE_STRING_POINTER (var_name);
+ tree var = TREE_OPERAND (gimple_call_arg (stmt, 2), 0);
warning_at (gimple_location (stmt), OPT_Wtrivial_auto_var_init,
- "%qs cannot be initialized with "
- "%<-ftrivial-auto-var_init%>", var_name_str);
+ "%qD cannot be initialized with "
+ "%<-ftrivial-auto-var_init%>", var);
}
break;
}
@@ -4600,8 +4587,11 @@ gimplify_call_expr (tree *expr_p, gimple_seq *pre_p,
fallback_t fallback)
for (i = 0; i < nargs; i++)
{
- gimplify_arg (&CALL_EXPR_ARG (*expr_p, i), pre_p,
- EXPR_LOCATION (*expr_p));
+ /* The object address is diagnostic metadata and must not make
+ its declaration addressable. */
+ if (ifn != IFN_DEFERRED_INIT || i != 2)
+ gimplify_arg (&CALL_EXPR_ARG (*expr_p, i), pre_p,
+ EXPR_LOCATION (*expr_p));
vargs.quick_push (CALL_EXPR_ARG (*expr_p, i));
}
@@ -7454,8 +7444,11 @@ gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p,
gimple_seq *post_p,
for (i = 0; i < nargs; i++)
{
- gimplify_arg (&CALL_EXPR_ARG (*from_p, i), pre_p,
- EXPR_LOCATION (*from_p));
+ /* The object address is diagnostic metadata and must not make
+ its declaration addressable. */
+ if (ifn != IFN_DEFERRED_INIT || i != 2)
+ gimplify_arg (&CALL_EXPR_ARG (*from_p, i), pre_p,
+ EXPR_LOCATION (*from_p));
vargs.quick_push (CALL_EXPR_ARG (*from_p, i));
}
call_stmt = gimple_build_call_internal_vec (ifn, vargs);
diff --git a/gcc/internal-fn.cc b/gcc/internal-fn.cc
index 45ad08d2cf612..ae96bfd4934ce 100644
--- a/gcc/internal-fn.cc
+++ b/gcc/internal-fn.cc
@@ -3476,7 +3476,7 @@ expand_UNIQUE (internal_fn, gcall *stmt)
}
/* Expand the IFN_DEFERRED_INIT function:
- LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the DECL);
+ LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, &DECL);
Initialize the LHS with zero/pattern according to its second argument
INIT_TYPE:
diff --git a/gcc/omp-offload.cc b/gcc/omp-offload.cc
index f39635712e48f..c195077bca3f1 100644
--- a/gcc/omp-offload.cc
+++ b/gcc/omp-offload.cc
@@ -2411,8 +2411,9 @@ execute_oacc_device_lower ()
that conversion substituted in place of the original ADDR_EXPR node.
Which of these is done depends on the gimple statement being processed.
- At present atomic operations and inline asms use (1), and everything else
- uses (2). At least on AMD GCN, there are atomic operations that work
+ At present atomic operations, inline asms and diagnostic object addresses
+ in .DEFERRED_INIT use (1), and everything else uses (2).
+ At least on AMD GCN, there are atomic operations that work
directly in the LDS address space.
COMPONENT_REFS, ARRAY_REFS and plain VAR_DECLs are also rewritten to use
@@ -2433,7 +2434,8 @@ execute_oacc_device_lower ()
info.avoid_pointer_conversion
= (is_gimple_call (stmt)
&& is_sync_builtin_call (as_a <gcall *> (stmt)))
- || gimple_code (stmt) == GIMPLE_ASM;
+ || gimple_code (stmt) == GIMPLE_ASM
+ || gimple_call_internal_p (stmt, IFN_DEFERRED_INIT);
info.stmt = stmt;
info.modified = false;
info.adjusted_vars = &adjusted_vars;
diff --git a/gcc/testsuite/c-c++-common/auto-init-1.c
b/gcc/testsuite/c-c++-common/auto-init-1.c
index 96dd4be32a8d4..6126cda9f089e 100644
--- a/gcc/testsuite/c-c++-common/auto-init-1.c
+++ b/gcc/testsuite/c-c++-common/auto-init-1.c
@@ -29,13 +29,13 @@ void foo()
return;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, \[26],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, \[26],
\&\"temp2\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, \[26],
\&\"temp3\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, \[26],
\&\"temp4\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, \[26],
\&\"temp5\"" "gimple" { target ilp32 } } } */
-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, \[26],
\&\"temp5\"" "gimple" { target lp64 } } } */
-/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, \[26],
\&\"temp6\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, \[26],
\&\"temp7\"" "gimple" { target ilp32 } } } */
-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, \[26],
\&\"temp7\"" "gimple" { target lp64 } } } */
-/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, \[26],
\&\"temp8\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, \[26], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, \[26], \&temp2"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, \[26], \&temp3"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, \[26], \&temp4"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, \[26], \&temp5"
"gimple" { target ilp32 } } } */
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, \[26], \&temp5"
"gimple" { target lp64 } } } */
+/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, \[26], \&temp6"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, \[26], \&temp7"
"gimple" { target ilp32 } } } */
+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, \[26], \&temp7"
"gimple" { target lp64 } } } */
+/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, \[26], \&temp8"
"gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-10.c
b/gcc/testsuite/c-c++-common/auto-init-10.c
index 4ec0a25940703..235362246ea77 100644
--- a/gcc/testsuite/c-c++-common/auto-init-10.c
+++ b/gcc/testsuite/c-c++-common/auto-init-10.c
@@ -18,5 +18,5 @@ void foo()
return;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, \[15],
\&\"temp1\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, \[15], \&temp1"
"gimple" } } */
/* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-11.c
b/gcc/testsuite/c-c++-common/auto-init-11.c
index 2114474e68aab..6cfd9b2551f6a 100644
--- a/gcc/testsuite/c-c++-common/auto-init-11.c
+++ b/gcc/testsuite/c-c++-common/auto-init-11.c
@@ -11,4 +11,4 @@ void foo(int n)
return;
}
-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[26], \&\"arr\""
"gimple" } } */
+/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[26], \&arr"
"gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-12.c
b/gcc/testsuite/c-c++-common/auto-init-12.c
index 4eb0f6e507644..65a11f1b4beb6 100644
--- a/gcc/testsuite/c-c++-common/auto-init-12.c
+++ b/gcc/testsuite/c-c++-common/auto-init-12.c
@@ -11,4 +11,4 @@ void foo(int n)
return;
}
-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[15], \&\"arr\""
"gimple" } } */
+/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[15], \&arr"
"gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-13.c
b/gcc/testsuite/c-c++-common/auto-init-13.c
index b53b2b98e8777..5f8ba25f38925 100644
--- a/gcc/testsuite/c-c++-common/auto-init-13.c
+++ b/gcc/testsuite/c-c++-common/auto-init-13.c
@@ -19,5 +19,5 @@ int foo()
return d.b + var.bar.b;
}
-/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, \[15], \&\"d\""
"gimple" } } */
-/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, \[15], \&\"var\""
"gimple" } } */
+/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, \[15], \&d" "gimple"
} } */
+/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, \[15], \&var"
"gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-14.c
b/gcc/testsuite/c-c++-common/auto-init-14.c
index 90fd57a537f40..0506325ff2e72 100644
--- a/gcc/testsuite/c-c++-common/auto-init-14.c
+++ b/gcc/testsuite/c-c++-common/auto-init-14.c
@@ -19,5 +19,5 @@ int foo()
return d.b + var.bar.b;
}
-/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, \[26], \&\"d\""
"gimple" } } */
-/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, \[26], \&\"var\""
"gimple" } } */
+/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, \[26], \&d" "gimple"
} } */
+/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, \[26], \&var"
"gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-15.c
b/gcc/testsuite/c-c++-common/auto-init-15.c
index f389b5aa544f6..fdc01140f4cd4 100644
--- a/gcc/testsuite/c-c++-common/auto-init-15.c
+++ b/gcc/testsuite/c-c++-common/auto-init-15.c
@@ -10,4 +10,4 @@ void foo(int a)
g(x);
}
-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[26], \&\"x\""
"gimple" } } */
+/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[26], \&x" "gimple"
} } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-16.c
b/gcc/testsuite/c-c++-common/auto-init-16.c
index b6cc7506c3c23..418d4fdc15d6d 100644
--- a/gcc/testsuite/c-c++-common/auto-init-16.c
+++ b/gcc/testsuite/c-c++-common/auto-init-16.c
@@ -10,4 +10,4 @@ void foo(int a)
g(x);
}
-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[15], \&\"x\""
"gimple" } } */
+/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[15], \&x" "gimple"
} } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-2.c
b/gcc/testsuite/c-c++-common/auto-init-2.c
index a1f66358e6e22..08240d56ac561 100644
--- a/gcc/testsuite/c-c++-common/auto-init-2.c
+++ b/gcc/testsuite/c-c++-common/auto-init-2.c
@@ -29,13 +29,13 @@ void foo()
return;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, \[15],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, \[15],
\&\"temp2\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, \[15],
\&\"temp3\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, \[15],
\&\"temp4\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, \[15],
\&\"temp5\"" "gimple" { target ilp32 } } } */
-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, \[15],
\&\"temp5\"" "gimple" { target lp64 } } } */
-/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, \[15],
\&\"temp6\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, \[15],
\&\"temp7\"" "gimple" { target ilp32 } } } */
-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, \[15],
\&\"temp7\"" "gimple" { target lp64 } } } */
-/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, \[15],
\&\"temp8\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, \[15], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, \[15], \&temp2"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, \[15], \&temp3"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, \[15], \&temp4"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, \[15], \&temp5"
"gimple" { target ilp32 } } } */
+/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, \[15], \&temp5"
"gimple" { target lp64 } } } */
+/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, \[15], \&temp6"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, \[15], \&temp7"
"gimple" { target ilp32 } } } */
+/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, \[15], \&temp7"
"gimple" { target lp64 } } } */
+/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, \[15], \&temp8"
"gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-3.c
b/gcc/testsuite/c-c++-common/auto-init-3.c
index c2e310f236433..c2406d2b2956b 100644
--- a/gcc/testsuite/c-c++-common/auto-init-3.c
+++ b/gcc/testsuite/c-c++-common/auto-init-3.c
@@ -14,6 +14,6 @@ long double foo()
return result;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, \[26],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, \[26],
\&\"temp2\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), \[26],
\&\"temp3\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, \[26], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, \[26], \&temp2"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), \[26],
\&temp3" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-4.c
b/gcc/testsuite/c-c++-common/auto-init-4.c
index cff11ef3e1671..13b43aad3f440 100644
--- a/gcc/testsuite/c-c++-common/auto-init-4.c
+++ b/gcc/testsuite/c-c++-common/auto-init-4.c
@@ -14,6 +14,6 @@ long double foo()
return result;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, \[15],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, \[15],
\&\"temp2\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), \[15],
\&\"temp3\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, \[15], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, \[15], \&temp2"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16), \[15],
\&temp3" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-5.c
b/gcc/testsuite/c-c++-common/auto-init-5.c
index 1be200c4428ec..b9805f4d29736 100644
--- a/gcc/testsuite/c-c++-common/auto-init-5.c
+++ b/gcc/testsuite/c-c++-common/auto-init-5.c
@@ -15,7 +15,7 @@ _Complex long double foo()
return result;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, \[26],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, \[26],
\&\"temp2\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), \[26],
\&\"temp3\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, \[26], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, \[26], \&temp2"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), \[26],
\&temp3" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-6.c
b/gcc/testsuite/c-c++-common/auto-init-6.c
index 8f09007c358a5..1e772d7d9364f 100644
--- a/gcc/testsuite/c-c++-common/auto-init-6.c
+++ b/gcc/testsuite/c-c++-common/auto-init-6.c
@@ -15,7 +15,7 @@ _Complex long double foo()
return result;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, \[15],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, \[15],
\&\"temp2\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), \[15],
\&\"temp3\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, \[15], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, \[15], \&temp2"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32), \[15],
\&temp3" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-7.c
b/gcc/testsuite/c-c++-common/auto-init-7.c
index 3466763040163..6c998de839269 100644
--- a/gcc/testsuite/c-c++-common/auto-init-7.c
+++ b/gcc/testsuite/c-c++-common/auto-init-7.c
@@ -29,7 +29,7 @@ double foo()
return result;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, \[26],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, \[26],
\&\"temp2\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, \[26],
\&\"temp3\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\((8|5), \[26],
\&\"temp4\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, \[26], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, \[26], \&temp2"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, \[26], \&temp3"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\((8|5), \[26],
\&temp4" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-8.c
b/gcc/testsuite/c-c++-common/auto-init-8.c
index 93d37ee6c9cae..4ac7d65d683f2 100644
--- a/gcc/testsuite/c-c++-common/auto-init-8.c
+++ b/gcc/testsuite/c-c++-common/auto-init-8.c
@@ -29,7 +29,7 @@ double foo()
return result;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, \[15],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, \[15],
\&\"temp2\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, \[15],
\&\"temp3\"" "gimple" } } */
-/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\((8|5), \[15],
\&\"temp4\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, \[15], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, \[15], \&temp2"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, \[15], \&temp3"
"gimple" } } */
+/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\((8|5), \[15],
\&temp4" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-9.c
b/gcc/testsuite/c-c++-common/auto-init-9.c
index 66204285616c1..e3849afbcfa55 100644
--- a/gcc/testsuite/c-c++-common/auto-init-9.c
+++ b/gcc/testsuite/c-c++-common/auto-init-9.c
@@ -16,5 +16,5 @@ void foo()
return;
}
-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, \[26],
\&\"temp1\"" "gimple" } } */
-/* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(8, \[26],
\&\"temp2\"" "gimple" } } */
+/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, \[26], \&temp1"
"gimple" } } */
+/* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(8, \[26],
\&temp2" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-esra.c
b/gcc/testsuite/c-c++-common/auto-init-esra.c
index 3471a21aa808c..9e10f8abac057 100644
--- a/gcc/testsuite/c-c++-common/auto-init-esra.c
+++ b/gcc/testsuite/c-c++-common/auto-init-esra.c
@@ -1,6 +1,7 @@
/* Verify the strength reduction adjustment for -ftrivial-auto-var-init. */
/* { dg-do compile } */
/* { dg-options "-O2 -ftrivial-auto-var-init=zero -fno-PIC -fdump-tree-gimple
-fdump-tree-esra" } */
+/* { dg-additional-options "-fdump-tree-ssa" } */
typedef double VECTOR[3];
@@ -31,5 +32,15 @@ void VCross(VECTOR a, const VECTOR b, const VECTOR c)
Assign_Vector(a, tmp);
}
-/* { dg-final { scan-tree-dump-times "tmp = .DEFERRED_INIT \\(24, \[26],
\&\"tmp\"" 1 "gimple" } } */
-/* { dg-final { scan-tree-dump-times ".DEFERRED_INIT \\(8, \[26], \&\"tmp\"" 3
"esra" } } */
+/* { dg-final { scan-tree-dump-times "tmp = .DEFERRED_INIT \\(24, \[26],
\&tmp" 1 "gimple" } } */
+/* { dg-final { scan-tree-dump-times ".DEFERRED_INIT \\(8, \[26], \&tmp\\$" 3
"esra" } } */
+
+/* The diagnostic object address must not prevent SSA promotion. */
+int
+f (void)
+{
+ int x;
+ return x;
+}
+
+/* { dg-final { scan-tree-dump {x_[0-9]+ = \.DEFERRED_INIT} "ssa" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-ifcvt-1.c
b/gcc/testsuite/c-c++-common/auto-init-ifcvt-1.c
new file mode 100644
index 0000000000000..fea7bc3d5e623
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/auto-init-ifcvt-1.c
@@ -0,0 +1,24 @@
+/* Loop if-conversion must preserve diagnostic object addresses. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-ssa-phiopt -ftree-loop-if-convert" } */
+/* { dg-additional-options "-ftrivial-auto-var-init=zero" } */
+
+void
+f (int *out, const int *in, int n)
+{
+ for (int i = 0; i < n; ++i)
+ {
+ int r;
+ if (in[i])
+ {
+ int a;
+ r = a;
+ }
+ else
+ {
+ int b;
+ r = b;
+ }
+ out[i] = r;
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/auto-init-ifcvt-2.c
b/gcc/testsuite/c-c++-common/auto-init-ifcvt-2.c
new file mode 100644
index 0000000000000..7dfaff512ebde
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/auto-init-ifcvt-2.c
@@ -0,0 +1,5 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-ssa-phiopt -ftree-loop-if-convert" } */
+/* { dg-additional-options "-ftrivial-auto-var-init=pattern" } */
+
+#include "auto-init-ifcvt-1.c"
diff --git a/gcc/testsuite/c-c++-common/auto-init-padding-1.c
b/gcc/testsuite/c-c++-common/auto-init-padding-1.c
index dddff37a68bfc..a6ed0f970f3ab 100644
--- a/gcc/testsuite/c-c++-common/auto-init-padding-1.c
+++ b/gcc/testsuite/c-c++-common/auto-init-padding-1.c
@@ -19,5 +19,5 @@ void foo(int a)
g(s);
}
-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(24, \[15], \&\"s\"" "gimple"
} } */
+/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(24, \[15], \&s" "gimple" } }
*/
/* { dg-final { scan-tree-dump "__builtin_clear_padding" "gimple" } } */
diff --git a/gcc/testsuite/c-c++-common/auto-init-phiopt-1.c
b/gcc/testsuite/c-c++-common/auto-init-phiopt-1.c
new file mode 100644
index 0000000000000..c70e120a928eb
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/auto-init-phiopt-1.c
@@ -0,0 +1,18 @@
+/* Factoring must not turn diagnostic object addresses into pointer PHIs. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftrivial-auto-var-init=zero" } */
+
+int
+f (int x)
+{
+ if (x)
+ {
+ int a;
+ return a;
+ }
+ else
+ {
+ int b;
+ return b;
+ }
+}
diff --git a/gcc/testsuite/c-c++-common/auto-init-phiopt-2.c
b/gcc/testsuite/c-c++-common/auto-init-phiopt-2.c
new file mode 100644
index 0000000000000..8a4429a3af7bc
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/auto-init-phiopt-2.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -ftrivial-auto-var-init=pattern" } */
+
+#include "auto-init-phiopt-1.c"
diff --git a/gcc/testsuite/g++.dg/asan/auto-init-uninit-1.C
b/gcc/testsuite/g++.dg/asan/auto-init-uninit-1.C
new file mode 100644
index 0000000000000..5585558f63674
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/auto-init-uninit-1.C
@@ -0,0 +1,24 @@
+// { dg-do compile { target c++14 } }
+// { dg-options "-O2 -Wuninitialized -fsanitize=undefined
-ftrivial-auto-var-init=zero" }
+
+template <typename T>
+const T &
+max (const T &a, const T &b)
+{
+ return a < b ? b : a;
+}
+
+template <typename A, typename B>
+auto
+max_mixed (const A &a, const B &b)
+{
+ const unsigned long &x = a;
+ const unsigned long &y = b;
+ return max (x, y);
+}
+
+unsigned long
+f (unsigned long a)
+{
+ return max_mixed (a, 1);
+}
diff --git a/gcc/testsuite/g++.dg/asan/auto-init-uninit-2.C
b/gcc/testsuite/g++.dg/asan/auto-init-uninit-2.C
new file mode 100644
index 0000000000000..b0ce10863824f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/auto-init-uninit-2.C
@@ -0,0 +1,4 @@
+// { dg-do compile { target c++14 } }
+// { dg-options "-O2 -Wuninitialized -fsanitize=undefined
-ftrivial-auto-var-init=pattern" }
+
+#include "auto-init-uninit-1.C"
diff --git a/gcc/testsuite/g++.dg/asan/auto-init-uninit-3.C
b/gcc/testsuite/g++.dg/asan/auto-init-uninit-3.C
new file mode 100644
index 0000000000000..f83a4766b3e7e
--- /dev/null
+++ b/gcc/testsuite/g++.dg/asan/auto-init-uninit-3.C
@@ -0,0 +1,26 @@
+// PR middle-end/124380
+// { dg-do compile }
+// { dg-options "-O3 -Wuninitialized -fsanitize=undefined
-ftrivial-auto-var-init=zero -fipa-cp-clone --param=ipa-cp-eval-threshold=0
-fno-early-inlining" }
+
+int get ();
+void sink (const int &);
+
+static __attribute__((noinline)) int
+body (int selector, int value)
+{
+ const int &temporary = get ();
+ sink (temporary);
+ return selector ? value + 1 : value - 1;
+}
+
+int
+caller_a (int value)
+{
+ return body (0, value);
+}
+
+int
+caller_b (int value)
+{
+ return body (1, value);
+}
diff --git a/gcc/testsuite/g++.dg/lto/auto-init-uninit_0.C
b/gcc/testsuite/g++.dg/lto/auto-init-uninit_0.C
new file mode 100644
index 0000000000000..5028d479ee2ab
--- /dev/null
+++ b/gcc/testsuite/g++.dg/lto/auto-init-uninit_0.C
@@ -0,0 +1,28 @@
+// PR middle-end/124380
+// { dg-lto-do link }
+// { dg-extra-ld-options "-r -nostdlib -flinker-output=nolto-rel" }
+// { dg-skip-if "no address sanitizer" { no_fsanitize_address } }
+// { dg-lto-options { { -std=c++14 -O2 -Wuninitialized -Werror
-fsanitize=address,undefined -ftrivial-auto-var-init=zero -flto } { -std=c++14
-O2 -Wuninitialized -Werror -fsanitize=address,undefined
-ftrivial-auto-var-init=pattern -flto } } }
+
+template <typename T>
+const T &
+max (const T &a, const T &b)
+{
+ return a < b ? b : a;
+}
+
+template <typename A, typename B>
+auto
+max_mixed (const A &a, const B &b)
+{
+ const unsigned long &x = a;
+ const unsigned long &y = b;
+ return max (x, y);
+}
+
+unsigned long
+f (unsigned long a)
+{
+ return max_mixed (a, 1);
+}
+
diff --git a/gcc/testsuite/g++.dg/opt/auto-init-debug-1.C
b/gcc/testsuite/g++.dg/opt/auto-init-debug-1.C
new file mode 100644
index 0000000000000..c7068197908d9
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/auto-init-debug-1.C
@@ -0,0 +1,5 @@
+// Diagnostic metadata must not affect -fcompare-debug.
+// { dg-do compile }
+// { dg-options "-Og -fif-conversion -fno-tree-ccp -fno-tree-copy-prop
-fcompare-debug -ftrivial-auto-var-init=zero" }
+
+#include "pr100852.C"
diff --git a/gcc/testsuite/g++.dg/opt/auto-init-debug-2.C
b/gcc/testsuite/g++.dg/opt/auto-init-debug-2.C
new file mode 100644
index 0000000000000..9a6b884f77f49
--- /dev/null
+++ b/gcc/testsuite/g++.dg/opt/auto-init-debug-2.C
@@ -0,0 +1,4 @@
+// { dg-do compile }
+// { dg-options "-Og -fif-conversion -fno-tree-ccp -fno-tree-copy-prop
-fcompare-debug -ftrivial-auto-var-init=pattern" }
+
+#include "pr100852.C"
diff --git a/gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-1.C
b/gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-1.C
new file mode 100644
index 0000000000000..565069572fe3b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-1.C
@@ -0,0 +1,23 @@
+// The diagnostic address must not become a real parallel argument.
+// { dg-do compile }
+// { dg-require-effective-target pthread }
+// { dg-options "-std=c++26 -O3 -ftrivial-auto-var-init=zero
-ftree-parallelize-loops=2 -fno-tree-loop-im -fdump-tree-parloops2-details" }
+
+template <typename T>
+void
+f (T *__restrict a, T *__restrict b)
+{
+ for (int i = 0; i < 10000; ++i)
+ {
+ T x;
+ if (b[i] > 4)
+ x = b[i];
+ a[i] = x;
+ }
+}
+
+template void f (int *__restrict, int *__restrict);
+template void f (unsigned char *__restrict, unsigned char *__restrict);
+
+// { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2
"parloops2" } }
+// { dg-final { scan-tree-dump-not {paral_data_store[^;]*\.x} "parloops2" } }
diff --git a/gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-2.C
b/gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-2.C
new file mode 100644
index 0000000000000..971b0816bb93b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-2.C
@@ -0,0 +1,8 @@
+// { dg-do compile }
+// { dg-require-effective-target pthread }
+// { dg-options "-std=c++26 -O3 -ftrivial-auto-var-init=pattern
-ftree-parallelize-loops=2 -fno-tree-loop-im -fdump-tree-parloops2-details" }
+
+#include "auto-init-parloops-1.C"
+
+// { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2
"parloops2" } }
+// { dg-final { scan-tree-dump-not {paral_data_store[^;]*\.x} "parloops2" } }
diff --git a/gcc/testsuite/g++.dg/uninit-pr124380.C
b/gcc/testsuite/g++.dg/uninit-pr124380.C
new file mode 100644
index 0000000000000..a3bec28fc30a5
--- /dev/null
+++ b/gcc/testsuite/g++.dg/uninit-pr124380.C
@@ -0,0 +1,27 @@
+// PR middle-end/124380
+// { dg-do compile }
+// { dg-options "-O1 -Wuninitialized -ftrivial-auto-var-init=zero" }
+
+int get ();
+void sink (const int &);
+
+inline __attribute__((always_inline)) void
+two ()
+{
+ const int &result = get ();
+ sink (result);
+}
+
+inline __attribute__((always_inline)) void
+three ()
+{
+ two ();
+ two ();
+}
+
+void
+one ()
+{
+ two ();
+ three ();
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-nested-1.c
b/gcc/testsuite/gcc.dg/auto-init-nested-1.c
new file mode 100644
index 0000000000000..7fca9161b3d21
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-nested-1.c
@@ -0,0 +1,23 @@
+/* Captured locals must retain their diagnostic declaration when their
+ storage is moved into a nested function's frame. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized -Werror -ftrivial-auto-var-init=zero" } */
+
+int
+scalar (void)
+{
+ int x;
+ int read (void) { return x; }
+ x = 42;
+ return read ();
+}
+
+int
+aggregate (void)
+{
+ struct S { int x, y; } s;
+ int read (void) { return s.x + s.y; }
+ s.x = 20;
+ s.y = 22;
+ return read ();
+}
diff --git a/gcc/testsuite/gcc.dg/auto-init-nested-2.c
b/gcc/testsuite/gcc.dg/auto-init-nested-2.c
new file mode 100644
index 0000000000000..8f84f14bc88a6
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-nested-2.c
@@ -0,0 +1,4 @@
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized -Werror -ftrivial-auto-var-init=pattern"
} */
+
+#include "auto-init-nested-1.c"
diff --git a/gcc/testsuite/gcc.dg/auto-init-nested-3.c
b/gcc/testsuite/gcc.dg/auto-init-nested-3.c
new file mode 100644
index 0000000000000..866c0149a4a6e
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/auto-init-nested-3.c
@@ -0,0 +1,12 @@
+/* A captured variable's artificial initialization must not hide its
+ subsequent uninitialized use. */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
+int
+f (void)
+{
+ int x;
+ int read (void) { return x; }
+ return read (); /* { dg-warning "'x' is used uninitialized" } */
+}
diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc
index ba1d4a125adcf..bb8f3dc044311 100644
--- a/gcc/tree-cfg.cc
+++ b/gcc/tree-cfg.cc
@@ -3473,12 +3473,20 @@ verify_gimple_call (gcall *stmt)
}
/* For a call to .DEFERRED_INIT,
- LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the DECL)
+ LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, &DECL)
we should guarantee that when the 1st argument is a constant, it should
be the same as the size of the LHS. */
if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
{
+ if (gimple_call_num_args (stmt) != 3
+ || TREE_CODE (gimple_call_arg (stmt, 2)) != ADDR_EXPR
+ || !DECL_P (TREE_OPERAND (gimple_call_arg (stmt, 2), 0)))
+ {
+ error ("invalid object argument to %<.DEFERRED_INIT%>");
+ return true;
+ }
+
tree size_of_arg0 = gimple_call_arg (stmt, 0);
tree size_of_lhs = TYPE_SIZE_UNIT (TREE_TYPE (lhs));
diff --git a/gcc/tree-dfa.cc b/gcc/tree-dfa.cc
index ee587fe845452..b13e97a6c6126 100644
--- a/gcc/tree-dfa.cc
+++ b/gcc/tree-dfa.cc
@@ -1022,6 +1022,8 @@ dump_enumerated_decls (FILE *file, dump_flags_t flags)
memset (&wi, '\0', sizeof (wi));
wi.info = (void *) &decl_list;
+ /* Diagnostic metadata does not represent a use of a declaration. */
+ wi.skip_diagnostic_operands = true;
FOR_EACH_BB_FN (bb, cfun)
{
gimple_stmt_iterator gsi;
diff --git a/gcc/tree-nested.cc b/gcc/tree-nested.cc
index 78ee580465c6c..4eb69cc747d63 100644
--- a/gcc/tree-nested.cc
+++ b/gcc/tree-nested.cc
@@ -822,6 +822,7 @@ walk_body (walk_stmt_fn callback_stmt, walk_tree_fn
callback_op,
memset (&wi, 0, sizeof (wi));
wi.info = info;
wi.val_only = true;
+ wi.skip_diagnostic_operands = true;
walk_gimple_seq_mod (pseq, callback_stmt, callback_op, &wi);
}
diff --git a/gcc/tree-parloops.cc b/gcc/tree-parloops.cc
index 1da23f8d3c8df..5f694dde6bfe3 100644
--- a/gcc/tree-parloops.cc
+++ b/gcc/tree-parloops.cc
@@ -1246,6 +1246,7 @@ eliminate_local_variables_stmt (edge entry,
gimple_stmt_iterator *gsi,
gimple *stmt = gsi_stmt (*gsi);
memset (&dta.info, '\0', sizeof (dta.info));
+ dta.info.skip_diagnostic_operands = true;
dta.entry = entry;
dta.decl_address = decl_address;
dta.changed = false;
@@ -1464,6 +1465,18 @@ separate_decls_in_region_stmt (edge entry, edge exit,
gimple *stmt,
copy_name_p);
SET_USE (use, copy);
}
+
+ /* Keep the diagnostic identity in step with the copied SSA variable.
+ Its address must not be passed through the parallel argument data. */
+ if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
+ {
+ tree var = TREE_OPERAND (gimple_call_arg (stmt, 2), 0);
+ int_tree_map elt;
+ elt.uid = DECL_UID (var);
+ tree copy = decl_copies->find (elt).to;
+ if (copy)
+ gimple_call_set_arg (stmt, 2, build_fold_addr_expr (copy));
+ }
}
/* Finds the ssa names used in STMT that are defined outside the
diff --git a/gcc/tree-sra.cc b/gcc/tree-sra.cc
index f951a38442a5b..c64a8911ee327 100644
--- a/gcc/tree-sra.cc
+++ b/gcc/tree-sra.cc
@@ -1653,6 +1653,9 @@ scan_function (void)
gcall *call = as_a <gcall *> (stmt);
for (i = 0; i < gimple_call_num_args (call); i++)
{
+ if (i == 2
+ && gimple_call_internal_p (call, IFN_DEFERRED_INIT))
+ continue;
bool can_be_returned;
if (gimple_call_lhs (call))
{
@@ -4598,7 +4601,6 @@ get_repl_default_def_ssa_name (struct access *racc, tree
reg_type)
static void
generate_subtree_deferred_init (struct access *access,
tree init_type,
- tree decl_name,
gimple_stmt_iterator *gsi,
location_t loc)
{
@@ -4610,7 +4612,8 @@ generate_subtree_deferred_init (struct access *access,
gimple *call
= gimple_build_call_internal (IFN_DEFERRED_INIT, 3,
TYPE_SIZE_UNIT (TREE_TYPE (repl)),
- init_type, decl_name);
+ init_type,
+ build_fold_addr_expr (repl));
gimple_call_set_lhs (call, repl);
gsi_insert_before (gsi, call, GSI_SAME_STMT);
update_stmt (call);
@@ -4619,7 +4622,7 @@ generate_subtree_deferred_init (struct access *access,
}
if (access->first_child)
generate_subtree_deferred_init (access->first_child, init_type,
- decl_name, gsi, loc);
+ gsi, loc);
access = access ->next_sibling;
}
@@ -4627,7 +4630,7 @@ generate_subtree_deferred_init (struct access *access,
}
/* For a call to .DEFERRED_INIT:
- var = .DEFERRED_INIT (size_of_var, init_type, name_of_var);
+ var = .DEFERRED_INIT (size_of_var, init_type, &var);
examine the LHS variable VAR and replace it with a scalar replacement if
there is one, also replace the RHS call to a call to .DEFERRED_INIT of
the corresponding scalar relacement variable. Examine the subtree and
@@ -4639,7 +4642,6 @@ sra_modify_deferred_init (gimple *stmt,
gimple_stmt_iterator *gsi)
{
tree lhs = gimple_call_lhs (stmt);
tree init_type = gimple_call_arg (stmt, 1);
- tree decl_name = gimple_call_arg (stmt, 2);
struct access *lhs_access = get_access_for_expr (lhs);
if (!lhs_access)
@@ -4653,6 +4655,7 @@ sra_modify_deferred_init (gimple *stmt,
gimple_stmt_iterator *gsi)
gimple_call_set_lhs (stmt, lhs_repl);
tree arg0_repl = TYPE_SIZE_UNIT (TREE_TYPE (lhs_repl));
gimple_call_set_arg (stmt, 0, arg0_repl);
+ gimple_call_set_arg (stmt, 2, build_fold_addr_expr (lhs_repl));
sra_stats.deferred_init++;
gcc_assert (!lhs_access->first_child);
return SRA_AM_MODIFIED;
@@ -4660,7 +4663,7 @@ sra_modify_deferred_init (gimple *stmt,
gimple_stmt_iterator *gsi)
if (lhs_access->first_child)
generate_subtree_deferred_init (lhs_access->first_child,
- init_type, decl_name, gsi, loc);
+ init_type, gsi, loc);
if (lhs_access->grp_covered)
{
unlink_stmt_vdef (stmt);
diff --git a/gcc/tree-ssa-operands.cc b/gcc/tree-ssa-operands.cc
index c526c842b2fb9..d5605108f1c76 100644
--- a/gcc/tree-ssa-operands.cc
+++ b/gcc/tree-ssa-operands.cc
@@ -986,7 +986,10 @@ operands_scanner::parse_ssa_operands ()
case GIMPLE_CALL:
/* Add call-clobbered operands, if needed. */
maybe_add_call_vops (as_a <gcall *> (stmt));
- if (gimple_call_internal_p (stmt, IFN_ASSUME))
+ /* The object address in .DEFERRED_INIT is diagnostic metadata,
+ not an address escape or a use of the object's value. */
+ if (gimple_call_internal_p (stmt, IFN_ASSUME)
+ || gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
flags |= opf_non_addressable;
/* FALLTHRU */
diff --git a/gcc/tree-ssa-uninit.cc b/gcc/tree-ssa-uninit.cc
index 7d242ab7530a0..9ef76d68b0a35 100644
--- a/gcc/tree-ssa-uninit.cc
+++ b/gcc/tree-ssa-uninit.cc
@@ -193,18 +193,13 @@ warn_uninit (opt_code opt, tree t, tree var, gimple
*context,
Or
- 2. A call to .DEFERRED_INIT internal function. Since the original variable
- has been eliminated by optimization, we need to get the variable name,
- and variable declaration location from this call. We recorded variable
- name into VAR_NAME_STR, and will get location info and record warning
- suppressed info to VAR_DEF_STMT, which is the .DEFERRED_INIT call. */
-
- const char *var_name_str = NULL;
- gimple *var_def_stmt = NULL;
+ 2. A call to .DEFERRED_INIT. Its third argument retains the address
+ of the initialized declaration even if optimization has eliminated
+ the variable's storage and the SSA_NAME no longer has a variable. */
if (!var && !SSA_NAME_VAR (t))
{
- var_def_stmt = SSA_NAME_DEF_STMT (t);
+ gimple *var_def_stmt = SSA_NAME_DEF_STMT (t);
if (gassign *ass = dyn_cast <gassign *> (var_def_stmt))
{
@@ -233,48 +228,27 @@ warn_uninit (opt_code opt, tree t, tree var, gimple
*context,
if (gimple_call_internal_p (var_def_stmt, IFN_DEFERRED_INIT))
{
- /* Ignore the call to .DEFERRED_INIT that define the original
- var itself as the following case:
- temp = .DEFERRED_INIT (4, 2, ���alt_reloc");
- alt_reloc = temp;
- In order to avoid generating warning for the fake usage
- at alt_reloc = temp.
- */
- tree lhs_var = NULL_TREE;
-
- /* Get the variable name from the 3rd argument of call. */
- tree var_name = gimple_call_arg (var_def_stmt, 2);
- var_name = TREE_OPERAND (TREE_OPERAND (var_name, 0), 0);
- var_name_str = TREE_STRING_POINTER (var_name);
+ tree addr = gimple_call_arg (var_def_stmt, 2);
+ var = TREE_OPERAND (addr, 0);
+ /* Do not diagnose the artificial initialization store:
+ temp = .DEFERRED_INIT (4, 2, &var);
+ var = temp;
+ Copies to other variables are real uses and must still warn. */
if (is_gimple_assign (context))
{
- if (VAR_P (gimple_assign_lhs (context)))
- lhs_var = gimple_assign_lhs (context);
- else if (TREE_CODE (gimple_assign_lhs (context)) == SSA_NAME)
- lhs_var = SSA_NAME_VAR (gimple_assign_lhs (context));
- }
- if (lhs_var)
- {
- /* Get the name string for the LHS_VAR.
- Refer to routine gimple_add_init_for_auto_var. */
- if (DECL_NAME (lhs_var)
- && (strcmp (IDENTIFIER_POINTER (DECL_NAME (lhs_var)),
- var_name_str) == 0))
+ tree lhs = gimple_assign_lhs (context);
+ if (TREE_CODE (lhs) == SSA_NAME)
+ lhs = SSA_NAME_VAR (lhs);
+ if (lhs == var
+ || (lhs && DECL_HAS_VALUE_EXPR_P (var)
+ && operand_equal_p (lhs, DECL_VALUE_EXPR (var), 0)))
return;
- else if (!DECL_NAME (lhs_var))
- {
- char lhs_var_name_str_buf[3 + (HOST_BITS_PER_INT + 2) / 3];
- sprintf (lhs_var_name_str_buf, "D.%u", DECL_UID (lhs_var));
- if (strcmp (lhs_var_name_str_buf, var_name_str) == 0)
- return;
- }
}
- gcc_assert (var_name_str && var_def_stmt);
}
}
- if (var == NULL_TREE && var_name_str == NULL)
+ if (var == NULL_TREE)
return;
/* Avoid warning if we've already done so or if the warning has been
@@ -282,9 +256,7 @@ warn_uninit (opt_code opt, tree t, tree var, gimple
*context,
if (((warning_suppressed_p (context, OPT_Wuninitialized)
|| (gimple_assign_single_p (context)
&& get_no_uninit_warning (gimple_assign_rhs1 (context)))))
- || (var && get_no_uninit_warning (var))
- || (var_name_str
- && warning_suppressed_p (var_def_stmt, OPT_Wuninitialized)))
+ || get_no_uninit_warning (var))
return;
/* Use either the location of the read statement or that of the PHI
@@ -295,10 +267,8 @@ warn_uninit (opt_code opt, tree t, tree var, gimple
*context,
location = gimple_location (context);
else if (phi_arg_loc != UNKNOWN_LOCATION)
location = phi_arg_loc;
- else if (var)
+ else
location = DECL_SOURCE_LOCATION (var);
- else if (var_name_str)
- location = gimple_location (var_def_stmt);
auto_diagnostic_group d;
gcc_assert (opt == OPT_Wuninitialized || opt == OPT_Wmaybe_uninitialized);
@@ -311,34 +281,17 @@ warn_uninit (opt_code opt, tree t, tree var, gimple
*context,
var)))
return;
}
- else if (var_name_str)
- {
- if ((opt == OPT_Wuninitialized
- && !warning_at (location, opt, "%qs is used uninitialized",
- var_name_str))
- || (opt == OPT_Wmaybe_uninitialized
- && !warning_at (location, opt, "%qs may be used uninitialized",
- var_name_str)))
- return;
- }
/* Avoid subsequent warnings for reads of the same variable again. */
- if (var)
- suppress_warning (var, opt);
- else if (var_name_str)
- suppress_warning (var_def_stmt, opt);
+ suppress_warning (var, opt);
/* Issue a note pointing to the read variable unless the warning
is at the same location. */
- location_t var_loc = var ? DECL_SOURCE_LOCATION (var)
- : gimple_location (var_def_stmt);
+ location_t var_loc = DECL_SOURCE_LOCATION (var);
if (location == var_loc)
return;
- if (var)
- inform (var_loc, "%qD was declared here", var);
- else if (var_name_str)
- inform (var_loc, "%qs was declared here", var_name_str);
+ inform (var_loc, "%qD was declared here", var);
}
struct check_defs_data
@@ -482,7 +435,7 @@ check_defs (ao_ref *ref, tree vdef, void *data_)
/* For address taken variable, a temporary variable is added between
the variable and the call to .DEFERRED_INIT function as:
- _1 = .DEFERRED_INIT (4, 2, &"i1"[0]);
+ _1 = .DEFERRED_INIT (4, 2, &i1);
i1 = _1;
Ignore this vdef as well. */
if (is_gimple_assign (def_stmt)
Range-diff against v2:
1: 1a4cf66d552c5 ! 1: 7923ab0cfa2f4 tree-inline: Update deferred
initialization names when copying bodies [PR124380]
@@ Metadata
Author: Jonas Hansen <[email protected]>
## Commit message ##
- tree-inline: Update deferred initialization names when copying bodies
[PR124380]
+ middle-end: Track deferred initialization by declaration [PR124380]
- With -ftrivial-auto-var-init, an anonymous temporary can be initialized
- by an SSA name defined by .DEFERRED_INIT. Inlining gives the
destination
- declaration a new DECL_UID while the call retains the original D.N
name.
- warn_uninit then fails to recognize the artificial initialization store
- and diagnoses it as an uninitialized read.
+ The name recorded by .DEFERRED_INIT can stop identifying its
destination
+ after inlining or LTO renumbers anonymous declarations. This makes
+ warn_uninit diagnose an artificial initialization store as an
+ uninitialized read, notably with sanitizers and
-ftrivial-auto-var-init.
- Remap the anonymous variable name when copying .DEFERRED_INIT calls,
- using the declaration mapping for the copied body. Build a UID lookup
- lazily and release it after copying the body. This also handles
function
- cloning and repeated inlining without changing warn_uninit.
+ Use the initialized declaration's address as diagnostic metadata
instead
+ of a name string. Preserve its identity through declaration remapping
+ and LTO streaming, and compare declarations in warn_uninit. Keep this
+ operand unevaluated and avoid making the object addressable or
preventing
+ SSA promotion. Update scalar replacement, nested-function lowering,
+ parallelization and offload handling accordingly.
- Document the operands and semantics of .DEFERRED_INIT, including the
- AUTO_INIT_CXX26 bit and the anonymous variable identity. Add tests for
- zero and pattern initialization with sanitizers, repeated inlining
- without sanitizers, and IPA constant-propagation cloning.
+ Prevent conditional operation factoring from turning the diagnostic
+ address into a computed pointer, and omit metadata-only references from
+ declaration enumeration used by debug comparison. Document the operand
+ contract and add coverage for inlining, cloning, LTO, SSA promotion,
+ parallelization, nested functions, debug comparison and both factoring
+ paths, with zero and pattern initialization.
gcc/ChangeLog:
PR middle-end/124380
- * tree-inline.h (copy_body_data): Add deferred_init_map.
- * tree-inline.cc (remap_deferred_init): New function.
- (copy_bb): Remap anonymous variable names in .DEFERRED_INIT
calls.
- (copy_cfg_body): Release deferred_init_map.
- * doc/ifn.texi (IFN_DEFERRED_INIT): Document operands and
semantics.
+ * config/avr/avr-passes.cc (avr_pass_has::execute): Initialize
+ walk_stmt_info completely.
+ * doc/ifn.texi (IFN_DEFERRED_INIT): Document operands,
semantics
+ and diagnostic declaration-address handling.
+ * gimple-match-exports.cc (factor_operation_ok): Preserve the
+ diagnostic object address when factoring deferred
initialization.
+ * gimple-walk.cc (walk_gimple_op): Support skipping diagnostic
+ operands.
+ (walk_stmt_load_store_addr_ops): Ignore the diagnostic operand
+ of deferred initialization.
+ * gimple-walk.h (walk_stmt_info): Add skip_diagnostic_operands.
+ * gimplify-me.cc (gimple_regimplify_operands): Preserve the
+ diagnostic object address.
+ * gimplify.cc (gimple_add_init_for_auto_var): Pass the
declaration
+ address instead of its name.
+ (warn_switch_unreachable_and_auto_init_r): Diagnose the
declaration.
+ (gimplify_call_expr, gimplify_modify_expr): Do not gimplify the
+ diagnostic address operand.
+ * internal-fn.cc (expand_DEFERRED_INIT): Update the operand
comment.
+ * omp-offload.cc (execute_oacc_device_lower): Avoid pointer
+ conversion for deferred initialization metadata.
+ * tree-cfg.cc (verify_gimple_call): Verify the diagnostic
object
+ argument to deferred initialization.
+ * tree-dfa.cc (dump_enumerated_decls): Skip diagnostic
operands.
+ * tree-nested.cc (walk_body): Likewise.
+ * tree-parloops.cc (eliminate_local_variables_stmt): Likewise.
+ (separate_decls_in_region_stmt): Remap deferred
initialization's
+ diagnostic declaration to its parallel-region copy.
+ * tree-sra.cc (scan_function): Ignore diagnostic object
addresses.
+ (generate_subtree_deferred_init, sra_modify_deferred_init): Use
+ the scalar replacement's declaration address.
+ * tree-ssa-operands.cc (operands_scanner::parse_ssa_operands):
Do
+ not mark deferred initialization's diagnostic object
addressable.
+ * tree-ssa-uninit.cc (warn_uninit): Identify deferred
initialization
+ objects by declaration instead of name strings. Recognize
nested
+ frame initialization stores through DECL_VALUE_EXPR.
+ (check_defs): Update the deferred initialization example.
+
+ gcc/cp/ChangeLog:
+
+ PR middle-end/124380
+ * decl.cc (build_deferred_init_call): Pass the declaration
address
+ instead of its name. Update related examples.
gcc/testsuite/ChangeLog:
PR middle-end/124380
+ * c-c++-common/auto-init-1.c: Adjust dump expectations.
+ * c-c++-common/auto-init-2.c: Likewise.
+ * c-c++-common/auto-init-3.c: Likewise.
+ * c-c++-common/auto-init-4.c: Likewise.
+ * c-c++-common/auto-init-5.c: Likewise.
+ * c-c++-common/auto-init-6.c: Likewise.
+ * c-c++-common/auto-init-7.c: Likewise.
+ * c-c++-common/auto-init-8.c: Likewise.
+ * c-c++-common/auto-init-9.c: Likewise.
+ * c-c++-common/auto-init-10.c: Likewise.
+ * c-c++-common/auto-init-11.c: Likewise.
+ * c-c++-common/auto-init-12.c: Likewise.
+ * c-c++-common/auto-init-13.c: Likewise.
+ * c-c++-common/auto-init-14.c: Likewise.
+ * c-c++-common/auto-init-15.c: Likewise.
+ * c-c++-common/auto-init-16.c: Likewise.
+ * c-c++-common/auto-init-esra.c: Likewise. Check SSA
promotion.
+ * c-c++-common/auto-init-padding-1.c: Adjust dump expectations.
+ * c-c++-common/auto-init-ifcvt-1.c: New test.
+ * c-c++-common/auto-init-ifcvt-2.c: New test.
+ * c-c++-common/auto-init-phiopt-1.c: New test.
+ * c-c++-common/auto-init-phiopt-2.c: New test.
* g++.dg/asan/auto-init-uninit-1.C: New test.
* g++.dg/asan/auto-init-uninit-2.C: New test.
* g++.dg/asan/auto-init-uninit-3.C: New test.
+ * g++.dg/lto/auto-init-uninit_0.C: New test.
+ * g++.dg/opt/auto-init-debug-1.C: New test.
+ * g++.dg/opt/auto-init-debug-2.C: New test.
+ * g++.dg/tree-ssa/auto-init-parloops-1.C: New test.
+ * g++.dg/tree-ssa/auto-init-parloops-2.C: New test.
* g++.dg/uninit-pr124380.C: New test.
+ * gcc.dg/auto-init-nested-1.c: New test.
+ * gcc.dg/auto-init-nested-2.c: New test.
+ * gcc.dg/auto-init-nested-3.c: New test.
Signed-off-by: Jonas Hansen <[email protected]>
+ ## gcc/config/avr/avr-passes.cc ##
+@@ gcc/config/avr/avr-passes.cc: public:
+
+ unsigned int execute (function *func) final override
+ {
+- walk_stmt_info wi;
++ walk_stmt_info wi = {};
+ hash_set<tree> hset;
+ wi.pset = &hset;
+
+
+ ## gcc/cp/decl.cc ##
+@@ gcc/cp/decl.cc: build_deferred_init_call (tree decl)
+ tree init_type_arg = build_int_cst (integer_type_node,
+ (int) flag_auto_var_init);
+ location_t loc = DECL_SOURCE_LOCATION (decl);
+- tree decl_name;
+-
+- if (DECL_NAME (decl))
+- decl_name = build_string_literal (DECL_NAME (decl));
+- else
+- {
+- char decl_name_anonymous[3 + (HOST_BITS_PER_INT + 2) / 3];
+- sprintf (decl_name_anonymous, "D.%u", DECL_UID (decl));
+- decl_name = build_string_literal (decl_name_anonymous);
+- }
+
+ tree call = build_call_expr_internal_loc (loc, IFN_DEFERRED_INIT,
+ TREE_TYPE (decl), 3,
+ decl_size_arg, init_type_arg,
+- decl_name);
++ build_fold_addr_expr (decl));
+ tree ret = build2_loc (loc, MODIFY_EXPR, void_type_node, decl, call);
+ return build_stmt (loc, EXPR_STMT, ret);
+ }
+@@ gcc/cp/decl.cc: build_deferred_init_call (tree decl)
+ if (0)
+ {
+ l1:
+- v4 = .DEFERRED_INIT (sizeof (v4), ?, "v4");
+- v3 = .DEFERRED_INIT (sizeof (v3), ?, "v3");
+- v2 = .DEFERRED_INIT (sizeof (v2), ?, "v2");
+- v1 = .DEFERRED_INIT (sizeof (v1), ?, "v1");
++ v4 = .DEFERRED_INIT (sizeof (v4), ?, &v4);
++ v3 = .DEFERRED_INIT (sizeof (v3), ?, &v3);
++ v2 = .DEFERRED_INIT (sizeof (v2), ?, &v2);
++ v1 = .DEFERRED_INIT (sizeof (v1), ?, &v1);
+ }
+ and return l1 label, or if it already exists, assert it has the
+ .DEFERRED_INIT calls for the right decls in the right order and
+
## gcc/doc/ifn.texi ##
@@ gcc/doc/ifn.texi: lowered to PHI nodes.
@@ gcc/doc/ifn.texi: lowered to PHI nodes.
-The @code{IFN_DEFERRED_INIT} internal function is expanded by the
-@code{expand_DEFERRED_INIT} function.
+@smallexample
-+@var{lhs} = .DEFERRED_INIT (@var{size}, @var{init_type}, @var{name})
++@var{lhs} = .DEFERRED_INIT (@var{size}, @var{init_type}, @var{object})
+@end smallexample
+
-+Represent deferred initialization of an automatic variable for
-+@option{-ftrivial-auto-var-init} or C++26. @var{size} is the size of the
-+variable in bytes. @var{init_type} is an integer constant encoding an
-+@code{auto_init_type}. After masking out @code{AUTO_INIT_CXX26} (4),
-+@code{AUTO_INIT_PATTERN} (1) requests a repeated @code{0xFE} byte pattern.
-+@code{AUTO_INIT_ZERO} (2), or zero with @code{AUTO_INIT_CXX26} set,
-+requests zero initialization. Boolean scalars that fit in registers are
-+always initialized to zero. Padding is initialized as well. The call
-+is expanded by @code{expand_DEFERRED_INIT}.
-+
-+The @code{AUTO_INIT_CXX26} bit requires all uses of the result to have the
-+same value. Without this bit, optimizers can treat the result as
-+undefined.
-+
-+The initialized value is still treated as uninitialized by the
-+@option{-Wuninitialized} and @option{-Wmaybe-uninitialized} diagnostics.
-+@var{name} points to a string literal identifying the original variable.
-+For a named variable this is its declaration name. For an anonymous
-+variable it is @samp{D.} followed by the decimal @code{DECL_UID}.
-+This identifies the artificial initialization store so that it does not
-+itself trigger an uninitialized warning. When a declaration is copied
-+during inlining or function cloning, the recorded UID is updated to
-+refer to the copied declaration.
++Represent initialization for @option{-ftrivial-auto-var-init} or C++26.
++@var{size} is the object's size in bytes; @var{init_type} encodes an
++@code{auto_init_type} selecting zero or pattern initialization.
++The @code{AUTO_INIT_CXX26} flag requires all uses of the result to have
the
++same value; otherwise optimizers can treat the result as undefined.
++The result is still treated as uninitialized for diagnostics.
++The call is expanded by @code{expand_DEFERRED_INIT}.
++
++@var{object} is the address of the initialized declaration. It preserves
++the variable's identity for diagnostics and identifies the artificial
++initialization store. This operand is diagnostic metadata, is not
++evaluated, and must not set @code{TREE_ADDRESSABLE} or
++@code{DECL_NOT_GIMPLE_REG_P}, or inhibit SSA promotion.
++
++Declaration remapping, LTO streaming and scalar replacement must preserve
++or update this reference. Storage-lowering walks must not materialize
++its address. Nested-function lowering retains the original declaration,
++whose @code{DECL_VALUE_EXPR} describes its location in the frame.
@cindex @code{IFN_ACCESS_WITH_SIZE} internal function
@item @samp{IFN_ACCESS_WITH_SIZE}
+ ## gcc/gimple-match-exports.cc ##
+@@ gcc/gimple-match-exports.cc: factor_operation_ok (code_helper code, int
opnum,
+ && code.is_internal_fn ())
+ switch (internal_fn (code))
+ {
++ /* The object address is diagnostic metadata and must remain an
++ address of a declaration rather than a computed pointer. */
++ case IFN_DEFERRED_INIT:
++ if (opnum == 2)
++ return false;
++ break;
++
+ /* For these internal functions, gimple_location is an implicit
+ parameter, which will be used explicitly after expansion.
+ Merging these statements may cause confusing line numbers in
+
+ ## gcc/gimple-walk.cc ##
+@@ gcc/gimple-walk.cc: walk_gimple_op (gimple *stmt, walk_tree_fn
callback_op,
+
+ for (i = 0; i < gimple_call_num_args (stmt); i++)
+ {
++ if (wi && wi->skip_diagnostic_operands && i == 2
++ && gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
++ continue;
+ if (wi)
+ wi->val_only
+ = is_gimple_reg_type (TREE_TYPE (gimple_call_arg (stmt, i)));
+@@ gcc/gimple-walk.cc: walk_stmt_load_store_addr_ops (gimple *stmt, void
*data,
+ if (visit_load || visit_addr)
+ for (i = 0; i < gimple_call_num_args (call_stmt); ++i)
+ {
++ /* The third .DEFERRED_INIT operand only identifies the object
++ for diagnostics. It is neither a load nor an address escape. */
++ if (gimple_call_internal_p (call_stmt, IFN_DEFERRED_INIT) && i == 2)
++ continue;
+ tree arg = gimple_call_arg (call_stmt, i);
+ if (visit_addr
+ && TREE_CODE (arg) == ADDR_EXPR)
+
+ ## gcc/gimple-walk.h ##
+@@ gcc/gimple-walk.h: struct walk_stmt_info
+ /* True if we're interested in location information. */
+ bool want_locations : 1;
+
++ /* Do not walk operands that only identify an object for diagnostics,
++ such as the third .DEFERRED_INIT argument. Storage-lowering walks
++ should set this; declaration-copying walks must still remap them. */
++ bool skip_diagnostic_operands : 1;
++
+ /* True if we've removed the statement that was processed. */
+ bool removed_stmt : 1;
+ };
+
+ ## gcc/gimplify-me.cc ##
+@@ gcc/gimplify-me.cc: gimple_regimplify_operands (gimple *stmt,
gimple_stmt_iterator *gsi_p)
+ num_ops = gimple_num_ops (stmt);
+ for (i = num_ops; i > 0; i--)
+ {
++ /* Do not make the diagnostic object address in .DEFERRED_INIT
++ addressable when regimplifying a copied or modified call. */
++ if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT)
++ && gimple_op_ptr (stmt, i - 1) == gimple_call_arg_ptr (stmt, 2))
++ continue;
+ tree op = gimple_op (stmt, i - 1);
+ if (op == NULL_TREE)
+ continue;
+
+ ## gcc/gimplify.cc ##
+@@ gcc/gimplify.cc: force_labels_r (tree *tp, int *walk_subtrees, void
*data ATTRIBUTE_UNUSED)
+ Build a call to internal const function DEFERRED_INIT:
+ 1st argument: SIZE of the DECL;
+ 2nd argument: INIT_TYPE;
+- 3rd argument: NAME of the DECL;
++ 3rd argument: address of the DECL, for diagnostics only.
+
+- as LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the
DECL). */
++ as LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, &DECL). */
+
+ static void
+ gimple_add_init_for_auto_var (tree decl,
+@@ gcc/gimplify.cc: gimple_add_init_for_auto_var (tree decl,
+ const location_t loc = DECL_SOURCE_LOCATION (decl);
+ tree decl_size = TYPE_SIZE_UNIT (TREE_TYPE (decl));
+ tree init_type_node = build_int_cst (integer_type_node, (int)
init_type);
+- tree decl_name;
+-
+- if (DECL_NAME (decl))
+- decl_name = build_string_literal (DECL_NAME (decl));
+- else
+- {
+- char decl_name_anonymous[3 + (HOST_BITS_PER_INT + 2) / 3];
+- sprintf (decl_name_anonymous, "D.%u", DECL_UID (decl));
+- decl_name = build_string_literal (decl_name_anonymous);
+- }
+
+ tree call = build_call_expr_internal_loc (loc, IFN_DEFERRED_INIT,
+ TREE_TYPE (decl), 3,
+ decl_size, init_type_node,
+- decl_name);
++ build_fold_addr_expr (decl));
+
+ gimplify_assign (decl, call, seq_p);
+ }
+@@ gcc/gimplify.cc: warn_switch_unreachable_and_auto_init_r
(gimple_stmt_iterator *gsi_p,
+ present and non-zero;
+ case 3: a gimple assign store right after the call to .DEFERRED_INIT
+ that has the LHS of .DEFERRED_INIT as the RHS as following:
+- _1 = .DEFERRED_INIT (4, 2, &"i1"[0]);
++ _1 = .DEFERRED_INIT (4, 2, &i1);
+ i1 = _1.
+ case 3 is handled above in the GIMPLE_ASSIGN case. */
+ if (flag_auto_var_init > AUTO_INIT_UNINITIALIZED
+@@ gcc/gimplify.cc: warn_switch_unreachable_and_auto_init_r
(gimple_stmt_iterator *gsi_p,
+ {
+ if (warn_trivial_auto_var_init)
+ {
+- /* Get the variable name from the 3rd argument of call. */
+- tree var_name = gimple_call_arg (stmt, 2);
+- var_name = TREE_OPERAND (TREE_OPERAND (var_name, 0), 0);
+- const char *var_name_str = TREE_STRING_POINTER (var_name);
++ tree var = TREE_OPERAND (gimple_call_arg (stmt, 2), 0);
+
+ warning_at (gimple_location (stmt), OPT_Wtrivial_auto_var_init,
+- "%qs cannot be initialized with "
+- "%<-ftrivial-auto-var_init%>", var_name_str);
++ "%qD cannot be initialized with "
++ "%<-ftrivial-auto-var_init%>", var);
+ }
+ break;
+ }
+@@ gcc/gimplify.cc: gimplify_call_expr (tree *expr_p, gimple_seq *pre_p,
fallback_t fallback)
+
+ for (i = 0; i < nargs; i++)
+ {
+- gimplify_arg (&CALL_EXPR_ARG (*expr_p, i), pre_p,
+- EXPR_LOCATION (*expr_p));
++ /* The object address is diagnostic metadata and must not make
++ its declaration addressable. */
++ if (ifn != IFN_DEFERRED_INIT || i != 2)
++ gimplify_arg (&CALL_EXPR_ARG (*expr_p, i), pre_p,
++ EXPR_LOCATION (*expr_p));
+ vargs.quick_push (CALL_EXPR_ARG (*expr_p, i));
+ }
+
+@@ gcc/gimplify.cc: gimplify_modify_expr (tree *expr_p, gimple_seq *pre_p,
gimple_seq *post_p,
+
+ for (i = 0; i < nargs; i++)
+ {
+- gimplify_arg (&CALL_EXPR_ARG (*from_p, i), pre_p,
+- EXPR_LOCATION (*from_p));
++ /* The object address is diagnostic metadata and must not make
++ its declaration addressable. */
++ if (ifn != IFN_DEFERRED_INIT || i != 2)
++ gimplify_arg (&CALL_EXPR_ARG (*from_p, i), pre_p,
++ EXPR_LOCATION (*from_p));
+ vargs.quick_push (CALL_EXPR_ARG (*from_p, i));
+ }
+ call_stmt = gimple_build_call_internal_vec (ifn, vargs);
+
+ ## gcc/internal-fn.cc ##
+@@ gcc/internal-fn.cc: expand_UNIQUE (internal_fn, gcall *stmt)
+ }
+
+ /* Expand the IFN_DEFERRED_INIT function:
+- LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the DECL);
++ LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, &DECL);
+
+ Initialize the LHS with zero/pattern according to its second argument
+ INIT_TYPE:
+
+ ## gcc/omp-offload.cc ##
+@@ gcc/omp-offload.cc: execute_oacc_device_lower ()
+ that conversion substituted in place of the original ADDR_EXPR node.
+
+ Which of these is done depends on the gimple statement being
processed.
+- At present atomic operations and inline asms use (1), and everything
else
+- uses (2). At least on AMD GCN, there are atomic operations that work
++ At present atomic operations, inline asms and diagnostic object
addresses
++ in .DEFERRED_INIT use (1), and everything else uses (2).
++ At least on AMD GCN, there are atomic operations that work
+ directly in the LDS address space.
+
+ COMPONENT_REFS, ARRAY_REFS and plain VAR_DECLs are also rewritten to
use
+@@ gcc/omp-offload.cc: execute_oacc_device_lower ()
+ info.avoid_pointer_conversion
+ = (is_gimple_call (stmt)
+ && is_sync_builtin_call (as_a <gcall *> (stmt)))
+- || gimple_code (stmt) == GIMPLE_ASM;
++ || gimple_code (stmt) == GIMPLE_ASM
++ || gimple_call_internal_p (stmt, IFN_DEFERRED_INIT);
+ info.stmt = stmt;
+ info.modified = false;
+ info.adjusted_vars = &adjusted_vars;
+
+ ## gcc/testsuite/c-c++-common/auto-init-1.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-1.c: void foo()
+ return;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, \[26],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, \[26],
\&\"temp2\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, \[26],
\&\"temp3\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, \[26],
\&\"temp4\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, \[26],
\&\"temp5\"" "gimple" { target ilp32 } } } */
+-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, \[26],
\&\"temp5\"" "gimple" { target lp64 } } } */
+-/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, \[26],
\&\"temp6\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, \[26],
\&\"temp7\"" "gimple" { target ilp32 } } } */
+-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, \[26],
\&\"temp7\"" "gimple" { target lp64 } } } */
+-/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, \[26],
\&\"temp8\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, \[26],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, \[26],
\&temp2" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, \[26],
\&temp3" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, \[26],
\&temp4" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, \[26],
\&temp5" "gimple" { target ilp32 } } } */
++/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, \[26],
\&temp5" "gimple" { target lp64 } } } */
++/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, \[26],
\&temp6" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, \[26],
\&temp7" "gimple" { target ilp32 } } } */
++/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, \[26],
\&temp7" "gimple" { target lp64 } } } */
++/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, \[26],
\&temp8" "gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-10.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-10.c: void foo()
+ return;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, \[15],
\&\"temp1\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, \[15],
\&temp1" "gimple" } } */
+ /* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(" "gimple"
} } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-11.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-11.c: void foo(int n)
+ return;
+ }
+
+-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[26],
\&\"arr\"" "gimple" } } */
++/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[26], \&arr"
"gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-12.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-12.c: void foo(int n)
+ return;
+ }
+
+-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[15],
\&\"arr\"" "gimple" } } */
++/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[15], \&arr"
"gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-13.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-13.c: int foo()
+ return d.b + var.bar.b;
+ }
+
+-/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, \[15], \&\"d\""
"gimple" } } */
+-/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, \[15],
\&\"var\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, \[15], \&d"
"gimple" } } */
++/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, \[15], \&var"
"gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-14.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-14.c: int foo()
+ return d.b + var.bar.b;
+ }
+
+-/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, \[26], \&\"d\""
"gimple" } } */
+-/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, \[26],
\&\"var\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "d = .DEFERRED_INIT \\(4, \[26], \&d"
"gimple" } } */
++/* { dg-final { scan-tree-dump "var = .DEFERRED_INIT \\(4, \[26], \&var"
"gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-15.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-15.c: void foo(int a)
+ g(x);
+ }
+
+-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[26], \&\"x\""
"gimple" } } */
++/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[26], \&x"
"gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-16.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-16.c: void foo(int a)
+ g(x);
+ }
+
+-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[15], \&\"x\""
"gimple" } } */
++/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(D.\\d*, \[15], \&x"
"gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-2.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-2.c: void foo()
+ return;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, \[15],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, \[15],
\&\"temp2\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, \[15],
\&\"temp3\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, \[15],
\&\"temp4\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, \[15],
\&\"temp5\"" "gimple" { target ilp32 } } } */
+-/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, \[15],
\&\"temp5\"" "gimple" { target lp64 } } } */
+-/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, \[15],
\&\"temp6\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, \[15],
\&\"temp7\"" "gimple" { target ilp32 } } } */
+-/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, \[15],
\&\"temp7\"" "gimple" { target lp64 } } } */
+-/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, \[15],
\&\"temp8\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(1, \[15],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(2, \[15],
\&temp2" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(4, \[15],
\&temp3" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\(4, \[15],
\&temp4" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(4, \[15],
\&temp5" "gimple" { target ilp32 } } } */
++/* { dg-final { scan-tree-dump "temp5 = .DEFERRED_INIT \\(8, \[15],
\&temp5" "gimple" { target lp64 } } } */
++/* { dg-final { scan-tree-dump "temp6 = .DEFERRED_INIT \\(8, \[15],
\&temp6" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(4, \[15],
\&temp7" "gimple" { target ilp32 } } } */
++/* { dg-final { scan-tree-dump "temp7 = .DEFERRED_INIT \\(8, \[15],
\&temp7" "gimple" { target lp64 } } } */
++/* { dg-final { scan-tree-dump "temp8 = .DEFERRED_INIT \\(1, \[15],
\&temp8" "gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-3.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-3.c: long double foo()
+ return result;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, \[26],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, \[26],
\&\"temp2\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16),
\[26], \&\"temp3\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, \[26],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, \[26],
\&temp2" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16),
\[26], \&temp3" "gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-4.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-4.c: long double foo()
+ return result;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, \[15],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, \[15],
\&\"temp2\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16),
\[15], \&\"temp3\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(4, \[15],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(8, \[15],
\&temp2" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((8|12|16),
\[15], \&temp3" "gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-5.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-5.c: _Complex long double foo()
+ return result;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, \[26],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, \[26],
\&\"temp2\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32),
\[26], \&\"temp3\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, \[26],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, \[26],
\&temp2" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32),
\[26], \&temp3" "gimple" } } */
+
+
+ ## gcc/testsuite/c-c++-common/auto-init-6.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-6.c: _Complex long double foo()
+ return result;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, \[15],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, \[15],
\&\"temp2\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32),
\[15], \&\"temp3\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(8, \[15],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(16, \[15],
\&temp2" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\((16|24|32),
\[15], \&temp3" "gimple" } } */
+
+
+ ## gcc/testsuite/c-c++-common/auto-init-7.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-7.c: double foo()
+ return result;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, \[26],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, \[26],
\&\"temp2\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, \[26],
\&\"temp3\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\((8|5), \[26],
\&\"temp4\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, \[26],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, \[26],
\&temp2" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, \[26],
\&temp3" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\((8|5), \[26],
\&temp4" "gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-8.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-8.c: double foo()
+ return result;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, \[15],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, \[15],
\&\"temp2\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, \[15],
\&\"temp3\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\((8|5), \[15],
\&\"temp4\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(12, \[15],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp2 = .DEFERRED_INIT \\(24, \[15],
\&temp2" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp3 = .DEFERRED_INIT \\(28, \[15],
\&temp3" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp4 = .DEFERRED_INIT \\((8|5), \[15],
\&temp4" "gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-9.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-9.c: void foo()
+ return;
+ }
+
+-/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, \[26],
\&\"temp1\"" "gimple" } } */
+-/* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(8, \[26],
\&\"temp2\"" "gimple" } } */
++/* { dg-final { scan-tree-dump "temp1 = .DEFERRED_INIT \\(2, \[26],
\&temp1" "gimple" } } */
++/* { dg-final { scan-tree-dump-not "temp2 = .DEFERRED_INIT \\(8, \[26],
\&temp2" "gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-esra.c ##
+@@
+ /* Verify the strength reduction adjustment for -ftrivial-auto-var-init.
*/
+ /* { dg-do compile } */
+ /* { dg-options "-O2 -ftrivial-auto-var-init=zero -fno-PIC
-fdump-tree-gimple -fdump-tree-esra" } */
++/* { dg-additional-options "-fdump-tree-ssa" } */
+
+
+ typedef double VECTOR[3];
+@@ gcc/testsuite/c-c++-common/auto-init-esra.c: void VCross(VECTOR a,
const VECTOR b, const VECTOR c)
+ Assign_Vector(a, tmp);
+ }
+
+-/* { dg-final { scan-tree-dump-times "tmp = .DEFERRED_INIT \\(24, \[26],
\&\"tmp\"" 1 "gimple" } } */
+-/* { dg-final { scan-tree-dump-times ".DEFERRED_INIT \\(8, \[26],
\&\"tmp\"" 3 "esra" } } */
++/* { dg-final { scan-tree-dump-times "tmp = .DEFERRED_INIT \\(24, \[26],
\&tmp" 1 "gimple" } } */
++/* { dg-final { scan-tree-dump-times ".DEFERRED_INIT \\(8, \[26],
\&tmp\\$" 3 "esra" } } */
++
++/* The diagnostic object address must not prevent SSA promotion. */
++int
++f (void)
++{
++ int x;
++ return x;
++}
++
++/* { dg-final { scan-tree-dump {x_[0-9]+ = \.DEFERRED_INIT} "ssa" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-ifcvt-1.c (new) ##
+@@
++/* Loop if-conversion must preserve diagnostic object addresses. */
++/* { dg-do compile } */
++/* { dg-options "-O2 -fno-ssa-phiopt -ftree-loop-if-convert" } */
++/* { dg-additional-options "-ftrivial-auto-var-init=zero" } */
++
++void
++f (int *out, const int *in, int n)
++{
++ for (int i = 0; i < n; ++i)
++ {
++ int r;
++ if (in[i])
++ {
++ int a;
++ r = a;
++ }
++ else
++ {
++ int b;
++ r = b;
++ }
++ out[i] = r;
++ }
++}
+
+ ## gcc/testsuite/c-c++-common/auto-init-ifcvt-2.c (new) ##
+@@
++/* { dg-do compile } */
++/* { dg-options "-O2 -fno-ssa-phiopt -ftree-loop-if-convert" } */
++/* { dg-additional-options "-ftrivial-auto-var-init=pattern" } */
++
++#include "auto-init-ifcvt-1.c"
+
+ ## gcc/testsuite/c-c++-common/auto-init-padding-1.c ##
+@@ gcc/testsuite/c-c++-common/auto-init-padding-1.c: void foo(int a)
+ g(s);
+ }
+
+-/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(24, \[15], \&\"s\""
"gimple" } } */
++/* { dg-final { scan-tree-dump ".DEFERRED_INIT \\(24, \[15], \&s"
"gimple" } } */
+ /* { dg-final { scan-tree-dump "__builtin_clear_padding" "gimple" } } */
+
+ ## gcc/testsuite/c-c++-common/auto-init-phiopt-1.c (new) ##
+@@
++/* Factoring must not turn diagnostic object addresses into pointer PHIs.
*/
++/* { dg-do compile } */
++/* { dg-options "-O2 -ftrivial-auto-var-init=zero" } */
++
++int
++f (int x)
++{
++ if (x)
++ {
++ int a;
++ return a;
++ }
++ else
++ {
++ int b;
++ return b;
++ }
++}
+
+ ## gcc/testsuite/c-c++-common/auto-init-phiopt-2.c (new) ##
+@@
++/* { dg-do compile } */
++/* { dg-options "-O2 -ftrivial-auto-var-init=pattern" } */
++
++#include "auto-init-phiopt-1.c"
+
## gcc/testsuite/g++.dg/asan/auto-init-uninit-1.C (new) ##
@@
+// { dg-do compile { target c++14 } }
@@ gcc/testsuite/g++.dg/asan/auto-init-uninit-3.C (new)
+ return body (1, value);
+}
+ ## gcc/testsuite/g++.dg/lto/auto-init-uninit_0.C (new) ##
+@@
++// PR middle-end/124380
++// { dg-lto-do link }
++// { dg-extra-ld-options "-r -nostdlib -flinker-output=nolto-rel" }
++// { dg-skip-if "no address sanitizer" { no_fsanitize_address } }
++// { dg-lto-options { { -std=c++14 -O2 -Wuninitialized -Werror
-fsanitize=address,undefined -ftrivial-auto-var-init=zero -flto } { -std=c++14
-O2 -Wuninitialized -Werror -fsanitize=address,undefined
-ftrivial-auto-var-init=pattern -flto } } }
++
++template <typename T>
++const T &
++max (const T &a, const T &b)
++{
++ return a < b ? b : a;
++}
++
++template <typename A, typename B>
++auto
++max_mixed (const A &a, const B &b)
++{
++ const unsigned long &x = a;
++ const unsigned long &y = b;
++ return max (x, y);
++}
++
++unsigned long
++f (unsigned long a)
++{
++ return max_mixed (a, 1);
++}
++
+
+ ## gcc/testsuite/g++.dg/opt/auto-init-debug-1.C (new) ##
+@@
++// Diagnostic metadata must not affect -fcompare-debug.
++// { dg-do compile }
++// { dg-options "-Og -fif-conversion -fno-tree-ccp -fno-tree-copy-prop
-fcompare-debug -ftrivial-auto-var-init=zero" }
++
++#include "pr100852.C"
+
+ ## gcc/testsuite/g++.dg/opt/auto-init-debug-2.C (new) ##
+@@
++// { dg-do compile }
++// { dg-options "-Og -fif-conversion -fno-tree-ccp -fno-tree-copy-prop
-fcompare-debug -ftrivial-auto-var-init=pattern" }
++
++#include "pr100852.C"
+
+ ## gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-1.C (new) ##
+@@
++// The diagnostic address must not become a real parallel argument.
++// { dg-do compile }
++// { dg-require-effective-target pthread }
++// { dg-options "-std=c++26 -O3 -ftrivial-auto-var-init=zero
-ftree-parallelize-loops=2 -fno-tree-loop-im -fdump-tree-parloops2-details" }
++
++template <typename T>
++void
++f (T *__restrict a, T *__restrict b)
++{
++ for (int i = 0; i < 10000; ++i)
++ {
++ T x;
++ if (b[i] > 4)
++ x = b[i];
++ a[i] = x;
++ }
++}
++
++template void f (int *__restrict, int *__restrict);
++template void f (unsigned char *__restrict, unsigned char *__restrict);
++
++// { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2
"parloops2" } }
++// { dg-final { scan-tree-dump-not {paral_data_store[^;]*\.x} "parloops2"
} }
+
+ ## gcc/testsuite/g++.dg/tree-ssa/auto-init-parloops-2.C (new) ##
+@@
++// { dg-do compile }
++// { dg-require-effective-target pthread }
++// { dg-options "-std=c++26 -O3 -ftrivial-auto-var-init=pattern
-ftree-parallelize-loops=2 -fno-tree-loop-im -fdump-tree-parloops2-details" }
++
++#include "auto-init-parloops-1.C"
++
++// { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 2
"parloops2" } }
++// { dg-final { scan-tree-dump-not {paral_data_store[^;]*\.x} "parloops2"
} }
+
## gcc/testsuite/g++.dg/uninit-pr124380.C (new) ##
@@
+// PR middle-end/124380
@@ gcc/testsuite/g++.dg/uninit-pr124380.C (new)
+ three ();
+}
- ## gcc/tree-inline.cc ##
-@@ gcc/tree-inline.cc: remap_gimple_stmt (gimple *stmt, copy_body_data *id)
- }
-
-
-+/* Update the anonymous variable name in CALL to refer to the copied
-+ declaration in ID. */
+ ## gcc/testsuite/gcc.dg/auto-init-nested-1.c (new) ##
+@@
++/* Captured locals must retain their diagnostic declaration when their
++ storage is moved into a nested function's frame. */
++/* { dg-do compile } */
++/* { dg-options "-O2 -Wuninitialized -Werror
-ftrivial-auto-var-init=zero" } */
+
-+static void
-+remap_deferred_init (gcall *call, copy_body_data *id)
++int
++scalar (void)
+{
-+ tree name = gimple_call_arg (call, 2);
-+ name = TREE_OPERAND (TREE_OPERAND (name, 0), 0);
-+ const char *name_str = TREE_STRING_POINTER (name);
-+ if (strncmp (name_str, "D.", 2) != 0 || !ISDIGIT (name_str[2]))
-+ return;
-+
-+ char *end;
-+ unsigned long uid = strtoul (name_str + 2, &end, 10);
-+ if (*end || uid > UINT_MAX)
-+ return;
-+
-+ if (!id->deferred_init_map)
-+ {
-+ /* Build this map once per body copy, rather than searching all
-+ local declarations for each .DEFERRED_INIT call. */
-+ id->deferred_init_map = new hash_map<int_hash<unsigned, -1U>, tree>;
-+ tree var;
-+ unsigned int i;
-+ FOR_EACH_LOCAL_DECL (id->src_cfun, i, var)
-+ if (VAR_P (var) && !DECL_NAME (var))
-+ if (tree *new_var = id->decl_map->get (var))
-+ if (VAR_P (*new_var))
-+ id->deferred_init_map->put (DECL_UID (var), *new_var);
-+ }
++ int x;
++ int read (void) { return x; }
++ x = 42;
++ return read ();
++}
+
-+ if (tree *var = id->deferred_init_map->get (uid))
-+ {
-+ tree new_name;
-+ if (DECL_NAME (*var))
-+ new_name = build_string_literal (DECL_NAME (*var));
-+ else
-+ {
-+ char buf[3 + (HOST_BITS_PER_INT + 2) / 3];
-+ sprintf (buf, "D.%u", DECL_UID (*var));
-+ new_name = build_string_literal (buf);
-+ }
-+ gimple_call_set_arg (call, 2, new_name);
-+ }
++int
++aggregate (void)
++{
++ struct S { int x, y; } s;
++ int read (void) { return s.x + s.y; }
++ s.x = 20;
++ s.y = 22;
++ return read ();
+}
+
+ ## gcc/testsuite/gcc.dg/auto-init-nested-2.c (new) ##
+@@
++/* { dg-do compile } */
++/* { dg-options "-O2 -Wuninitialized -Werror
-ftrivial-auto-var-init=pattern" } */
++
++#include "auto-init-nested-1.c"
+
+ ## gcc/testsuite/gcc.dg/auto-init-nested-3.c (new) ##
+@@
++/* A captured variable's artificial initialization must not hide its
++ subsequent uninitialized use. */
++/* { dg-do compile } */
++/* { dg-options "-O2 -Wuninitialized -ftrivial-auto-var-init=zero" } */
+
- /* Copy basic block, scale profile accordingly. Edges will be taken care
of
- later */
++int
++f (void)
++{
++ int x;
++ int read (void) { return x; }
++ return read (); /* { dg-warning "'x' is used uninitialized" } */
++}
+
+ ## gcc/tree-cfg.cc ##
+@@ gcc/tree-cfg.cc: verify_gimple_call (gcall *stmt)
+ }
-@@ gcc/tree-inline.cc: copy_bb (copy_body_data *id, basic_block bb,
- {
- stmt = gsi_stmt (stmts_gsi);
+ /* For a call to .DEFERRED_INIT,
+- LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, NAME of the DECL)
++ LHS = DEFERRED_INIT (SIZE of the DECL, INIT_TYPE, &DECL)
+ we should guarantee that when the 1st argument is a constant, it
should
+ be the same as the size of the LHS. */
-+ if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
-+ remap_deferred_init (as_a <gcall *> (stmt), id);
+ if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
+ {
++ if (gimple_call_num_args (stmt) != 3
++ || TREE_CODE (gimple_call_arg (stmt, 2)) != ADDR_EXPR
++ || !DECL_P (TREE_OPERAND (gimple_call_arg (stmt, 2), 0)))
++ {
++ error ("invalid object argument to %<.DEFERRED_INIT%>");
++ return true;
++ }
+
- /* Advance iterator now before stmt is moved to seq_gsi. */
- gsi_next (&stmts_gsi);
+ tree size_of_arg0 = gimple_call_arg (stmt, 0);
+ tree size_of_lhs = TYPE_SIZE_UNIT (TREE_TYPE (lhs));
-@@ gcc/tree-inline.cc: copy_cfg_body (copy_body_data * id,
- delete id->dependence_map;
- id->dependence_map = NULL;
- }
-+ if (id->deferred_init_map)
+
+ ## gcc/tree-dfa.cc ##
+@@ gcc/tree-dfa.cc: dump_enumerated_decls (FILE *file, dump_flags_t flags)
+
+ memset (&wi, '\0', sizeof (wi));
+ wi.info = (void *) &decl_list;
++ /* Diagnostic metadata does not represent a use of a declaration. */
++ wi.skip_diagnostic_operands = true;
+ FOR_EACH_BB_FN (bb, cfun)
+ {
+ gimple_stmt_iterator gsi;
+
+ ## gcc/tree-nested.cc ##
+@@ gcc/tree-nested.cc: walk_body (walk_stmt_fn callback_stmt, walk_tree_fn
callback_op,
+ memset (&wi, 0, sizeof (wi));
+ wi.info = info;
+ wi.val_only = true;
++ wi.skip_diagnostic_operands = true;
+ walk_gimple_seq_mod (pseq, callback_stmt, callback_op, &wi);
+ }
+
+
+ ## gcc/tree-parloops.cc ##
+@@ gcc/tree-parloops.cc: eliminate_local_variables_stmt (edge entry,
gimple_stmt_iterator *gsi,
+ gimple *stmt = gsi_stmt (*gsi);
+
+ memset (&dta.info, '\0', sizeof (dta.info));
++ dta.info.skip_diagnostic_operands = true;
+ dta.entry = entry;
+ dta.decl_address = decl_address;
+ dta.changed = false;
+@@ gcc/tree-parloops.cc: separate_decls_in_region_stmt (edge entry, edge
exit, gimple *stmt,
+ copy_name_p);
+ SET_USE (use, copy);
+ }
++
++ /* Keep the diagnostic identity in step with the copied SSA variable.
++ Its address must not be passed through the parallel argument data.
*/
++ if (gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
+ {
-+ delete id->deferred_init_map;
-+ id->deferred_init_map = NULL;
++ tree var = TREE_OPERAND (gimple_call_arg (stmt, 2), 0);
++ int_tree_map elt;
++ elt.uid = DECL_UID (var);
++ tree copy = decl_copies->find (elt).to;
++ if (copy)
++ gimple_call_set_arg (stmt, 2, build_fold_addr_expr (copy));
+ }
+ }
+
+ /* Finds the ssa names used in STMT that are defined outside the
+
+ ## gcc/tree-sra.cc ##
+@@ gcc/tree-sra.cc: scan_function (void)
+ gcall *call = as_a <gcall *> (stmt);
+ for (i = 0; i < gimple_call_num_args (call); i++)
+ {
++ if (i == 2
++ && gimple_call_internal_p (call, IFN_DEFERRED_INIT))
++ continue;
+ bool can_be_returned;
+ if (gimple_call_lhs (call))
+ {
+@@ gcc/tree-sra.cc: get_repl_default_def_ssa_name (struct access *racc,
tree reg_type)
+ static void
+ generate_subtree_deferred_init (struct access *access,
+ tree init_type,
+- tree decl_name,
+ gimple_stmt_iterator *gsi,
+ location_t loc)
+ {
+@@ gcc/tree-sra.cc: generate_subtree_deferred_init (struct access *access,
+ gimple *call
+ = gimple_build_call_internal (IFN_DEFERRED_INIT, 3,
+ TYPE_SIZE_UNIT (TREE_TYPE (repl)),
+- init_type, decl_name);
++ init_type,
++ build_fold_addr_expr (repl));
+ gimple_call_set_lhs (call, repl);
+ gsi_insert_before (gsi, call, GSI_SAME_STMT);
+ update_stmt (call);
+@@ gcc/tree-sra.cc: generate_subtree_deferred_init (struct access *access,
+ }
+ if (access->first_child)
+ generate_subtree_deferred_init (access->first_child, init_type,
+- decl_name, gsi, loc);
++ gsi, loc);
- return new_fndecl;
+ access = access ->next_sibling;
+ }
+@@ gcc/tree-sra.cc: generate_subtree_deferred_init (struct access *access,
}
+
+ /* For a call to .DEFERRED_INIT:
+- var = .DEFERRED_INIT (size_of_var, init_type, name_of_var);
++ var = .DEFERRED_INIT (size_of_var, init_type, &var);
+ examine the LHS variable VAR and replace it with a scalar replacement
if
+ there is one, also replace the RHS call to a call to .DEFERRED_INIT of
+ the corresponding scalar relacement variable. Examine the subtree and
+@@ gcc/tree-sra.cc: sra_modify_deferred_init (gimple *stmt,
gimple_stmt_iterator *gsi)
+ {
+ tree lhs = gimple_call_lhs (stmt);
+ tree init_type = gimple_call_arg (stmt, 1);
+- tree decl_name = gimple_call_arg (stmt, 2);
+
+ struct access *lhs_access = get_access_for_expr (lhs);
+ if (!lhs_access)
+@@ gcc/tree-sra.cc: sra_modify_deferred_init (gimple *stmt,
gimple_stmt_iterator *gsi)
+ gimple_call_set_lhs (stmt, lhs_repl);
+ tree arg0_repl = TYPE_SIZE_UNIT (TREE_TYPE (lhs_repl));
+ gimple_call_set_arg (stmt, 0, arg0_repl);
++ gimple_call_set_arg (stmt, 2, build_fold_addr_expr (lhs_repl));
+ sra_stats.deferred_init++;
+ gcc_assert (!lhs_access->first_child);
+ return SRA_AM_MODIFIED;
+@@ gcc/tree-sra.cc: sra_modify_deferred_init (gimple *stmt,
gimple_stmt_iterator *gsi)
+
+ if (lhs_access->first_child)
+ generate_subtree_deferred_init (lhs_access->first_child,
+- init_type, decl_name, gsi, loc);
++ init_type, gsi, loc);
+ if (lhs_access->grp_covered)
+ {
+ unlink_stmt_vdef (stmt);
- ## gcc/tree-inline.h ##
-@@ gcc/tree-inline.h: struct copy_body_data
- equivalents in the function into which it is being inlined. */
- hash_map<dependence_hash, unsigned short> *dependence_map;
+ ## gcc/tree-ssa-operands.cc ##
+@@ gcc/tree-ssa-operands.cc: operands_scanner::parse_ssa_operands ()
+ case GIMPLE_CALL:
+ /* Add call-clobbered operands, if needed. */
+ maybe_add_call_vops (as_a <gcall *> (stmt));
+- if (gimple_call_internal_p (stmt, IFN_ASSUME))
++ /* The object address in .DEFERRED_INIT is diagnostic metadata,
++ not an address escape or a use of the object's value. */
++ if (gimple_call_internal_p (stmt, IFN_ASSUME)
++ || gimple_call_internal_p (stmt, IFN_DEFERRED_INIT))
+ flags |= opf_non_addressable;
+ /* FALLTHRU */
-+ /* Map anonymous variable UIDs to remapped declarations for
-+ .DEFERRED_INIT calls. */
-+ hash_map<int_hash<unsigned, -1U>, tree> *deferred_init_map;
-+
- /* A list of addressable local variables remapped into the caller
- when inlining a call within an OpenMP SIMD-on-SIMT loop. */
- vec<tree> *dst_simt_vars;
+
+ ## gcc/tree-ssa-uninit.cc ##
+@@ gcc/tree-ssa-uninit.cc: warn_uninit (opt_code opt, tree t, tree var,
gimple *context,
+
+ Or
+
+- 2. A call to .DEFERRED_INIT internal function. Since the original
variable
+- has been eliminated by optimization, we need to get the variable
name,
+- and variable declaration location from this call. We recorded
variable
+- name into VAR_NAME_STR, and will get location info and record warning
+- suppressed info to VAR_DEF_STMT, which is the .DEFERRED_INIT call.
*/
+-
+- const char *var_name_str = NULL;
+- gimple *var_def_stmt = NULL;
++ 2. A call to .DEFERRED_INIT. Its third argument retains the address
++ of the initialized declaration even if optimization has eliminated
++ the variable's storage and the SSA_NAME no longer has a variable. */
+
+ if (!var && !SSA_NAME_VAR (t))
+ {
+- var_def_stmt = SSA_NAME_DEF_STMT (t);
++ gimple *var_def_stmt = SSA_NAME_DEF_STMT (t);
+
+ if (gassign *ass = dyn_cast <gassign *> (var_def_stmt))
+ {
+@@ gcc/tree-ssa-uninit.cc: warn_uninit (opt_code opt, tree t, tree var,
gimple *context,
+
+ if (gimple_call_internal_p (var_def_stmt, IFN_DEFERRED_INIT))
+ {
+- /* Ignore the call to .DEFERRED_INIT that define the original
+- var itself as the following case:
+- temp = .DEFERRED_INIT (4, 2, ���alt_reloc");
+- alt_reloc = temp;
+- In order to avoid generating warning for the fake usage
+- at alt_reloc = temp.
+- */
+- tree lhs_var = NULL_TREE;
+-
+- /* Get the variable name from the 3rd argument of call. */
+- tree var_name = gimple_call_arg (var_def_stmt, 2);
+- var_name = TREE_OPERAND (TREE_OPERAND (var_name, 0), 0);
+- var_name_str = TREE_STRING_POINTER (var_name);
++ tree addr = gimple_call_arg (var_def_stmt, 2);
++ var = TREE_OPERAND (addr, 0);
+
++ /* Do not diagnose the artificial initialization store:
++ temp = .DEFERRED_INIT (4, 2, &var);
++ var = temp;
++ Copies to other variables are real uses and must still warn. */
+ if (is_gimple_assign (context))
+ {
+- if (VAR_P (gimple_assign_lhs (context)))
+- lhs_var = gimple_assign_lhs (context);
+- else if (TREE_CODE (gimple_assign_lhs (context)) == SSA_NAME)
+- lhs_var = SSA_NAME_VAR (gimple_assign_lhs (context));
+- }
+- if (lhs_var)
+- {
+- /* Get the name string for the LHS_VAR.
+- Refer to routine gimple_add_init_for_auto_var. */
+- if (DECL_NAME (lhs_var)
+- && (strcmp (IDENTIFIER_POINTER (DECL_NAME (lhs_var)),
+- var_name_str) == 0))
++ tree lhs = gimple_assign_lhs (context);
++ if (TREE_CODE (lhs) == SSA_NAME)
++ lhs = SSA_NAME_VAR (lhs);
++ if (lhs == var
++ || (lhs && DECL_HAS_VALUE_EXPR_P (var)
++ && operand_equal_p (lhs, DECL_VALUE_EXPR (var), 0)))
+ return;
+- else if (!DECL_NAME (lhs_var))
+- {
+- char lhs_var_name_str_buf[3 + (HOST_BITS_PER_INT + 2) / 3];
+- sprintf (lhs_var_name_str_buf, "D.%u", DECL_UID (lhs_var));
+- if (strcmp (lhs_var_name_str_buf, var_name_str) == 0)
+- return;
+- }
+ }
+- gcc_assert (var_name_str && var_def_stmt);
+ }
+ }
+
+- if (var == NULL_TREE && var_name_str == NULL)
++ if (var == NULL_TREE)
+ return;
+
+ /* Avoid warning if we've already done so or if the warning has been
+@@ gcc/tree-ssa-uninit.cc: warn_uninit (opt_code opt, tree t, tree var,
gimple *context,
+ if (((warning_suppressed_p (context, OPT_Wuninitialized)
+ || (gimple_assign_single_p (context)
+ && get_no_uninit_warning (gimple_assign_rhs1 (context)))))
+- || (var && get_no_uninit_warning (var))
+- || (var_name_str
+- && warning_suppressed_p (var_def_stmt, OPT_Wuninitialized)))
++ || get_no_uninit_warning (var))
+ return;
+
+ /* Use either the location of the read statement or that of the PHI
+@@ gcc/tree-ssa-uninit.cc: warn_uninit (opt_code opt, tree t, tree var,
gimple *context,
+ location = gimple_location (context);
+ else if (phi_arg_loc != UNKNOWN_LOCATION)
+ location = phi_arg_loc;
+- else if (var)
++ else
+ location = DECL_SOURCE_LOCATION (var);
+- else if (var_name_str)
+- location = gimple_location (var_def_stmt);
+
+ auto_diagnostic_group d;
+ gcc_assert (opt == OPT_Wuninitialized || opt ==
OPT_Wmaybe_uninitialized);
+@@ gcc/tree-ssa-uninit.cc: warn_uninit (opt_code opt, tree t, tree var,
gimple *context,
+ var)))
+ return;
+ }
+- else if (var_name_str)
+- {
+- if ((opt == OPT_Wuninitialized
+- && !warning_at (location, opt, "%qs is used uninitialized",
+- var_name_str))
+- || (opt == OPT_Wmaybe_uninitialized
+- && !warning_at (location, opt, "%qs may be used uninitialized",
+- var_name_str)))
+- return;
+- }
+
+ /* Avoid subsequent warnings for reads of the same variable again. */
+- if (var)
+- suppress_warning (var, opt);
+- else if (var_name_str)
+- suppress_warning (var_def_stmt, opt);
++ suppress_warning (var, opt);
+
+ /* Issue a note pointing to the read variable unless the warning
+ is at the same location. */
+- location_t var_loc = var ? DECL_SOURCE_LOCATION (var)
+- : gimple_location (var_def_stmt);
++ location_t var_loc = DECL_SOURCE_LOCATION (var);
+ if (location == var_loc)
+ return;
+
+- if (var)
+- inform (var_loc, "%qD was declared here", var);
+- else if (var_name_str)
+- inform (var_loc, "%qs was declared here", var_name_str);
++ inform (var_loc, "%qD was declared here", var);
+ }
+
+ struct check_defs_data
+@@ gcc/tree-ssa-uninit.cc: check_defs (ao_ref *ref, tree vdef, void *data_)
+
+ /* For address taken variable, a temporary variable is added between
+ the variable and the call to .DEFERRED_INIT function as:
+- _1 = .DEFERRED_INIT (4, 2, &"i1"[0]);
++ _1 = .DEFERRED_INIT (4, 2, &i1);
+ i1 = _1;
+ Ignore this vdef as well. */
+ if (is_gimple_assign (def_stmt)
--
2.56.0