public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-2335] analyzer: use DECL_DEBUG_EXPR on SSA names for artificial vars
@ 2021-07-15 19:03 David Malcolm
0 siblings, 0 replies; only message in thread
From: David Malcolm @ 2021-07-15 19:03 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:e9711fe482b4abef0e7572809d3593631991276e
commit r12-2335-ge9711fe482b4abef0e7572809d3593631991276e
Author: David Malcolm <dmalcolm@redhat.com>
Date: Thu Jul 15 15:02:42 2021 -0400
analyzer: use DECL_DEBUG_EXPR on SSA names for artificial vars
gcc/analyzer/ChangeLog:
* analyzer.cc (fixup_tree_for_diagnostic_1): Use DECL_DEBUG_EXPR
if it's available.
* engine.cc (readability): Likewise.
Signed-off-by: David Malcolm <dmalcolm@redhat.com>
Diff:
---
gcc/analyzer/analyzer.cc | 9 +++++++--
gcc/analyzer/engine.cc | 19 ++++++++++++++++---
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/gcc/analyzer/analyzer.cc b/gcc/analyzer/analyzer.cc
index 12c03f6cfbd..a8ee1a1a2dc 100644
--- a/gcc/analyzer/analyzer.cc
+++ b/gcc/analyzer/analyzer.cc
@@ -165,8 +165,13 @@ fixup_tree_for_diagnostic_1 (tree expr, hash_set<tree> *visited)
&& TREE_CODE (expr) == SSA_NAME
&& (SSA_NAME_VAR (expr) == NULL_TREE
|| DECL_ARTIFICIAL (SSA_NAME_VAR (expr))))
- if (tree expr2 = maybe_reconstruct_from_def_stmt (expr, visited))
- return expr2;
+ {
+ if (tree var = SSA_NAME_VAR (expr))
+ if (VAR_P (var) && DECL_HAS_DEBUG_EXPR_P (var))
+ return DECL_DEBUG_EXPR (var);
+ if (tree expr2 = maybe_reconstruct_from_def_stmt (expr, visited))
+ return expr2;
+ }
return expr;
}
diff --git a/gcc/analyzer/engine.cc b/gcc/analyzer/engine.cc
index 01b83a4ef28..8f3e7f781b2 100644
--- a/gcc/analyzer/engine.cc
+++ b/gcc/analyzer/engine.cc
@@ -527,9 +527,22 @@ readability (const_tree expr)
case SSA_NAME:
{
if (tree var = SSA_NAME_VAR (expr))
- /* Slightly favor the underlying var over the SSA name to
- avoid having them compare equal. */
- return readability (var) - 1;
+ {
+ if (DECL_ARTIFICIAL (var))
+ {
+ /* If we have an SSA name for an artificial var,
+ only use it if it has a debug expr associated with
+ it that fixup_tree_for_diagnostic can use. */
+ if (VAR_P (var) && DECL_HAS_DEBUG_EXPR_P (var))
+ return readability (DECL_DEBUG_EXPR (var)) - 1;
+ }
+ else
+ {
+ /* Slightly favor the underlying var over the SSA name to
+ avoid having them compare equal. */
+ return readability (var) - 1;
+ }
+ }
/* Avoid printing '<unknown>' for SSA names for temporaries. */
return -1;
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-07-15 19:03 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-15 19:03 [gcc r12-2335] analyzer: use DECL_DEBUG_EXPR on SSA names for artificial vars David Malcolm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).