public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Eric Botcazou <ebotcazou@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r12-8383] Do not use DW_OP_not for TRUTH_NOT_EXPR in conditional expressions Date: Mon, 16 May 2022 09:10:17 +0000 (GMT) [thread overview] Message-ID: <20220516091017.338CE3857815@sourceware.org> (raw) https://gcc.gnu.org/g:ad05a1d7f83aa7ddff9ac6ec5ca65e69042d6907 commit r12-8383-gad05a1d7f83aa7ddff9ac6ec5ca65e69042d6907 Author: Eric Botcazou <ebotcazou@adacore.com> Date: Mon May 16 10:44:09 2022 +0200 Do not use DW_OP_not for TRUTH_NOT_EXPR in conditional expressions DW_OP_not is a bitwise, not a logical NOT, so it computes the wrong result in a DWARF conditional expression. gcc/ * dwarf2out.cc (loc_list_from_tree_1) <TRUTH_NOT_EXPR>: Do a logical instead of a bitwise negation. <COND_EXPR>: Swap the operands if the condition is TRUTH_NOT_EXPR. Diff: --- gcc/dwarf2out.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/gcc/dwarf2out.cc b/gcc/dwarf2out.cc index 5681b01749a..c333c595026 100644 --- a/gcc/dwarf2out.cc +++ b/gcc/dwarf2out.cc @@ -19449,6 +19449,14 @@ loc_list_from_tree_1 (tree loc, int want_address, break; case TRUTH_NOT_EXPR: + list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context); + if (list_ret == 0) + return 0; + + add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_lit0, 0, 0)); + add_loc_descr_to_each (list_ret, new_loc_descr (DW_OP_eq, 0, 0)); + break; + case BIT_NOT_EXPR: op = DW_OP_not; goto do_unop; @@ -19497,6 +19505,15 @@ loc_list_from_tree_1 (tree loc, int want_address, list_ret = loc_list_from_tree_1 (TREE_OPERAND (TREE_OPERAND (loc, 0), 0), 0, context); + /* Likewise, swap the operands for a logically negated condition. */ + else if (TREE_CODE (TREE_OPERAND (loc, 0)) == TRUTH_NOT_EXPR) + { + lhs = loc_descriptor_from_tree (TREE_OPERAND (loc, 2), 0, context); + rhs = loc_list_from_tree_1 (TREE_OPERAND (loc, 1), 0, context); + list_ret + = loc_list_from_tree_1 (TREE_OPERAND (TREE_OPERAND (loc, 0), 0), + 0, context); + } else list_ret = loc_list_from_tree_1 (TREE_OPERAND (loc, 0), 0, context); if (list_ret == 0 || lhs == 0 || rhs == 0)
reply other threads:[~2022-05-16 9:10 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20220516091017.338CE3857815@sourceware.org \ --to=ebotcazou@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).