From owner-svn-src-projects@freebsd.org Sat Sep 14 10:55:33 2019 Return-Path: Delivered-To: svn-src-projects@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id EE77AF09B9 for ; Sat, 14 Sep 2019 10:55:33 +0000 (UTC) (envelope-from dim@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 46VqD5640wz3Kt6; Sat, 14 Sep 2019 10:55:33 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B33891EB9F; Sat, 14 Sep 2019 10:55:33 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x8EAtXK2044946; Sat, 14 Sep 2019 10:55:33 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x8EAtXED044945; Sat, 14 Sep 2019 10:55:33 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201909141055.x8EAtXED044945@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sat, 14 Sep 2019 10:55:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r352318 - projects/clang900-import/contrib/llvm/lib/Transforms/Utils X-SVN-Group: projects X-SVN-Commit-Author: dim X-SVN-Commit-Paths: projects/clang900-import/contrib/llvm/lib/Transforms/Utils X-SVN-Commit-Revision: 352318 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 14 Sep 2019 10:55:34 -0000 Author: dim Date: Sat Sep 14 10:55:33 2019 New Revision: 352318 URL: https://svnweb.freebsd.org/changeset/base/352318 Log: Revert commit from upstream llvm trunk (by Hans Wennborg): Re-commit r357452 (take 3): "SimplifyCFG SinkCommonCodeFromPredecessors: Also sink function calls without used results (PR41259)" Third time's the charm. This was reverted in r363220 due to being suspected of an internal benchmark regression and a test failure, none of which turned out to be caused by this. As reported in https://bugs.llvm.org/show_bug.cgi?id=43269, this causes UNREACHABLE errors when compiling if_malo_pci.c for arm and aarch64. Modified: projects/clang900-import/contrib/llvm/lib/Transforms/Utils/SimplifyCFG.cpp Modified: projects/clang900-import/contrib/llvm/lib/Transforms/Utils/SimplifyCFG.cpp ============================================================================== --- projects/clang900-import/contrib/llvm/lib/Transforms/Utils/SimplifyCFG.cpp Sat Sep 14 10:52:20 2019 (r352317) +++ projects/clang900-import/contrib/llvm/lib/Transforms/Utils/SimplifyCFG.cpp Sat Sep 14 10:55:33 2019 (r352318) @@ -1428,10 +1428,9 @@ HoistTerminator: static bool canSinkInstructions( ArrayRef Insts, DenseMap> &PHIOperands) { - // Prune out obviously bad instructions to move. Each instruction must have - // exactly zero or one use, and we check later that use is by a single, common - // PHI instruction in the successor. - bool HasUse = !Insts.front()->user_empty(); + // Prune out obviously bad instructions to move. Any non-store instruction + // must have exactly one use, and we check later that use is by a single, + // common PHI instruction in the successor. for (auto *I : Insts) { // These instructions may change or break semantics if moved. if (isa(I) || I->isEHPad() || isa(I) || @@ -1445,11 +1444,10 @@ static bool canSinkInstructions( if (C->isInlineAsm()) return false; - // Each instruction must have zero or one use. - if (HasUse && !I->hasOneUse()) + // Everything must have only one use too, apart from stores which + // have no uses. + if (!isa(I) && !I->hasOneUse()) return false; - if (!HasUse && !I->user_empty()) - return false; } const Instruction *I0 = Insts.front(); @@ -1457,11 +1455,11 @@ static bool canSinkInstructions( if (!I->isSameOperationAs(I0)) return false; - // All instructions in Insts are known to be the same opcode. If they have a - // use, check that the only user is a PHI or in the same block as the - // instruction, because if a user is in the same block as an instruction we're - // contemplating sinking, it must already be determined to be sinkable. - if (HasUse) { + // All instructions in Insts are known to be the same opcode. If they aren't + // stores, check the only user of each is a PHI or in the same block as the + // instruction, because if a user is in the same block as an instruction + // we're contemplating sinking, it must already be determined to be sinkable. + if (!isa(I0)) { auto *PNUse = dyn_cast(*I0->user_begin()); auto *Succ = I0->getParent()->getTerminator()->getSuccessor(0); if (!all_of(Insts, [&PNUse,&Succ](const Instruction *I) -> bool { @@ -1539,7 +1537,7 @@ static bool sinkLastInstruction(ArrayRef // it is slightly over-aggressive - it gets confused by commutative instructions // so double-check it here. Instruction *I0 = Insts.front(); - if (!I0->user_empty()) { + if (!isa(I0)) { auto *PNUse = dyn_cast(*I0->user_begin()); if (!all_of(Insts, [&PNUse](const Instruction *I) -> bool { auto *U = cast(*I->user_begin()); @@ -1597,10 +1595,11 @@ static bool sinkLastInstruction(ArrayRef I0->andIRFlags(I); } - if (!I0->user_empty()) { + if (!isa(I0)) { // canSinkLastInstruction checked that all instructions were used by // one and only one PHI node. Find that now, RAUW it to our common // instruction and nuke it. + assert(I0->hasOneUse()); auto *PN = cast(*I0->user_begin()); PN->replaceAllUsesWith(I0); PN->eraseFromParent();