From patchwork Sun Feb 21 22:34:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12097749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60E55C433E0 for ; Sun, 21 Feb 2021 22:35:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2FC7564EC3 for ; Sun, 21 Feb 2021 22:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231613AbhBUWfj (ORCPT ); Sun, 21 Feb 2021 17:35:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231272AbhBUWfi (ORCPT ); Sun, 21 Feb 2021 17:35:38 -0500 Received: from mail-ej1-x634.google.com (mail-ej1-x634.google.com [IPv6:2a00:1450:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BBFEC061786 for ; Sun, 21 Feb 2021 14:34:58 -0800 (PST) Received: by mail-ej1-x634.google.com with SMTP id g5so26264203ejt.2 for ; Sun, 21 Feb 2021 14:34:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PESktqMOy9uAdSFpdYi1YwHT32+LCSPy4rbiJuBOqIU=; b=Ct67mM9P+X/DajdsltV/PYg1M+Ui8hHCQHrNco7zvXaUM09ZhQH8WIX0aSCyTAuvj8 P/biKqKhP+L3ypPCmW++qq7aNqJwPYMQU8HOrfq0apCcFkAa2qB+LS6QPTPzvdSiICHm MbyWO6TwvZJDp2o5Z5dnqdr5HCYbDjq85pN89JAtuv8mqUBjJNP3KiXfbNv1t0cE5yPw yTA1rws+AsTICR1eauByawR85w4ifMCtpBmH3JQer75ilHXRljN9WTaZd2D1kyHRMmBI MPChQjN8QsXJDz4r3wU1Gecs9cV+BUS1zzC3i9iSX0Q7VccXiCPE+vQPWDCPTfM09JT9 PX0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PESktqMOy9uAdSFpdYi1YwHT32+LCSPy4rbiJuBOqIU=; b=lXxpo0Xid4Bpc3flGDHp4kx3UzO7P8EDXAX/59h/UBsdTwt/Wa0NI0EvzG1xRGJMlv sqPVJZRgMM66OyPIgcHiFK0Nhv4hwR+RQyyVRpypoo6U3Imym0rO48NNqINPep0IzrBy KYY6seDalAauo7xjs9ECwKjbQB37KxIHqfWnCUffzWppehEtWbgrQc2MPmMC6t6HnUY+ j+TgDDfLL/iilZSTZzEy0jlPvMridDKK4fSbkiZ0e+PTKTl+8wBkewjTNs0QKtixgtAE MJWlDU9YGnhmeD6mUdtPxaEOFJhLx8wFWR0BX/bMsicej5C6a+AxRX6b9P03MKJSQRN3 howw== X-Gm-Message-State: AOAM53203oOnkBQmaOF+5mfGAxSIOT3tef+86aSxVYBr5RdCqlw7dpwM NyXgLFXPuE13udcT66cMx7vyggYw2CA= X-Google-Smtp-Source: ABdhPJwGT2YX65oB4UJzdBTRU0xEMhIXJWTmybyvVRdvl3PMzztAyag9xVybYOe/KFUIvoLIvoQaQw== X-Received: by 2002:a17:907:9209:: with SMTP id ka9mr18186215ejb.123.1613946897100; Sun, 21 Feb 2021 14:34:57 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:9463:3f6a:e4eb:cf54]) by smtp.gmail.com with ESMTPSA id p2sm10433622edm.94.2021.02.21.14.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 14:34:56 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 1/5] reorg dominates() Date: Sun, 21 Feb 2021 23:34:48 +0100 Message-Id: <20210221223452.8075-2-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> References: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org To prepare the handling of OP_ASM instructions, reorganize the opcode tests to use a switch. Signed-off-by: Luc Van Oostenryck --- flow.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/flow.c b/flow.c index bda277aa551b..5751ce756518 100644 --- a/flow.c +++ b/flow.c @@ -490,12 +490,15 @@ static inline int distinct_symbols(pseudo_t a, pseudo_t b) */ int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom, int local) { - int opcode = dom->opcode; - - if (opcode == OP_CALL || opcode == OP_ENTRY) + switch (dom->opcode) { + case OP_CALL: case OP_ENTRY: return local ? 0 : -1; - if (opcode != OP_LOAD && opcode != OP_STORE) + case OP_LOAD: case OP_STORE: + break; + default: return 0; + } + if (dom->src != pseudo) { if (local) return 0; From patchwork Sun Feb 21 22:34:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12097753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 722C2C433DB for ; Sun, 21 Feb 2021 22:35:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4518064EC8 for ; Sun, 21 Feb 2021 22:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231272AbhBUWfj (ORCPT ); Sun, 21 Feb 2021 17:35:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52970 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbhBUWfj (ORCPT ); Sun, 21 Feb 2021 17:35:39 -0500 Received: from mail-ej1-x62f.google.com (mail-ej1-x62f.google.com [IPv6:2a00:1450:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D69E1C06178A for ; Sun, 21 Feb 2021 14:34:58 -0800 (PST) Received: by mail-ej1-x62f.google.com with SMTP id u20so25515680ejb.7 for ; Sun, 21 Feb 2021 14:34:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c2P241TTdYskntJuomQfjws2swqOAOJkaJvgVOeIZR4=; b=rx3Hppwh62vp/p4Wvmqzcpmo435yrH+0CAoLGaG5DhzRYSivKUcCBdP2qUIbzokNKm q9E+JfyBaSaaazMZmUeBW7KMVthz7XI/ToAKiLCPi3VfdQ6PKwKcterlrhK3r5ciyRhg cGWFWuzE9L7dI4pCO+q5CLu2yIAZ8+lUO3YQl8b1WLirtJ+3/OmN/nGwVOrhk2lzapsE Tp5zed7DBAXQsbhKcFO/CMZKN7jfuHXPX1sP811ramTzwBWHn84ji/JICwCjbvxbs3cL Zcv2WiAiR+ThwLjRZl1piqjwIL/gQhhChzjRsr/6G3gYBxjET2mk8Ive61eFcHW6keIn LD9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=c2P241TTdYskntJuomQfjws2swqOAOJkaJvgVOeIZR4=; b=KwHhDAZ5OvH7zi/MK/9t/Oh3fY5qliIHd30R9aM4kzIlziyuumx+jfrUnjSh6GtFJ9 kB0oA3eDioPh49+07bGnXS3h3pqcGr7wliXTQCaG4TdVM1WXEn6qZH91HsamnArPrjjR 5tO1aiNR1bP1JfSlQHFhLPmUzs8q6C3h1irbDF36Nq4zDOCZkOsxzxx2Sn5Y57Bnhbsu 9+vizRTH4nFEY0CJ2oj5aSIxF/iQDbNAdHlKhCoCJYtU5GsHx0UT7ERHsXxbJKkDe56J giP7vqQfe0rEVFOxJqn3FsviiSdV/qNqIlLJ+KfTOECrSdpAbxnoB5zCRrGJdEMCGk2A ovcA== X-Gm-Message-State: AOAM531TSQSkUpMEk2ezVd7caqAOt28ySTxbktN0eRN3tmR9/03qqSB1 g3ZxUa76OeSdqcIVRjZUd18tOiVNwcw= X-Google-Smtp-Source: ABdhPJzLqaIxW8kVvPz1EsDJZtznS74Lg2Mh/fP9CdDJIN1BrlHdttROCl3Z6r09z0yPaEBR09lJZA== X-Received: by 2002:a17:907:7667:: with SMTP id kk7mr6364125ejc.92.1613946897712; Sun, 21 Feb 2021 14:34:57 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:9463:3f6a:e4eb:cf54]) by smtp.gmail.com with ESMTPSA id p2sm10433622edm.94.2021.02.21.14.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 14:34:57 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 2/5] asm-mem: add testcase for missing reload after asm memops Date: Sun, 21 Feb 2021 23:34:49 +0100 Message-Id: <20210221223452.8075-3-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> References: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org Memory simplification is done with the help of the function dominates() which determine when memory instructions interfere. This function handles OP_CALLs, OP_LOADs and OP_STOREs but memory can also be changed via OP_ASMs. Add a testcase showing this. Signed-off-by: Luc Van Oostenryck --- validation/mem2reg/asm-reload0.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 validation/mem2reg/asm-reload0.c diff --git a/validation/mem2reg/asm-reload0.c b/validation/mem2reg/asm-reload0.c new file mode 100644 index 000000000000..c9e297dde428 --- /dev/null +++ b/validation/mem2reg/asm-reload0.c @@ -0,0 +1,15 @@ +static int asm_reload(void) +{ + int mem = 0; + asm volatile ("[%1] <= 1" : "=m" (mem)); + return mem; +} + +/* + * check-name: asm-reload0 + * check-command: test-linearize $file + * check-known-to-fail + * + * check-output-ignore + * check-output-contains: load\\. + */ From patchwork Sun Feb 21 22:34:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12097755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 89B32C433E9 for ; Sun, 21 Feb 2021 22:35:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A72D61606 for ; Sun, 21 Feb 2021 22:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231760AbhBUWfp (ORCPT ); Sun, 21 Feb 2021 17:35:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231695AbhBUWfk (ORCPT ); Sun, 21 Feb 2021 17:35:40 -0500 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C06BC06178B for ; Sun, 21 Feb 2021 14:34:59 -0800 (PST) Received: by mail-ej1-x629.google.com with SMTP id d8so26228273ejc.4 for ; Sun, 21 Feb 2021 14:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/EzbR+Du2BxaJJadZeD2HbcmcwMUcvujgdONk2vLKNQ=; b=JGMslxXiA4l/HqLLmh0a7bkzBkb3dFSaO2ozayzefDIZheaVUfv8cYetPfli0vrGt3 orJS0zHUUMBwgxoHOGR5Gy9Xy2Y6eJG/rSCAQJNBwAjwbD7sMJjzDYUYaU4jnNbr1iWN 3jV8CgiFQfHzsbvB1ZqKmJWA09CXSMkcQRgCovus8As86QLKuL+S5XVN/RQk5FvStc6R 7uPBStxrBkdiuX9XbJxZJRv0S8C1szP+I4+Kd2I1qxeQgAKSisRHEVUyNBVuuDjr0zpF JIRpDxMmtEq7YIi+qh5r8Epuz2qrrPJnfJDfGfxeYIp9dsMSiSQ03XqcsezToziTWZNE 4Zsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/EzbR+Du2BxaJJadZeD2HbcmcwMUcvujgdONk2vLKNQ=; b=dng6GUg5+hnHnOjY9eZKcalm5LSqP3yOToOQELreGs1YThdpX/j/8bxHAYLoq5lmPj hUatq0TfbHHTjGqxBV2QtJOSs7MjHQpP2PguXOSVi58nd5Hu7AW8KEEhE/KA4CYl6cvY BkEiBv7FeIx21zWRBJBhqLdIEtvgJ5kap45yxCPegWww2ykuJ2TsvZCm/Cb61pKLe2PF NrimDjyjtu21KfGMxbO2ZbhFNpMAdnMCDGMNji/cdDzzjMjxYTx2Z/j0bQ3yNT5e5jPB CoTSQ1duHdvMgbWS76mb8h61vagw7B1b34M24BvV5oJyGLMIYhs3155oeCpFdwme1xrX 17ZQ== X-Gm-Message-State: AOAM531eVCJ3gHiWJgifGkmvkHSbaOKyg+inxl/brjRt2XQy3cC7CrX9 ztduxbWL6JNRdEJcLfiraNMB5vSCfYI= X-Google-Smtp-Source: ABdhPJwHOMpae5b3Qpg/i4AubJ9xFG5tDhMSk5gFrGQoC4r2ml8dFrc3N9o/LEDQgyOKMauD2pb8SA== X-Received: by 2002:a17:906:b0d8:: with SMTP id bk24mr18675378ejb.252.1613946898327; Sun, 21 Feb 2021 14:34:58 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:9463:3f6a:e4eb:cf54]) by smtp.gmail.com with ESMTPSA id p2sm10433622edm.94.2021.02.21.14.34.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 14:34:58 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 3/5] asm-mem: does it clobber memory? Date: Sun, 21 Feb 2021 23:34:50 +0100 Message-Id: <20210221223452.8075-4-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> References: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org An asm statement can specify that it clobbers memory. Add this info directly in the corresponding instruction, avoiding the need to scan the clobber list each time. Signed-off-by: Luc Van Oostenryck --- linearize.c | 8 +++++++- linearize.h | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/linearize.c b/linearize.c index 33d641b40de6..4140b60caebd 100644 --- a/linearize.c +++ b/linearize.c @@ -2174,7 +2174,7 @@ static void add_asm_output(struct entrypoint *ep, struct instruction *insn, stru static pseudo_t linearize_asm_statement(struct entrypoint *ep, struct statement *stmt) { struct instruction *insn; - struct expression *expr; + struct expression *expr, *clob; struct asm_rules *rules; struct asm_operand *op; @@ -2206,6 +2206,12 @@ static pseudo_t linearize_asm_statement(struct entrypoint *ep, struct statement add_asm_output(ep, insn, op); } END_FOR_EACH_PTR(op); + /* and finally, look if it clobbers memory */ + FOR_EACH_PTR(stmt->asm_clobbers, clob) { + if (!strcmp(clob->string->data, "memory")) + insn->clobber_memory = 1; + } END_FOR_EACH_PTR(clob); + return VOID; } diff --git a/linearize.h b/linearize.h index a77e4b3e5f6f..fb51327684bb 100644 --- a/linearize.h +++ b/linearize.h @@ -150,6 +150,7 @@ struct instruction { struct /* asm */ { const char *string; struct asm_rules *asm_rules; + int clobber_memory:1; }; }; }; From patchwork Sun Feb 21 22:34:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12097751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9DEACC43381 for ; Sun, 21 Feb 2021 22:35:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7169B64EBE for ; Sun, 21 Feb 2021 22:35:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231695AbhBUWft (ORCPT ); Sun, 21 Feb 2021 17:35:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52980 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231614AbhBUWfl (ORCPT ); Sun, 21 Feb 2021 17:35:41 -0500 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85985C06178C for ; Sun, 21 Feb 2021 14:35:00 -0800 (PST) Received: by mail-ed1-x529.google.com with SMTP id q10so19592972edt.7 for ; Sun, 21 Feb 2021 14:35:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vIv1t53ectFeOVyiXsEEZ4xhYCJ930zM41PWD/+TfVs=; b=MKhwEYJFWT4sG1crsLZKzanRL++c5LI/eVa2ZFaW97c3tlw03dVjfHEuopK/tMXH7v OrSXpSBVRDZt54UGHkS2RLJEfFqBmhjrNcPQtNogAk4TTfT2mKQkqNDeDwzJ1yHSFuQ4 iek5iCy7A44F59J76RPtiTbJF7pfSSMgznE8YbjTNKFr1QUklrfa+Cl+j034+KF4fzmN ObvqV39LlJTKt45yFieXO+kkLFeKM6rknjXrJ7hHqN2iFa+HLmrpLlepFBD9QwiJWzek /YYhfnFAoEVBKC8LGl5MHP5cSVObplp1XY1DkUcsYQUCppoNQbpoZ8FKDQRIJj1CAKO5 s5Kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vIv1t53ectFeOVyiXsEEZ4xhYCJ930zM41PWD/+TfVs=; b=k1SStB720DMrbZ7yjeOTLLkLZnj389cI1sbw1swTV1vcTL95Nrn3kHOP+dLEaixITc AAxTERvK5npn9QIoSz/FJDB/ShHPmVnMiLYha7b5kGi1EPjH5uusGY8KrEuCTXhCx/Ox fYT53lht7DeeFG2Q/sF8siWMY/er3sQU9VjlNfFWAfg1gu4rusZ7MR8FvRCc5jwDHDKV lqzIfny9ZaDlSfguw1xDCZNvNMTu+YrrsOnYNhdE93tFDkKeIqi5n96aN8w1/C2ZJ24e PnsoFHGhaYPfFe834Mijn6TxGntBrJ2kDPKoTPKfP6/i39cB59PCFWv8F0Hm435LCTvj EKzw== X-Gm-Message-State: AOAM532jD0IZI6wRIqh3Ws/6YDf7oyEaKgztJK24gQJc5H5XAbPel+Nc 9Z97myVz40nCZ++zl0S+CnCdqdMzYHY= X-Google-Smtp-Source: ABdhPJyuS+JJJ+EzTgwpperqj5GL2l43kEKo7DqeXb7oJJWZUtkFkuhGBK5WVSLyrOQMvDXlNKtq2A== X-Received: by 2002:a05:6402:278a:: with SMTP id b10mr20033858ede.347.1613946898923; Sun, 21 Feb 2021 14:34:58 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:9463:3f6a:e4eb:cf54]) by smtp.gmail.com with ESMTPSA id p2sm10433622edm.94.2021.02.21.14.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 14:34:58 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 4/5] asm-mem: does it output to memory? Date: Sun, 21 Feb 2021 23:34:51 +0100 Message-Id: <20210221223452.8075-5-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> References: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org If an asm statement have a memory output operand, it modifies memory. Since this information is needed during memops simplification, add this info directly in the corresponding instruction, avoiding the need to scan the output operands list each time. Signed-off-by: Luc Van Oostenryck --- linearize.c | 1 + linearize.h | 1 + 2 files changed, 2 insertions(+) diff --git a/linearize.c b/linearize.c index 4140b60caebd..0c9b0e59cc4b 100644 --- a/linearize.c +++ b/linearize.c @@ -2153,6 +2153,7 @@ static void add_asm_output_address(struct entrypoint *ep, struct instruction *in pseudo = linearize_expression(ep, op->expr); add_asm_rule(insn, &insn->asm_rules->outputs, op, pseudo); + insn->output_memory = 1; } static void add_asm_output(struct entrypoint *ep, struct instruction *insn, struct asm_operand *op) diff --git a/linearize.h b/linearize.h index fb51327684bb..cf0cf066a8e5 100644 --- a/linearize.h +++ b/linearize.h @@ -151,6 +151,7 @@ struct instruction { const char *string; struct asm_rules *asm_rules; int clobber_memory:1; + int output_memory:1; }; }; }; From patchwork Sun Feb 21 22:34:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luc Van Oostenryck X-Patchwork-Id: 12097757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D469FC433DB for ; Sun, 21 Feb 2021 22:36:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F78964EBE for ; Sun, 21 Feb 2021 22:36:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231767AbhBUWgU (ORCPT ); Sun, 21 Feb 2021 17:36:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231752AbhBUWgS (ORCPT ); Sun, 21 Feb 2021 17:36:18 -0500 Received: from mail-ej1-x633.google.com (mail-ej1-x633.google.com [IPv6:2a00:1450:4864:20::633]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1C08C061793 for ; Sun, 21 Feb 2021 14:35:00 -0800 (PST) Received: by mail-ej1-x633.google.com with SMTP id u20so25515747ejb.7 for ; Sun, 21 Feb 2021 14:35:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=I9nMWVEoxwtXF283A8tddKxyHk0BWKf9Ft8bmoloBW4=; b=LLSQKlBlbq2536UjQAIMDXX7bRKsQlEiCYEbVorLr131hnoQN7BbxIuCJKDl/KjMk8 HC+LYvwh9m4f+h1OdhOUgUNYVbkhfcpHk58Rb2H5ZzKRoVJTgYiQGt8Zpn3sm8AJEBJD Kz0aFI6NYW1/v79PWT0n9IK6LvJunkctPr+piNbinc1P+Oyx6uDpoNzwnVD+Z/r7Q3Ya bxYyfee9aCxjklR4zhQwtffT89jbrDscKxS1Hq4azoWWA6c5B61Ob2JAMMs4EHPjGP1b 4RtIqAbsANWhWHi4YDA0ey9pp820x2te+xdjKNcq4oVGFwdEypmloaasA+ozKzpiQ8Tb H4hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I9nMWVEoxwtXF283A8tddKxyHk0BWKf9Ft8bmoloBW4=; b=Z64hYO/RMoxOpzuxaCcz+j4ePb3kObJPehxs6rz0wSGcMjnbtfJI6FBzIs9Lu1Kq9k gzUIiZ1bYiiRhXTX0G3bUW1ubmiNYgsUETwphoocG/ygT70ij8PjGt3s4BR7Ldq0zKzP YcGMt/K+7LrRjmQgUGKxjGHayAnIMOAaE2KYX4Sm5a0ZMsBawAzDjPaEnGfNPe/aw2mN mkBHI60eX+s/V1hFD93USbhrzsI2kHZq4p+cR5/Xf/Z4YVRXjv+2nvpjJPjRAQUdF/c4 dGeadVigjowa1ZSehcZ6zwthlRHuU3D/syz4I1mW0ryaDCblOTUZu/pYMEYs3ebGen5w Jijg== X-Gm-Message-State: AOAM5325FK1A88OMhXu8AiXa6Xqk6yeDTu7bgljtaAEKDq4JBB2FtSc4 3ER6qlyFIW3gF8r+11YLmqYuO3yvqb4= X-Google-Smtp-Source: ABdhPJzWPLwo+phI9cdlcfc2krmuPqAMRLFt+8uRXBpwPsUJERPGbsJS3o4fVoBGgGFtwFQFrwLdGw== X-Received: by 2002:a17:906:b24c:: with SMTP id ce12mr16894666ejb.278.1613946899590; Sun, 21 Feb 2021 14:34:59 -0800 (PST) Received: from localhost.localdomain ([2a02:a03f:b7fe:f700:9463:3f6a:e4eb:cf54]) by smtp.gmail.com with ESMTPSA id p2sm10433622edm.94.2021.02.21.14.34.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Feb 2021 14:34:59 -0800 (PST) From: Luc Van Oostenryck To: linux-sparse@vger.kernel.org Cc: Luc Van Oostenryck Subject: [PATCH 5/5] asm-mem: teach dominates() about OP_ASM Date: Sun, 21 Feb 2021 23:34:52 +0100 Message-Id: <20210221223452.8075-6-luc.vanoostenryck@gmail.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> References: <20210221223452.8075-1-luc.vanoostenryck@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org The function dominates() needs to know if an OP_ASM instruction may modify. Use the information now available in the instruction to return the answer. Signed-off-by: Luc Van Oostenryck --- flow.c | 6 ++++++ validation/mem2reg/asm-reload0.c | 1 - 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/flow.c b/flow.c index 5751ce756518..5d63018798d6 100644 --- a/flow.c +++ b/flow.c @@ -495,6 +495,12 @@ int dominates(pseudo_t pseudo, struct instruction *insn, struct instruction *dom return local ? 0 : -1; case OP_LOAD: case OP_STORE: break; + case OP_ASM: + if (dom->clobber_memory) + return -1; + if (dom->output_memory) + return -1; + return 0; default: return 0; } diff --git a/validation/mem2reg/asm-reload0.c b/validation/mem2reg/asm-reload0.c index c9e297dde428..ce1829e02724 100644 --- a/validation/mem2reg/asm-reload0.c +++ b/validation/mem2reg/asm-reload0.c @@ -8,7 +8,6 @@ static int asm_reload(void) /* * check-name: asm-reload0 * check-command: test-linearize $file - * check-known-to-fail * * check-output-ignore * check-output-contains: load\\.