From nobody Sat Jan 29 21:28:42 2022 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 758AB197543D; Sat, 29 Jan 2022 21:28:42 +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 4JmSB22rVxz4dSV; Sat, 29 Jan 2022 21:28:42 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643491722; 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=BsSF+Ix+6MSIZ1YMU7+Z3GX4cwPx8znBNIAvPL1k8GI=; b=FGETEcIv74G96iEb7471ij93ZTh7/ArjT4XwABa+s/vW6SEouoEyhwygUJxMzuJKohLdhb aLFvRVV9mTH526GcDgyAw2caYBfFg1rs/MzJddNxxVlChkjNSG3C4yp0Erf5/Lw0vYkHU5 y+HlOkc3GYmVkkoi+IxhcQ154IQ+sa28VV1+csATZfRcHrYlN9kf8ehxTYzuu8zs5yieJ3 hiWMELfHt3Toj9PtpEfDjuAtMmPdbZWyRTUeNQpQRSqGkO3JVEBXsociWoe7rDFLDqSJ+c qOa3LsorkQkLyMSKbsso54KVr9QUMiYXg9dIQeqw4D9751Y0xuMKhN1dIBAGAA== 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 4112F1CDBC; Sat, 29 Jan 2022 21:28:42 +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 20TLSgUN060861; Sat, 29 Jan 2022 21:28:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20TLSgZW060860; Sat, 29 Jan 2022 21:28:42 GMT (envelope-from git) Date: Sat, 29 Jan 2022 21:28:42 GMT Message-Id: <202201292128.20TLSgZW060860@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dimitry Andric Subject: git: 9738bc28abe8 - main - Apply llvm fix for assertion failure compiling recent libc++ 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/main X-Git-Reftype: branch X-Git-Commit: 9738bc28abe85f7890d92c007a8e5b1d6eeebb53 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1643491722; 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=BsSF+Ix+6MSIZ1YMU7+Z3GX4cwPx8znBNIAvPL1k8GI=; b=QdJwInYc3h0xzoBf0s+rQNfCuWicHlIUNSKhWToGtJKR9XmpeejskUl9CKRn3Zv7hRixjE czOz1CirGliefmohjiyr/NvdXIol/vHHtwOkXPV8NZEjS9WBAZ0Y+FJPje1baQ7u8KDXp5 LEdORJSJ/KJJvsPrp260nSjyAkdB6/4Yr4KMTMDCvn+Cr45bcO/u7fUlF0WIOu7kKwqb6R K3prrmRr8a7cTqy6yHOneM4cJ7irjl2bR0ynE7UNSpiombN55BrjIOfmcpzXrHkVBcfRjS ms21ZjU2PxvBT6Gm/jgBTdsniEnBbQ+BwCN1NgfzIY3TmiXgk1II6WiFiz/sqw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1643491722; a=rsa-sha256; cv=none; b=LoHlQ6DBhLDgNlVel2NZFiYjuTgGu1w2A41OdXWIuDObpIESkKsusPa3GEkdyXyydXlQux 225odtct4kHBoq/PJxeXLD3BZX9IPOjthhLwALsZovb1wWhLuSHvCXVaX94uD0IJK+g3zG m02ZJuWhQXk1qABmgebkjfPqAIyq9HJKOkXOSpoUpzztDdZcrySPuw1vbVlmemQR6RyjVI SXeL6qAjUW+RujCSnPIdULVxm4r+Ob2e+pLqJs5nhc22FdfTs9KRfaudo02Y4V5N5gzhfS mM+FOMDt1Tf0WhfcmAss9NZ1dyjsc9Q5DxNJ4c2JZz7AwyMdNbALziio8pe2nQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=9738bc28abe85f7890d92c007a8e5b1d6eeebb53 commit 9738bc28abe85f7890d92c007a8e5b1d6eeebb53 Author: Dimitry Andric AuthorDate: 2022-01-29 21:28:12 +0000 Commit: Dimitry Andric CommitDate: 2022-01-29 21:28:24 +0000 Apply llvm fix for assertion failure compiling recent libc++ Merge commit c7c84b90879f from llvm git (by Adrian Prantl): [DwarfDebug] Refuse to emit DW_OP_LLVM_arg values wider than 64 bits DwarfExpression::addUnsignedConstant(const APInt &Value) only supports wider-than-64-bit values when it is used to emit a top-level DWARF expression representing the location of a variable. Before this change, it was possible to call addUnsignedConstant on >64 bit values within a subexpression when substituting DW_OP_LLVM_arg values. This can trigger an assertion failure (e.g. PR52584, PR52333) when it happens in a fragment (DW_OP_LLVM_fragment) expression, as addUnsignedConstant on >64 bit values splits the constant into separate DW_OP_pieces, which modifies DwarfExpression::OffsetInBits. This change papers over the assertion errors by bailing on overly wide DW_OP_LLVM_arg values. A more comprehensive fix might be to be to split wide values into pointer-sized fragments. [0] https://github.com/llvm/llvm-project/blob/e71fa03/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp#L799-L805 Patch by Ricky Zhou! Differential Revision: https://reviews.llvm.org/D115343 MFC after: 3 days --- .../lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp | 25 +++++++++++++++------- .../lib/CodeGen/AsmPrinter/DwarfExpression.cpp | 11 +++++----- .../llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h | 19 ++++++++-------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp index 7edc44c48bbd..a3bf4be09fbe 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -779,7 +779,7 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV, const TargetRegisterInfo &TRI = *Asm->MF->getSubtarget().getRegisterInfo(); auto AddEntry = [&](const DbgValueLocEntry &Entry, - DIExpressionCursor &Cursor) { + DIExpressionCursor &Cursor) { if (Entry.isLocation()) { if (!DwarfExpr.addMachineRegExpression(TRI, Cursor, Entry.getLoc().getReg())) @@ -788,11 +788,19 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV, // If there is an expression, emit raw unsigned bytes. DwarfExpr.addUnsignedConstant(Entry.getInt()); } else if (Entry.isConstantFP()) { + // DwarfExpression does not support arguments wider than 64 bits + // (see PR52584). + // TODO: Consider chunking expressions containing overly wide + // arguments into separate pointer-sized fragment expressions. APInt RawBytes = Entry.getConstantFP()->getValueAPF().bitcastToAPInt(); - DwarfExpr.addUnsignedConstant(RawBytes); + if (RawBytes.getBitWidth() > 64) + return false; + DwarfExpr.addUnsignedConstant(RawBytes.getZExtValue()); } else if (Entry.isConstantInt()) { APInt RawBytes = Entry.getConstantInt()->getValue(); - DwarfExpr.addUnsignedConstant(RawBytes); + if (RawBytes.getBitWidth() > 64) + return false; + DwarfExpr.addUnsignedConstant(RawBytes.getZExtValue()); } else if (Entry.isTargetIndexLocation()) { TargetIndexLocation Loc = Entry.getTargetIndexLocation(); // TODO TargetIndexLocation is a target-independent. Currently only the @@ -805,11 +813,12 @@ DIE *DwarfCompileUnit::constructVariableDIEImpl(const DbgVariable &DV, return true; }; - DwarfExpr.addExpression( - std::move(Cursor), - [&](unsigned Idx, DIExpressionCursor &Cursor) -> bool { - return AddEntry(DVal->getLocEntries()[Idx], Cursor); - }); + if (!DwarfExpr.addExpression( + std::move(Cursor), + [&](unsigned Idx, DIExpressionCursor &Cursor) -> bool { + return AddEntry(DVal->getLocEntries()[Idx], Cursor); + })) + return VariableDie; // Now attach the location information to the DIE. addBlock(*VariableDie, dwarf::DW_AT_location, DwarfExpr.finalize()); diff --git a/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp b/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp index 6409c39e7849..37407c98e75f 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.cpp @@ -463,15 +463,14 @@ static bool isMemoryLocation(DIExpressionCursor ExprCursor) { return true; } -void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor, - unsigned FragmentOffsetInBits) { +void DwarfExpression::addExpression(DIExpressionCursor &&ExprCursor) { addExpression(std::move(ExprCursor), [](unsigned Idx, DIExpressionCursor &Cursor) -> bool { llvm_unreachable("unhandled opcode found in expression"); }); } -void DwarfExpression::addExpression( +bool DwarfExpression::addExpression( DIExpressionCursor &&ExprCursor, llvm::function_ref InsertArg) { // Entry values can currently only cover the initial register location, @@ -496,7 +495,7 @@ void DwarfExpression::addExpression( case dwarf::DW_OP_LLVM_arg: if (!InsertArg(Op->getArg(0), ExprCursor)) { LocationKind = Unknown; - return; + return false; } break; case dwarf::DW_OP_LLVM_fragment: { @@ -527,7 +526,7 @@ void DwarfExpression::addExpression( setSubRegisterPiece(0, 0); // Reset the location description kind. LocationKind = Unknown; - return; + return true; } case dwarf::DW_OP_plus_uconst: assert(!isRegisterLocation()); @@ -630,6 +629,8 @@ void DwarfExpression::addExpression( if (isImplicitLocation() && !isParameterValue()) // Turn this into an implicit location description. addStackValue(); + + return true; } /// add masking operations to stencil out a subregister. diff --git a/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h b/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h index 513e9072309e..e605fe2f7d39 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h +++ b/contrib/llvm-project/llvm/lib/CodeGen/AsmPrinter/DwarfExpression.h @@ -340,16 +340,17 @@ public: /// create one if necessary. unsigned getOrCreateBaseType(unsigned BitSize, dwarf::TypeKind Encoding); + /// Emit all remaining operations in the DIExpressionCursor. The + /// cursor must not contain any DW_OP_LLVM_arg operations. + void addExpression(DIExpressionCursor &&Expr); + /// Emit all remaining operations in the DIExpressionCursor. - /// - /// \param FragmentOffsetInBits If this is one fragment out of multiple - /// locations, this is the offset of the - /// fragment inside the entire variable. - void addExpression(DIExpressionCursor &&Expr, - unsigned FragmentOffsetInBits = 0); - void - addExpression(DIExpressionCursor &&Expr, - llvm::function_ref InsertArg); + /// DW_OP_LLVM_arg operations are resolved by calling (\p InsertArg). + // + /// \return false if any call to (\p InsertArg) returns false. + bool addExpression( + DIExpressionCursor &&Expr, + llvm::function_ref InsertArg); /// If applicable, emit an empty DW_OP_piece / DW_OP_bit_piece to advance to /// the fragment described by \c Expr.