From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 216973858404 for ; Fri, 8 Dec 2023 01:15:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 216973858404 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 216973858404 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701998151; cv=none; b=lVq2zxTg2Kf0vBHgsJnqWXwzOvdZxj5p35pQiw4zQ3CLvYelrOP124h0OettXuqrAsRVgnDlWyLpEDe9ooyvlTNiZgQvxxBYYLxT+9dP8ym8BCEut4ZIyWBxIFUoV+ZSaVN0ZY9YGCOG/WK/6p6wiBdgJQQ3LMI0JlZGOCR30LE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1701998151; c=relaxed/simple; bh=6/XEDHDTTi8nyHs7w9n7gbCowSWWv16T+LjjL/bQ92k=; h=DKIM-Signature:Message-ID:Subject:From:To:Date:MIME-Version; b=qX5G1pn02C3S9hQtOB0c37JcwKZ1CxHgdyZHjHdAG81UYj66aqgK9qT8C+vsdTCtBbZyEgf0K9NiaK1IKPOolBamZwHbcYiZtHmQMHUyTpALWVxQiik1h8BNok5MrUTC1FzuqDfELPGJxBlW+ufkSqVjvm6E8oDHV7mcRVu0DR4= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1701998148; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5m6DCzkFwCU9B+tuXu3vhS36Rjbvsq7oSGALFeph3CM=; b=XV6rXWg4EqaNeXMSidjC2eTSc6rkDg+RBplDo67fJ9vAAkJpkJuZ1iymgRe8O66oFyn2eB FeW5AObrfUGa3pjFZQTHepftCGAUokLJHMr3iaw7ot4wxpPnksHgZcVhNu08gJ8i0rGUs/ R3CzILJMBSmynYDbowQdr/2uYZoCz3Y= Received: from mail-qt1-f198.google.com (mail-qt1-f198.google.com [209.85.160.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-Q53TRhBFOCyEWLsD42FB2A-1; Thu, 07 Dec 2023 20:15:45 -0500 X-MC-Unique: Q53TRhBFOCyEWLsD42FB2A-1 Received: by mail-qt1-f198.google.com with SMTP id d75a77b69052e-42599db593fso9943781cf.0 for ; Thu, 07 Dec 2023 17:15:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701998145; x=1702602945; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=5m6DCzkFwCU9B+tuXu3vhS36Rjbvsq7oSGALFeph3CM=; b=wyxbjamOlzznApezw21vAiSmKbBXeNtwpftptcgbc3dsI2Bh7/a+92aMBNJJ2CQBu/ 8jMl8BnjTzuenHJRNv5AhUBaE0CquXOOTGvRHophBXijsH3b6R/mxtn+B0sqYhPNh/GE yZVCBXpZXGi0PMcFq/Qku2ZtPN+N1d9t82Zn/Puuq5DjtCu5JmX4Al/SKCusmwoCgXuR BPCNHdzp7iV2qcL2rB9arMpBbo2H82Rcvaagp+bJ7O/RD8Wybik5lG7XQo/Gzti1i/2x o7FKdeZWDjRU6sJwxca+3ZUaqdKDPLL6XxM/UpaQHyGbTvaATqWv5zUA7Ula7IGnE7rf DtgQ== X-Gm-Message-State: AOJu0YxYIrZVuVN7/dJ9RZb8ef4WyLv2o/xq+c8iDTHJlEJANYIh5t33 6nbMW9DGX3eZA17HBYOVn98aRPeq37FB1RfdfLzJLGhOa1fIvpuK/w/ieh9rY7fy6if1r5oO3mt TpkDLA6c= X-Received: by 2002:a05:622a:346:b0:41c:d62b:fb51 with SMTP id r6-20020a05622a034600b0041cd62bfb51mr227939qtw.26.1701998145348; Thu, 07 Dec 2023 17:15:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IHABvZtMtG3NewsjAF8mOh8VuJ2jjtNPvV7fkxE6bHY+VT/+wpyUGWT7bQHljO7C1HzyuF+xQ== X-Received: by 2002:a05:622a:346:b0:41c:d62b:fb51 with SMTP id r6-20020a05622a034600b0041cd62bfb51mr227926qtw.26.1701998145105; Thu, 07 Dec 2023 17:15:45 -0800 (PST) Received: from t14s.localdomain (c-76-28-97-5.hsd1.ma.comcast.net. [76.28.97.5]) by smtp.gmail.com with ESMTPSA id y17-20020ac85251000000b00425438e7c5esm362914qtn.62.2023.12.07.17.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Dec 2023 17:15:44 -0800 (PST) Message-ID: Subject: Re: [PATCH] libgccjit: Add type checks in gcc_jit_block_add_assignment_op From: David Malcolm To: Antoni Boucher , jit@gcc.gnu.org, gcc-patches@gcc.gnu.org Date: Thu, 07 Dec 2023 20:15:43 -0500 In-Reply-To: <447a6c24782a4275736dd38f35e17e42612ee80d.camel@zoho.com> References: <447a6c24782a4275736dd38f35e17e42612ee80d.camel@zoho.com> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-5.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Thu, 2023-12-07 at 17:34 -0500, Antoni Boucher wrote: > Hi. > This patch adds checks gcc_jit_block_add_assignment_op to make sure > it > is only ever called on numeric types. >=20 > With the previous patch, this might require a change to also allow > vector types here. >=20 > Thanks for the review. Thanks for the patch. [...snip...] > @@ -2890,6 +2900,17 @@ gcc_jit_block_add_assignment_op (gcc_jit_block *bl= ock, > lvalue->get_type ()->get_debug_string (), > rvalue->get_debug_string (), > rvalue->get_type ()->get_debug_string ()); > + // TODO: check if it is a numeric vector? > + RETURN_IF_FAIL_PRINTF3 ( > + lvalue->get_type ()->is_numeric () && rvalue->get_type ()->is_numeri= c (), ctxt, loc, > + "gcc_jit_block_add_assignment_op %s has non-numeric lvalue %s (type:= %s)", > + gcc::jit::binary_op_reproducer_strings[op], > + lvalue->get_debug_string (), lvalue->get_type ()->get_debug_string (= )); The condition being tested here should probably just be: lvalue->get_type ()->is_numeric () since otherwise if the lvalue's type is numeric and the rvalue's type fails to be, then the user would incorrectly get a message about the lvalue. > + RETURN_IF_FAIL_PRINTF3 ( > + rvalue->get_type ()->is_numeric () && rvalue->get_type ()->is_numeri= c (), ctxt, loc, > + "gcc_jit_block_add_assignment_op %s has non-numeric rvalue %s (type:= %s)", > + gcc::jit::binary_op_reproducer_strings[op], > + rvalue->get_debug_string (), rvalue->get_type ()->get_debug_string (= )); The condition being tested here seems to have a redundant repeated: && rvalue->get_type ()->is_numeric () Am I missing something, or is that a typo? [...snip...] The patch is OK otherwise. Thanks Dave