From patchwork Wed Dec 13 07:34:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 847820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-469092-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="s4bmeaMH"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3yxT4H0lDLz9s7B for ; Wed, 13 Dec 2017 18:35:09 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; q=dns; s=default; b=hfh0L+Lk3U6fWa8Y3DlY5FMvaBeZdMMy0C1sfDwkjz/k/BklTO tlGhDQE06xEK1MqXJIR9OKYFD73Tds4Z5vdWgpS8pCZKrdt4gWQDRIFbfBENtcQ3 xAI53CXC+yecO5ZGZB3YS3la5u6PN8wa2DVuF3ZithL/SxJccwy8y7qCY= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:mime-version:content-type; s= default; bh=HLB8sOgStnXvTnf/9iJdrwRck7I=; b=s4bmeaMH/HXXu+K1JyDe TKyWtBf2rEYBN9zmw5tTRsdSxE/EKUEVXQ8K8EMcKyL7CkX4cHV9cxq6Am0bnGrO +RnUjARZytle0tcDSKH0GY87/S2TBtYEy7c5JKjgsQlE1gtvewNC1s8xgVjIals+ UTC0ROJ9HWgeykZsPpbieM4= Received: (qmail 27455 invoked by alias); 13 Dec 2017 07:35:01 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 27405 invoked by uid 89); 13 Dec 2017 07:34:53 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 13 Dec 2017 07:34:51 +0000 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C08F6883AC; Wed, 13 Dec 2017 07:34:50 +0000 (UTC) Received: from freie.home (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8406A756C3; Wed, 13 Dec 2017 07:34:50 +0000 (UTC) Received: from livre (livre.home [172.31.160.2]) by freie.home (8.15.2/8.15.2) with ESMTP id vBD7YMIl003362; Wed, 13 Dec 2017 05:34:22 -0200 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: Igor Tsimbalist Subject: [compare-debug] use call loc for nop_endbr Date: Wed, 13 Dec 2017 05:34:22 -0200 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.3 (gnu/linux) MIME-Version: 1.0 We skip debug insns and notes after a call that needs a nop_endbr, but since a debug insn could be the last in a block, it may affect the loc in the emitted nop_endbr insn. Although this has no effect on codegen, it does mess with debug info a bit, and it causes -fcompare-debug to fail for e.g. libsanitizer's tsan/tsan_platform_linux.cc on x86_64. So, pick the location of the call insn for the nop_endbr insn, to avoid the line number differences in dumps, including -fcompare-debug ones. Also, we don't need to determine what the insert point would be unless we're actually emitting the nop_endbr insn after the call, so rearrange the code to avoid wasting cycles. Finally, it seems like testing for barriers is a mistake. We probably never actually pass that test, for the barriers would hit BB_END first. If we did, we'd end up emitting the nop_endbr outside any BB, even after the end of the function! That would be Very Bad (TM). Now, since the test as it is can't hurt, I figured I wouldn't change the logic right now, just add a comment so that someone involved in endbr stuff can have a second look and hopefully fix it. I'd appreciate if you'd try to drop the BARRIER_P from the loop test, Igor, so as to address the final ??? in the comment I add. Narrowing the skipped notes to only the relevant post-call ones might make sense as well, but it's not quite as important IMHO. Regstrapping with -fcompare-debug on stage3 host and target builds on x86_64- and i686-linux-gnu; ok to install? for gcc/ChangeLog * config/i386/i386.c (rest_of_insert_endbranch): Use call loc for its nop_endbr. --- gcc/config/i386/i386.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index e323102cef59..8960b966b7fc 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -2609,21 +2609,25 @@ rest_of_insert_endbranch (void) { if (INSN_P (insn) && GET_CODE (insn) == CALL_INSN) { - rtx_insn *next_insn = insn; + if (find_reg_note (insn, REG_SETJMP, NULL) == NULL) + continue; + /* Generate ENDBRANCH after CALL, which can return more than + twice, setjmp-like functions. */ + /* Skip notes and debug insns that must be next to the + call insn. ??? This might skip a lot more than + that... ??? Skipping barriers and emitting code + after them surely looks like a mistake; we probably + won't ever hit it, for we'll hit BB_END first. */ + rtx_insn *next_insn = insn; while ((next_insn != BB_END (bb)) && (DEBUG_INSN_P (NEXT_INSN (next_insn)) || NOTE_P (NEXT_INSN (next_insn)) || BARRIER_P (NEXT_INSN (next_insn)))) next_insn = NEXT_INSN (next_insn); - /* Generate ENDBRANCH after CALL, which can return more than - twice, setjmp-like functions. */ - if (find_reg_note (insn, REG_SETJMP, NULL) != NULL) - { - cet_eb = gen_nop_endbr (); - emit_insn_after (cet_eb, next_insn); - } + cet_eb = gen_nop_endbr (); + emit_insn_after_setloc (cet_eb, next_insn, INSN_LOCATION (insn)); continue; }