From nobody Mon Dec 6 16:33:24 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4ED0D18B3B45; Mon, 6 Dec 2021 16:33:27 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4J78BF1zByz3Bqr; Mon, 6 Dec 2021 16:33:25 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E6736ED6; Mon, 6 Dec 2021 16:33:24 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1B6GXOCx087636; Mon, 6 Dec 2021 16:33:24 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1B6GXOEL087635; Mon, 6 Dec 2021 16:33:24 GMT (envelope-from git) Date: Mon, 6 Dec 2021 16:33:24 GMT Message-Id: <202112061633.1B6GXOEL087635@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dimitry Andric Subject: git: 29623cceb1f2 - stable/13 - Fix "Bad machine code" when building world for mips or mips64 List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dim X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 29623cceb1f21253b1f4b64e538513c5314b3140 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1638808405; 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; bh=mjcECyTxN92QAB9hVvSiNcAphYdNMB0wMDBCvt6yKxA=; b=c9HByUzXIPCW681Ak71MlkhYHqbfkJqHXZrZEk3zwFeAbayPYhjd7yo7hsRHC+Hq+otmA9 TH5nYK7ynyIUfS+EhfhMHPd+wH5K0rYygDoGjzATBtC/qX8c78dJRBa26R5KW5pnUdXDUI ENU6WY8EqmulpjDjmSAuQ9nlQIkeQmtD63xbr9hOOhG6ro1IppiiZ4PbmARwIRfQRuhhjv V54R14Fke5ZSnFKSRg7LOZ8VBLfMFPrsGGLkt/PWMinH5i6Odw1PW/gDkbqgKjLkjlisUx xRRsohlXHJSH4BfO4T6qtitdPVJmWi0dlzA9uI0c6TbZNNUgdNO58XEAF8pfug== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1638808405; a=rsa-sha256; cv=none; b=tXLQxKKjNDx/j1f75HIAlq7ySOP3wcIRQ30ufrUqfTYVLOjfd5o27JmTBCc/RS8zrWd8Dg eR0411eXQjTxVdZIh+mlZ8syT8vZbdrAgnu6b1q/d1bJ8R1HlYf3xuKmRoiKXvZp5JBI8I fDQrJsHeP4Ll/7LDtR0rIxV8EXcJily72v9xw+jksnjRNV5Ct29boSpiMu9vigpqY0o46G pANYaWfAGiReCpiX/Ega6iSaI1EfBvMLl4WTrN6YDsrbqFm6xAvyYUdyzNFF76PEdyDZlQ S1Zi3bxoxsVT7oip0M7V+gqj7W4kxeXibtciD7FJOpUETRV2BKXNAmR+b7uWMg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=29623cceb1f21253b1f4b64e538513c5314b3140 commit 29623cceb1f21253b1f4b64e538513c5314b3140 Author: Dimitry Andric AuthorDate: 2021-10-18 14:50:24 +0000 Commit: Dimitry Andric CommitDate: 2021-12-06 16:30:08 +0000 Fix "Bad machine code" when building world for mips or mips64 Merge commit f5755c0849a5 from llvm git (by Jessica Clarke): [Mips] Add glue between CopyFromReg, CopyToReg and RDHWR nodes for TLS The MIPS ABI requires the thread pointer be accessed via rdhwr $3, $r29. This is currently represented by (CopyToReg $3, (RDHWR $29)) followed by a (CopyFromReg $3). However, there is no glue between these, meaning scheduling can break those apart. In particular, PR51691 is a report where PseudoSELECT_I was moved to between the CopyToReg and CopyFromReg, and since its expansion uses branches, it split the def and use of the physical register between two basic blocks, resulting in the def being eliminated and the use having no def. It also seems possible that a similar situation could arise splitting up the CopyToReg from the RDHWR, causing the RDHWR to use a destination register other than $3, violating the ABI requirement. Thus, add glue between all three nodes to ensure they aren't split up during instruction selection. No regression test is added since any test would be implictly relying on specific scheduling behaviour, so whilst it might be testing that glue is preventing reordering today, changes to scheduling behaviour could result in the test no longer being able to catch a regression here, as the reordering might no longer happen for other unrelated reasons. Fixes PR51691. Reviewed By: atanasyan, dim Differential Revision: https://reviews.llvm.org/D111967 (cherry picked from commit 4e117af10caf2b6f95c7ef44b08aa7a812a37286) --- contrib/llvm-project/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/contrib/llvm-project/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp b/contrib/llvm-project/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp index 7be5fc33a0af..04a835f08855 100644 --- a/contrib/llvm-project/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp +++ b/contrib/llvm-project/llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp @@ -1027,12 +1027,13 @@ bool MipsSEDAGToDAGISel::trySelect(SDNode *Node) { } SDNode *Rdhwr = - CurDAG->getMachineNode(RdhwrOpc, DL, Node->getValueType(0), + CurDAG->getMachineNode(RdhwrOpc, DL, Node->getValueType(0), MVT::Glue, CurDAG->getRegister(Mips::HWR29, MVT::i32), CurDAG->getTargetConstant(0, DL, MVT::i32)); SDValue Chain = CurDAG->getCopyToReg(CurDAG->getEntryNode(), DL, DestReg, - SDValue(Rdhwr, 0)); - SDValue ResNode = CurDAG->getCopyFromReg(Chain, DL, DestReg, PtrVT); + SDValue(Rdhwr, 0), SDValue(Rdhwr, 1)); + SDValue ResNode = CurDAG->getCopyFromReg(Chain, DL, DestReg, PtrVT, + Chain.getValue(1)); ReplaceNode(Node, ResNode.getNode()); return true; }