From nobody Sun Apr 9 21:35:18 2023 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 4Pvlkv3QvFz44J8g; Sun, 9 Apr 2023 21:35:19 +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 4Pvlkv1jbMz4MBG; Sun, 9 Apr 2023 21:35:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681076119; 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=fby/UJ3MARcdky/akyAzXfBHLCuvuQL/Xqn32QMzUN0=; b=FiZhHfor4Pc3XaoDjJrQDwNj5XR4X3CFyRoclOCw7tfuBgmQbKvyFuFy2CYvSjeRtdloY0 itiep6fOxQi+v/GX1v6W+jidIPO/jvRhxJTLgCfXW+2rsZX8AtBVHtKerDKqNtRtffIWnJ jy2QDB1xeejDBfhNrE/bQQ2BQmrNISu8jCUU5UCu4rfL9wQ1DuCgC8t2zpS+6bTcPaglOM qfd3cSkOjreo6KcVq303/6TccUeNdO6KMnP/vF17ug2BKhBTwUnJsR+S4f66HUILH4MLOr ANtNkoH9sP45oL9cNyOnECqgUt7OjXE1DAAUOYkTjkxad86+20IcRlFVoxXrQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681076119; 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=fby/UJ3MARcdky/akyAzXfBHLCuvuQL/Xqn32QMzUN0=; b=Q9BiVNHBygsvxlVYPxjgjcrV2fW+aCHE3cGWkd01geg0Jmam0X2LZziBW3qyD/hOk8V/l1 Vq1AoVP/9FtYPNFB2sfUBdLspgveRjnFABCGQGOgO4GvCMgqUl83nb3Fw/RehlC6fEKfcE U5En9YdUHi0NLioLF7fCZ6iui6X6oxSJiC4N32jBwXb5rvpauaKHx/LMBvASZzUH4nejdV DyFNZpO+9Fr6vxYlWeTPqxPZB8SiemvcxzUsRDUUfB45ckgx9cl/r8Axyho0W9kUvcebI3 rYslEaCavtXbH3IGOEw+rAYCnBvRanHsxcMENCNHOMAtZ+5qkQTAQGE+mjYWTQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681076119; a=rsa-sha256; cv=none; b=abA2gw3PtuF5gmSyHUVE1dQuCGcmxS/3qYieyP38r9dk4PzSTEo4XlvZo769aZmHL2Xfjz cru4NYOfJNE198x+QMtBWl7PnL+K9xQlTupQB9nzh5Lpog4zui6f0Jp4GroRcD5IGkQEQJ NKVJCHaly8G16XraHGoryY/yIiLpavmQeQ0T28u6udjYj3iK0oearDRnpcoQLbsEISKEOI lhEUPz4XL34Etnyjc7gaTqJgxuBul0pk9PObwJwEiLUooEOI3rK8YEnHvDEc1jyyv0cIz+ trEw2mxTRbi8ESrtwaTDBawCG6PvOzBcxkRlSVPzcZEjQplckbx8fqCX9QL5Lw== 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 4Pvlkv0MN4zPhD; Sun, 9 Apr 2023 21:35:19 +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 339LZJqj081582; Sun, 9 Apr 2023 21:35:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 339LZIa9081580; Sun, 9 Apr 2023 21:35:18 GMT (envelope-from git) Date: Sun, 9 Apr 2023 21:35:18 GMT Message-Id: <202304092135.339LZIa9081580@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: 5d976198a6de - stable/13 - Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454 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: 5d976198a6de2c316a9f371a4ca587cc8545d941 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dim: URL: https://cgit.FreeBSD.org/src/commit/?id=5d976198a6de2c316a9f371a4ca587cc8545d941 commit 5d976198a6de2c316a9f371a4ca587cc8545d941 Author: Dimitry Andric AuthorDate: 2022-09-10 18:56:18 +0000 Commit: Dimitry Andric CommitDate: 2023-04-09 14:54:50 +0000 Merge llvm-project release/15.x llvmorg-15.0.0-9-g1c73596d3454 This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and openmp to llvmorg-15.0.0-9-g1c73596d3454. PR: 265425 MFC after: 2 weeks (cherry picked from commit a4a491e2238b12ccd64d3faf9e6401487f6f1f1b) --- .../clang/include/clang/Lex/Preprocessor.h | 7 + .../clang/lib/AST/RecordLayoutBuilder.cpp | 7 +- .../clang/lib/Basic/Targets/AArch64.cpp | 5 +- .../clang/lib/CodeGen/CGStmtOpenMP.cpp | 13 +- .../clang/lib/CodeGen/CodeGenFunction.h | 7 +- .../llvm-project/clang/lib/CodeGen/TargetInfo.cpp | 15 +- .../clang/lib/Driver/ToolChains/Cuda.cpp | 4 +- .../clang/lib/Format/TokenAnnotator.cpp | 19 -- contrib/llvm-project/clang/lib/Headers/cpuid.h | 1 + .../clang/lib/Lex/PPMacroExpansion.cpp | 55 ++++ contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp | 7 + .../llvm-project/clang/lib/Sema/SemaExprCXX.cpp | 2 + contrib/llvm-project/clang/lib/Sema/SemaOpenMP.cpp | 3 + .../clang/utils/TableGen/SveEmitter.cpp | 2 + contrib/llvm-project/libcxx/include/regex | 2 +- contrib/llvm-project/libcxx/include/span | 7 +- contrib/llvm-project/lld/COFF/Driver.cpp | 15 +- contrib/llvm-project/lld/docs/ReleaseNotes.rst | 11 +- .../include/llvm/Analysis/LoopAccessAnalysis.h | 2 + .../llvm/DebugInfo/Symbolize/MarkupFilter.h | 30 +- .../llvm-project/llvm/include/llvm/MC/MCContext.h | 6 +- .../llvm-project/llvm/include/llvm/MC/MCDwarf.h | 6 + .../llvm/lib/Analysis/LoopAccessAnalysis.cpp | 3 +- .../llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp | 56 ++-- .../CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp | 5 +- .../llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp | 10 +- .../llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp | 302 +++++++++++++++++++-- contrib/llvm-project/llvm/lib/MC/MCContext.cpp | 39 +-- contrib/llvm-project/llvm/lib/MC/MCDwarf.cpp | 14 +- .../llvm/lib/MC/MCParser/ELFAsmParser.cpp | 3 +- contrib/llvm-project/llvm/lib/Support/Host.cpp | 1 + .../llvm/lib/Target/AMDGPU/AMDGPUISelLowering.cpp | 11 +- .../llvm/lib/Target/RISCV/RISCVCodeGenPrepare.cpp | 4 +- .../Target/RISCV/TargetInfo/RISCVTargetInfo.cpp | 8 +- .../Target/Sparc/MCTargetDesc/SparcMCAsmInfo.cpp | 1 - .../llvm/lib/Target/X86/X86ISelLowering.cpp | 49 +++- .../Transforms/InstCombine/InstCombineCompares.cpp | 4 +- .../llvm/lib/Transforms/Utils/LoopUtils.cpp | 5 +- .../llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp | 12 +- .../lib/Transforms/Vectorize/SLPVectorizer.cpp | 18 +- .../llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp | 28 +- lib/clang/include/VCSVersion.inc | 6 +- lib/clang/include/lld/Common/Version.inc | 2 +- lib/clang/include/llvm/Support/VCSRevision.h | 2 +- 44 files changed, 616 insertions(+), 193 deletions(-) diff --git a/contrib/llvm-project/clang/include/clang/Lex/Preprocessor.h b/contrib/llvm-project/clang/include/clang/Lex/Preprocessor.h index 79454b5addea..7c5df05069ed 100644 --- a/contrib/llvm-project/clang/include/clang/Lex/Preprocessor.h +++ b/contrib/llvm-project/clang/include/clang/Lex/Preprocessor.h @@ -178,6 +178,8 @@ class Preprocessor { IdentifierInfo *Ident__is_target_vendor; // __is_target_vendor IdentifierInfo *Ident__is_target_os; // __is_target_os IdentifierInfo *Ident__is_target_environment; // __is_target_environment + IdentifierInfo *Ident__is_target_variant_os; + IdentifierInfo *Ident__is_target_variant_environment; IdentifierInfo *Ident__FLT_EVAL_METHOD__; // __FLT_EVAL_METHOD // Weak, only valid (and set) while InMacroArgs is true. @@ -1353,6 +1355,11 @@ public: StringRef getLastMacroWithSpelling(SourceLocation Loc, ArrayRef Tokens) const; + /// Get the predefines for this processor. + /// Used by some third-party tools to inspect and add predefines (see + /// https://github.com/llvm/llvm-project/issues/57483). + const std::string &getPredefines() const { return Predefines; } + /// Set the predefines for this Preprocessor. /// /// These predefines are automatically injected when parsing the main file. diff --git a/contrib/llvm-project/clang/lib/AST/RecordLayoutBuilder.cpp b/contrib/llvm-project/clang/lib/AST/RecordLayoutBuilder.cpp index 6f3ede2ce42a..5ddd95e2ecca 100644 --- a/contrib/llvm-project/clang/lib/AST/RecordLayoutBuilder.cpp +++ b/contrib/llvm-project/clang/lib/AST/RecordLayoutBuilder.cpp @@ -1889,12 +1889,7 @@ void ItaniumRecordLayoutBuilder::LayoutField(const FieldDecl *D, UnfilledBitsInLastUnit = 0; LastBitfieldStorageUnitSize = 0; - llvm::Triple Target = Context.getTargetInfo().getTriple(); - bool FieldPacked = (Packed && (!FieldClass || FieldClass->isPOD() || - Context.getLangOpts().getClangABICompat() <= - LangOptions::ClangABI::Ver14 || - Target.isPS() || Target.isOSDarwin())) || - D->hasAttr(); + bool FieldPacked = Packed || D->hasAttr(); AlignRequirementKind AlignRequirement = AlignRequirementKind::None; CharUnits FieldSize; diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp index 60ef52ac3f0d..8d8972c1613a 100644 --- a/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp +++ b/contrib/llvm-project/clang/lib/Basic/Targets/AArch64.cpp @@ -489,9 +489,12 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions &Opts, Builder.defineMacro("__FP_FAST_FMA", "1"); Builder.defineMacro("__FP_FAST_FMAF", "1"); + // C/C++ operators work on both VLS and VLA SVE types + if (FPU & SveMode) + Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS", "2"); + if (Opts.VScaleMin && Opts.VScaleMin == Opts.VScaleMax) { Builder.defineMacro("__ARM_FEATURE_SVE_BITS", Twine(Opts.VScaleMin * 128)); - Builder.defineMacro("__ARM_FEATURE_SVE_VECTOR_OPERATORS"); } } diff --git a/contrib/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp b/contrib/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp index aa55cdaca5dc..570424dae7fc 100644 --- a/contrib/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/contrib/llvm-project/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -2582,8 +2582,9 @@ static void emitOMPSimdRegion(CodeGenFunction &CGF, const OMPLoopDirective &S, CGF.EmitOMPReductionClauseFinal(S, /*ReductionKind=*/OMPD_simd); emitPostUpdateForReductionClause(CGF, S, [](CodeGenFunction &) { return nullptr; }); + LoopScope.restoreMap(); + CGF.EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; }); } - CGF.EmitOMPLinearClauseFinal(S, [](CodeGenFunction &) { return nullptr; }); // Emit: if (PreCond) - end. if (ContBlock) { CGF.EmitBranch(ContBlock); @@ -3426,11 +3427,12 @@ bool CodeGenFunction::EmitOMPWorksharingLoop( EmitOMPLastprivateClauseFinal( S, isOpenMPSimdDirective(S.getDirectiveKind()), Builder.CreateIsNotNull(EmitLoadOfScalar(IL, S.getBeginLoc()))); + LoopScope.restoreMap(); + EmitOMPLinearClauseFinal(S, [IL, &S](CodeGenFunction &CGF) { + return CGF.Builder.CreateIsNotNull( + CGF.EmitLoadOfScalar(IL, S.getBeginLoc())); + }); } - EmitOMPLinearClauseFinal(S, [IL, &S](CodeGenFunction &CGF) { - return CGF.Builder.CreateIsNotNull( - CGF.EmitLoadOfScalar(IL, S.getBeginLoc())); - }); DoacrossCleanupScope.ForceCleanup(); // We're now done with the loop, so jump to the continuation block. if (ContBlock) { @@ -7658,6 +7660,7 @@ void CodeGenFunction::EmitOMPTaskLoopBasedDirective(const OMPLoopDirective &S) { CGF.GetAddrOfLocalVar(*LIP), /*Volatile=*/false, (*LIP)->getType(), S.getBeginLoc()))); } + LoopScope.restoreMap(); CGF.EmitOMPLinearClauseFinal(S, [LIP, &S](CodeGenFunction &CGF) { return CGF.Builder.CreateIsNotNull( CGF.EmitLoadOfScalar(CGF.GetAddrOfLocalVar(*LIP), /*Volatile=*/false, diff --git a/contrib/llvm-project/clang/lib/CodeGen/CodeGenFunction.h b/contrib/llvm-project/clang/lib/CodeGen/CodeGenFunction.h index fe0890f433e8..672acd844525 100644 --- a/contrib/llvm-project/clang/lib/CodeGen/CodeGenFunction.h +++ b/contrib/llvm-project/clang/lib/CodeGen/CodeGenFunction.h @@ -1094,7 +1094,7 @@ public: void ForceCleanup() { RunCleanupsScope::ForceCleanup(); - MappedVars.restore(CGF); + restoreMap(); } /// Exit scope - all the mapped variables are restored. @@ -1108,6 +1108,11 @@ public: VD = VD->getCanonicalDecl(); return !VD->isLocalVarDeclOrParm() && CGF.LocalDeclMap.count(VD) > 0; } + + /// Restore all mapped variables w/o clean up. This is usefully when we want + /// to reference the original variables but don't want the clean up because + /// that could emit lifetime end too early, causing backend issue #56913. + void restoreMap() { MappedVars.restore(CGF); } }; /// Save/restore original map of previously emitted local vars in case when we diff --git a/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp b/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp index 195ad8cdc13e..36e10e4df4c1 100644 --- a/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp +++ b/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp @@ -11002,9 +11002,22 @@ bool RISCVABIInfo::detectFPCCEligibleStructHelper(QualType Ty, CharUnits CurOff, // Unions aren't eligible unless they're empty (which is caught above). if (RD->isUnion()) return false; + const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD); + // If this is a C++ record, check the bases first. + if (const CXXRecordDecl *CXXRD = dyn_cast(RD)) { + for (const CXXBaseSpecifier &B : CXXRD->bases()) { + const auto *BDecl = + cast(B.getType()->castAs()->getDecl()); + CharUnits BaseOff = Layout.getBaseClassOffset(BDecl); + bool Ret = detectFPCCEligibleStructHelper(B.getType(), CurOff + BaseOff, + Field1Ty, Field1Off, Field2Ty, + Field2Off); + if (!Ret) + return false; + } + } int ZeroWidthBitFieldCount = 0; for (const FieldDecl *FD : RD->fields()) { - const ASTRecordLayout &Layout = getContext().getASTRecordLayout(RD); uint64_t FieldOffInBits = Layout.getFieldOffset(FD->getFieldIndex()); QualType QTy = FD->getType(); if (FD->isBitField()) { diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Cuda.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Cuda.cpp index 5e59677947e6..7ad990dda467 100644 --- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Cuda.cpp +++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Cuda.cpp @@ -693,8 +693,8 @@ CudaToolChain::CudaToolChain(const Driver &D, const llvm::Triple &Triple, std::string CudaToolChain::getInputFilename(const InputInfo &Input) const { // Only object files are changed, for example assembly files keep their .s - // extensions. - if (Input.getType() != types::TY_Object) + // extensions. If the user requested device-only compilation don't change it. + if (Input.getType() != types::TY_Object || getDriver().offloadDeviceOnly()) return ToolChain::getInputFilename(Input); // Replace extension for object files with cubin because nvlink relies on diff --git a/contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp b/contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp index 5991cf23d5dc..cf6549e2a5bd 100644 --- a/contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp +++ b/contrib/llvm-project/clang/lib/Format/TokenAnnotator.cpp @@ -2329,25 +2329,6 @@ private: !PrevToken->MatchingParen) return TT_PointerOrReference; - // For "} &&" - if (PrevToken->is(tok::r_brace) && Tok.is(tok::ampamp)) { - const FormatToken *MatchingLBrace = PrevToken->MatchingParen; - - // We check whether there is a TemplateCloser(">") to indicate it's a - // template or not. If it's not a template, "&&" is likely a reference - // operator. - // struct {} &&ref = {}; - if (!MatchingLBrace) - return TT_PointerOrReference; - FormatToken *BeforeLBrace = MatchingLBrace->getPreviousNonComment(); - if (!BeforeLBrace || BeforeLBrace->isNot(TT_TemplateCloser)) - return TT_PointerOrReference; - - // If it is a template, "&&" is a binary operator. - // enable_if<>{} && ... - return TT_BinaryOperator; - } - if (PrevToken->Tok.isLiteral() || PrevToken->isOneOf(tok::r_paren, tok::r_square, tok::kw_true, tok::kw_false, tok::r_brace)) { diff --git a/contrib/llvm-project/clang/lib/Headers/cpuid.h b/contrib/llvm-project/clang/lib/Headers/cpuid.h index 5d262a60735f..caa0069c2e1f 100644 --- a/contrib/llvm-project/clang/lib/Headers/cpuid.h +++ b/contrib/llvm-project/clang/lib/Headers/cpuid.h @@ -232,6 +232,7 @@ /* Features in %ebx for leaf 0x80000008 */ #define bit_CLZERO 0x00000001 +#define bit_RDPRU 0x00000010 #define bit_WBNOINVD 0x00000200 diff --git a/contrib/llvm-project/clang/lib/Lex/PPMacroExpansion.cpp b/contrib/llvm-project/clang/lib/Lex/PPMacroExpansion.cpp index f3be2107f985..c56f41c4495e 100644 --- a/contrib/llvm-project/clang/lib/Lex/PPMacroExpansion.cpp +++ b/contrib/llvm-project/clang/lib/Lex/PPMacroExpansion.cpp @@ -387,6 +387,10 @@ void Preprocessor::RegisterBuiltinMacros() { Ident__is_target_os = RegisterBuiltinMacro(*this, "__is_target_os"); Ident__is_target_environment = RegisterBuiltinMacro(*this, "__is_target_environment"); + Ident__is_target_variant_os = + RegisterBuiltinMacro(*this, "__is_target_variant_os"); + Ident__is_target_variant_environment = + RegisterBuiltinMacro(*this, "__is_target_variant_environment"); // Modules. Ident__building_module = RegisterBuiltinMacro(*this, "__building_module"); @@ -1431,6 +1435,39 @@ static bool isTargetEnvironment(const TargetInfo &TI, return TI.getTriple().getEnvironment() == Env.getEnvironment(); } +/// Implements the __is_target_variant_os builtin macro. +static bool isTargetVariantOS(const TargetInfo &TI, const IdentifierInfo *II) { + if (TI.getTriple().isOSDarwin()) { + const llvm::Triple *VariantTriple = TI.getDarwinTargetVariantTriple(); + if (!VariantTriple) + return false; + + std::string OSName = + (llvm::Twine("unknown-unknown-") + II->getName().lower()).str(); + llvm::Triple OS(OSName); + if (OS.getOS() == llvm::Triple::Darwin) { + // Darwin matches macos, ios, etc. + return VariantTriple->isOSDarwin(); + } + return VariantTriple->getOS() == OS.getOS(); + } + return false; +} + +/// Implements the __is_target_variant_environment builtin macro. +static bool isTargetVariantEnvironment(const TargetInfo &TI, + const IdentifierInfo *II) { + if (TI.getTriple().isOSDarwin()) { + const llvm::Triple *VariantTriple = TI.getDarwinTargetVariantTriple(); + if (!VariantTriple) + return false; + std::string EnvName = (llvm::Twine("---") + II->getName().lower()).str(); + llvm::Triple Env(EnvName); + return VariantTriple->getEnvironment() == Env.getEnvironment(); + } + return false; +} + /// ExpandBuiltinMacro - If an identifier token is read that is to be expanded /// as a builtin macro, handle it and return the next token as 'Tok'. void Preprocessor::ExpandBuiltinMacro(Token &Tok) { @@ -1677,6 +1714,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { .Case("__is_target_vendor", true) .Case("__is_target_os", true) .Case("__is_target_environment", true) + .Case("__is_target_variant_os", true) + .Case("__is_target_variant_environment", true) .Default(false); } }); @@ -1877,6 +1916,22 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) { Tok, *this, diag::err_feature_check_malformed); return II && isTargetEnvironment(getTargetInfo(), II); }); + } else if (II == Ident__is_target_variant_os) { + EvaluateFeatureLikeBuiltinMacro( + OS, Tok, II, *this, false, + [this](Token &Tok, bool &HasLexedNextToken) -> int { + IdentifierInfo *II = ExpectFeatureIdentifierInfo( + Tok, *this, diag::err_feature_check_malformed); + return II && isTargetVariantOS(getTargetInfo(), II); + }); + } else if (II == Ident__is_target_variant_environment) { + EvaluateFeatureLikeBuiltinMacro( + OS, Tok, II, *this, false, + [this](Token &Tok, bool &HasLexedNextToken) -> int { + IdentifierInfo *II = ExpectFeatureIdentifierInfo( + Tok, *this, diag::err_feature_check_malformed); + return II && isTargetVariantEnvironment(getTargetInfo(), II); + }); } else { llvm_unreachable("Unknown identifier!"); } diff --git a/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp b/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp index 0f79978b0911..83081bbf0aa0 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp @@ -15603,6 +15603,8 @@ ExprResult Sema::CreateBuiltinUnaryOp(SourceLocation OpLoc, resultType->castAs()->getVectorKind() != VectorType::AltiVecBool)) break; + else if (resultType->isVLSTBuiltinType()) // SVE vectors allow + and - + break; else if (getLangOpts().CPlusPlus && // C++ [expr.unary.op]p6 Opc == UO_Plus && resultType->isPointerType()) @@ -17598,6 +17600,11 @@ static void RemoveNestedImmediateInvocation( DRSet.erase(E); return E; } + ExprResult TransformLambdaExpr(LambdaExpr *E) { + // Do not rebuild lambdas to avoid creating a new type. + // Lambdas have already been processed inside their eval context. + return E; + } bool AlwaysRebuild() { return false; } bool ReplacingOriginal() { return true; } bool AllowSkippingCXXConstructExpr() { diff --git a/contrib/llvm-project/clang/lib/Sema/SemaExprCXX.cpp b/contrib/llvm-project/clang/lib/Sema/SemaExprCXX.cpp index 5331193de863..6f9e025283f5 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaExprCXX.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaExprCXX.cpp @@ -5412,6 +5412,8 @@ void DiagnoseBuiltinDeprecation(Sema& S, TypeTrait Kind, Replacement = BTT_IsTriviallyAssignable; break; case UTT_HasTrivialCopy: + Replacement = UTT_IsTriviallyCopyable; + break; case UTT_HasTrivialDefaultConstructor: case UTT_HasTrivialMoveConstructor: Replacement = TT_IsTriviallyConstructible; diff --git a/contrib/llvm-project/clang/lib/Sema/SemaOpenMP.cpp b/contrib/llvm-project/clang/lib/Sema/SemaOpenMP.cpp index dc1470bf7a9d..a92fec6a0232 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaOpenMP.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaOpenMP.cpp @@ -2270,6 +2270,9 @@ bool Sema::isInOpenMPTargetExecutionDirective() const { } bool Sema::isOpenMPRebuildMemberExpr(ValueDecl *D) { + // Only rebuild for Field. + if (!dyn_cast(D)) + return false; DSAStackTy::DSAVarData DVarPrivate = DSAStack->hasDSA( D, [](OpenMPClauseKind C, bool AppliedToPointee, diff --git a/contrib/llvm-project/clang/utils/TableGen/SveEmitter.cpp b/contrib/llvm-project/clang/utils/TableGen/SveEmitter.cpp index b2f6ede56522..e1e1c078ccbf 100644 --- a/contrib/llvm-project/clang/utils/TableGen/SveEmitter.cpp +++ b/contrib/llvm-project/clang/utils/TableGen/SveEmitter.cpp @@ -1282,6 +1282,8 @@ void SVEEmitter::createHeader(raw_ostream &OS) { OS << "#ifdef __cplusplus\n"; OS << "} // extern \"C\"\n"; OS << "#endif\n\n"; + OS << "#undef __ai\n\n"; + OS << "#undef __aio\n\n"; OS << "#endif /*__ARM_FEATURE_SVE */\n\n"; OS << "#endif /* __ARM_SVE_H */\n"; } diff --git a/contrib/llvm-project/libcxx/include/regex b/contrib/llvm-project/libcxx/include/regex index 850fe099df1e..26887e84bf28 100644 --- a/contrib/llvm-project/libcxx/include/regex +++ b/contrib/llvm-project/libcxx/include/regex @@ -1355,7 +1355,7 @@ inline _LIBCPP_INLINE_VISIBILITY unsigned char __to_lower(unsigned char __c) { #if defined(__MVS__) && !defined(__NATIVE_ASCII_F) - return c & 0xBF; + return __c & 0xBF; #else return __c | 0x20; #endif diff --git a/contrib/llvm-project/libcxx/include/span b/contrib/llvm-project/libcxx/include/span index 00793a210cbe..67d2ac241ff2 100644 --- a/contrib/llvm-project/libcxx/include/span +++ b/contrib/llvm-project/libcxx/include/span @@ -453,9 +453,10 @@ public: : __data{_VSTD::to_address(__first)}, __size{__count} {} template <__span_compatible_iterator _It, __span_compatible_sentinel_for<_It> _End> - _LIBCPP_INLINE_VISIBILITY - constexpr span(_It __first, _End __last) - : __data(_VSTD::to_address(__first)), __size(__last - __first) {} + _LIBCPP_INLINE_VISIBILITY constexpr span(_It __first, _End __last) + : __data(_VSTD::to_address(__first)), __size(__last - __first) { + _LIBCPP_ASSERT(__last - __first >= 0, "invalid range in span's constructor (iterator, sentinel)"); + } template _LIBCPP_INLINE_VISIBILITY diff --git a/contrib/llvm-project/lld/COFF/Driver.cpp b/contrib/llvm-project/lld/COFF/Driver.cpp index 680f89b79b95..5b21337bb45e 100644 --- a/contrib/llvm-project/lld/COFF/Driver.cpp +++ b/contrib/llvm-project/lld/COFF/Driver.cpp @@ -2228,15 +2228,14 @@ void LinkerDriver::linkerMain(ArrayRef argsArr) { // Windows specific -- if __load_config_used can be resolved, resolve it. if (ctx.symtab.findUnderscore("_load_config_used")) addUndefined(mangle("_load_config_used")); - } while (run()); - if (args.hasArg(OPT_include_optional)) { - // Handle /includeoptional - for (auto *arg : args.filtered(OPT_include_optional)) - if (isa_and_nonnull(ctx.symtab.find(arg->getValue()))) - addUndefined(arg->getValue()); - while (run()); - } + if (args.hasArg(OPT_include_optional)) { + // Handle /includeoptional + for (auto *arg : args.filtered(OPT_include_optional)) + if (isa_and_nonnull(ctx.symtab.find(arg->getValue()))) + addUndefined(arg->getValue()); + } + } while (run()); // Create wrapped symbols for -wrap option. std::vector wrapped = addWrappedSymbols(ctx, args); diff --git a/contrib/llvm-project/lld/docs/ReleaseNotes.rst b/contrib/llvm-project/lld/docs/ReleaseNotes.rst index 5819d67d3297..db0b66a3807c 100644 --- a/contrib/llvm-project/lld/docs/ReleaseNotes.rst +++ b/contrib/llvm-project/lld/docs/ReleaseNotes.rst @@ -5,13 +5,6 @@ lld |release| Release Notes .. contents:: :local: -.. only:: PreRelease - - .. warning:: - These are in-progress notes for the upcoming LLVM |release| release. - Release notes for previous releases can be found on - `the Download Page `_. - Introduction ============ @@ -98,7 +91,7 @@ MachO Improvements * We now support proper relocation and pruning of EH frames. **Note:** this comes at some performance overhead on x86_64 builds, and we recommend adding - the ``-femit-compact-unwind=no-compact-unwind`` compile flag to avoid it. + the ``-femit-dwarf-unwind=no-compact-unwind`` compile flag to avoid it. (`D129540 `_, `D122258 `_) @@ -212,6 +205,8 @@ Fixes errors. (`D122624 `_) * Fixed handling of relocatable object files within frameworks. (`D114841 `_) +* Fixed the PPC64R2SaveStub to only use non-pc-relative code. + (`D129580 `_) WebAssembly Improvements ------------------------ diff --git a/contrib/llvm-project/llvm/include/llvm/Analysis/LoopAccessAnalysis.h b/contrib/llvm-project/llvm/include/llvm/Analysis/LoopAccessAnalysis.h index 8f71ce9e96c0..af8e8d22269e 100644 --- a/contrib/llvm-project/llvm/include/llvm/Analysis/LoopAccessAnalysis.h +++ b/contrib/llvm-project/llvm/include/llvm/Analysis/LoopAccessAnalysis.h @@ -253,6 +253,8 @@ public: return {}; } + const Loop *getInnermostLoop() const { return InnermostLoop; } + private: /// A wrapper around ScalarEvolution, used to add runtime SCEV checks, and /// applies dynamic knowledge to simplify SCEV expressions and convert them diff --git a/contrib/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h b/contrib/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h index 26686143af95..a54f8f5d2db8 100644 --- a/contrib/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h +++ b/contrib/llvm-project/llvm/include/llvm/DebugInfo/Symbolize/MarkupFilter.h @@ -26,11 +26,14 @@ namespace llvm { namespace symbolize { +class LLVMSymbolizer; + /// Filter to convert parsed log symbolizer markup elements into human-readable /// text. class MarkupFilter { public: - MarkupFilter(raw_ostream &OS, Optional ColorsEnabled = llvm::None); + MarkupFilter(raw_ostream &OS, LLVMSymbolizer &Symbolizer, + Optional ColorsEnabled = llvm::None); /// Filters a line containing symbolizer markup and writes the human-readable /// results to the output stream. @@ -57,6 +60,7 @@ private: uint64_t ModuleRelativeAddr; bool contains(uint64_t Addr) const; + uint64_t getModuleRelativeAddr(uint64_t Addr) const; }; // An informational module line currently being constructed. As many mmap @@ -67,6 +71,15 @@ private: SmallVector MMaps = {}; }; + // The semantics of a possible program counter value. + enum class PCType { + // The address is a return address and must be adjusted to point to the call + // itself. + ReturnAddress, + // The address is the precise location in the code and needs no adjustment. + PreciseCode, + }; + bool tryContextualElement(const MarkupNode &Node, const SmallVector &DeferredNodes); bool tryMMap(const MarkupNode &Element, @@ -83,6 +96,9 @@ private: bool tryPresentation(const MarkupNode &Node); bool trySymbol(const MarkupNode &Node); + bool tryPC(const MarkupNode &Node); + bool tryBackTrace(const MarkupNode &Node); + bool tryData(const MarkupNode &Node); bool trySGR(const MarkupNode &Node); @@ -91,6 +107,9 @@ private: void restoreColor(); void resetColor(); + void printRawElement(const MarkupNode &Element); + void printValue(Twine Value); + Optional parseModule(const MarkupNode &Element) const; Optional parseMMap(const MarkupNode &Element) const; @@ -99,19 +118,26 @@ private: Optional parseSize(StringRef Str) const; Optional> parseBuildID(StringRef Str) const; Optional parseMode(StringRef Str) const; + Optional parsePCType(StringRef Str) const; + Optional parseFrameNumber(StringRef Str) const; bool checkTag(const MarkupNode &Node) const; bool checkNumFields(const MarkupNode &Element, size_t Size) const; bool checkNumFieldsAtLeast(const MarkupNode &Element, size_t Size) const; + bool checkNumFieldsAtMost(const MarkupNode &Element, size_t Size) const; void reportTypeError(StringRef Str, StringRef TypeName) const; void reportLocation(StringRef::iterator Loc) const; - const MMap *overlappingMMap(const MMap &Map) const; + const MMap *getOverlappingMMap(const MMap &Map) const; + const MMap *getContainingMMap(uint64_t Addr) const; + + uint64_t adjustAddr(uint64_t Addr, PCType Type) const; StringRef lineEnding() const; raw_ostream &OS; + LLVMSymbolizer &Symbolizer; const bool ColorsEnabled; MarkupParser Parser; diff --git a/contrib/llvm-project/llvm/include/llvm/MC/MCContext.h b/contrib/llvm-project/llvm/include/llvm/MC/MCContext.h index 61520c4f29bf..c20ce79ee4d0 100644 --- a/contrib/llvm-project/llvm/include/llvm/MC/MCContext.h +++ b/contrib/llvm-project/llvm/include/llvm/MC/MCContext.h @@ -190,7 +190,8 @@ private: SmallString<128> CompilationDir; /// Prefix replacement map for source file information. - std::map DebugPrefixMap; + std::map> + DebugPrefixMap; /// The main file name if passed in explicitly. std::string MainFileName; @@ -698,6 +699,9 @@ public: /// Add an entry to the debug prefix map. void addDebugPrefixMapEntry(const std::string &From, const std::string &To); + /// Remap one path in-place as per the debug prefix map. + void remapDebugPath(SmallVectorImpl &Path); + // Remaps all debug directory paths in-place as per the debug prefix map. void RemapDebugPaths(); diff --git a/contrib/llvm-project/llvm/include/llvm/MC/MCDwarf.h b/contrib/llvm-project/llvm/include/llvm/MC/MCDwarf.h index 8b2ae84749b4..557c713575e4 100644 --- a/contrib/llvm-project/llvm/include/llvm/MC/MCDwarf.h +++ b/contrib/llvm-project/llvm/include/llvm/MC/MCDwarf.h @@ -22,6 +22,7 @@ #include "llvm/MC/StringTableBuilder.h" #include "llvm/Support/Error.h" #include "llvm/Support/MD5.h" +#include "llvm/Support/StringSaver.h" #include #include #include @@ -48,6 +49,8 @@ MCSymbol *emitListsTableHeaderStart(MCStreamer &S); /// Manage the .debug_line_str section contents, if we use it. class MCDwarfLineStr { + BumpPtrAllocator Alloc; + StringSaver Saver{Alloc}; MCSymbol *LineStrLabel = nullptr; StringTableBuilder LineStrings{StringTableBuilder::DWARF}; bool UseRelocs = false; @@ -57,6 +60,8 @@ public: /// v5 line table). explicit MCDwarfLineStr(MCContext &Ctx); + StringSaver &getSaver() { return Saver; } + /// Emit a reference to the string. void emitRef(MCStreamer *MCOS, StringRef Path); @@ -382,6 +387,7 @@ public: bool hasRootFile() const { return !Header.RootFile.Name.empty(); } + MCDwarfFile &getRootFile() { return Header.RootFile; } const MCDwarfFile &getRootFile() const { return Header.RootFile; } // Report whether MD5 usage has been consistent (all-or-none). diff --git a/contrib/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/contrib/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp index aa35f253bc5f..8311b480ab09 100644 --- a/contrib/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/contrib/llvm-project/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -280,7 +280,8 @@ void RuntimePointerChecking::tryToCreateDiffCheck( auto *SrcAR = dyn_cast(Src->Expr); auto *SinkAR = dyn_cast(Sink->Expr); - if (!SrcAR || !SinkAR) { + if (!SrcAR || !SinkAR || SrcAR->getLoop() != DC.getInnermostLoop() || + SinkAR->getLoop() != DC.getInnermostLoop()) { CanUseDiffCheck = false; return; } diff --git a/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp index 8d465b9520de..a7f9382478d4 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp @@ -6360,7 +6360,8 @@ SDValue DAGCombiner::visitAND(SDNode *N) { SDValue Extendee = Ext->getOperand(0); unsigned ScalarWidth = Extendee.getValueType().getScalarSizeInBits(); - if (N1C->getAPIntValue().isMask(ScalarWidth)) { + if (N1C->getAPIntValue().isMask(ScalarWidth) && + (!LegalOperations || TLI.isOperationLegal(ISD::ZERO_EXTEND, ExtVT))) { // (and (extract_subvector (zext|anyext|sext v) _) iN_mask) // => (extract_subvector (iN_zeroext v)) SDValue ZeroExtExtendee = @@ -7162,9 +7163,8 @@ static SDValue extractShiftForRotate(SelectionDAG &DAG, SDValue OppShift, SDValue ExtractFrom, SDValue &Mask, const SDLoc &DL) { assert(OppShift && ExtractFrom && "Empty SDValue"); - assert( - (OppShift.getOpcode() == ISD::SHL || OppShift.getOpcode() == ISD::SRL) && - "Existing shift must be valid as a rotate half"); + if (OppShift.getOpcode() != ISD::SHL && OppShift.getOpcode() != ISD::SRL) + return SDValue(); ExtractFrom = stripConstantMask(DAG, ExtractFrom, Mask); @@ -7573,6 +7573,10 @@ SDValue DAGCombiner::MatchRotate(SDValue LHS, SDValue RHS, const SDLoc &DL) { std::swap(LHSMask, RHSMask); } + // Something has gone wrong - we've lost the shl/srl pair - bail. + if (LHSShift.getOpcode() != ISD::SHL || RHSShift.getOpcode() != ISD::SRL) + return SDValue(); + unsigned EltSizeInBits = VT.getScalarSizeInBits(); SDValue LHSShiftArg = LHSShift.getOperand(0); SDValue LHSShiftAmt = LHSShift.getOperand(1); @@ -22729,25 +22733,31 @@ SDValue DAGCombiner::visitVECTOR_SHUFFLE(SDNode *N) { SDLoc DL(N); EVT IntVT = VT.changeVectorElementTypeToInteger(); EVT IntSVT = VT.getVectorElementType().changeTypeToInteger(); - IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT); - SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT); - SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT); - SmallVector AndMask(NumElts, DAG.getUNDEF(IntSVT)); - for (int I = 0; I != (int)NumElts; ++I) - if (0 <= Mask[I]) - AndMask[I] = Mask[I] == I ? AllOnesElt : ZeroElt; - - // See if a clear mask is legal instead of going via - // XformToShuffleWithZero which loses UNDEF mask elements. - if (TLI.isVectorClearMaskLegal(ClearMask, IntVT)) - return DAG.getBitcast( - VT, DAG.getVectorShuffle(IntVT, DL, DAG.getBitcast(IntVT, N0), - DAG.getConstant(0, DL, IntVT), ClearMask)); - - if (TLI.isOperationLegalOrCustom(ISD::AND, IntVT)) - return DAG.getBitcast( - VT, DAG.getNode(ISD::AND, DL, IntVT, DAG.getBitcast(IntVT, N0), - DAG.getBuildVector(IntVT, DL, AndMask))); + // Transform the type to a legal type so that the buildvector constant + // elements are not illegal. Make sure that the result is larger than the + // original type, incase the value is split into two (eg i64->i32). + if (!TLI.isTypeLegal(IntSVT) && LegalTypes) + IntSVT = TLI.getTypeToTransformTo(*DAG.getContext(), IntSVT); + if (IntSVT.getSizeInBits() >= IntVT.getScalarSizeInBits()) { + SDValue ZeroElt = DAG.getConstant(0, DL, IntSVT); + SDValue AllOnesElt = DAG.getAllOnesConstant(DL, IntSVT); + SmallVector AndMask(NumElts, DAG.getUNDEF(IntSVT)); + for (int I = 0; I != (int)NumElts; ++I) + if (0 <= Mask[I]) + AndMask[I] = Mask[I] == I ? AllOnesElt : ZeroElt; + + // See if a clear mask is legal instead of going via + // XformToShuffleWithZero which loses UNDEF mask elements. + if (TLI.isVectorClearMaskLegal(ClearMask, IntVT)) + return DAG.getBitcast( + VT, DAG.getVectorShuffle(IntVT, DL, DAG.getBitcast(IntVT, N0), + DAG.getConstant(0, DL, IntVT), ClearMask)); + + if (TLI.isOperationLegalOrCustom(ISD::AND, IntVT)) + return DAG.getBitcast( + VT, DAG.getNode(ISD::AND, DL, IntVT, DAG.getBitcast(IntVT, N0), + DAG.getBuildVector(IntVT, DL, AndMask))); + } } } diff --git a/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp b/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp index 228d4a43ccde..e2173879c218 100644 --- a/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp +++ b/contrib/llvm-project/llvm/lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp @@ -4428,7 +4428,10 @@ void DAGTypeLegalizer::ExpandIntRes_XMULO(SDNode *N, else if (VT == MVT::i128) LC = RTLIB::MULO_I128; - if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC)) { + // If we don't have the libcall or if the function we are compiling is the + // implementation of the expected libcall (avoid inf-loop), expand inline. + if (LC == RTLIB::UNKNOWN_LIBCALL || !TLI.getLibcallName(LC) || + TLI.getLibcallName(LC) == DAG.getMachineFunction().getName()) { // FIXME: This is not an optimal expansion, but better than crashing. EVT WideVT = EVT::getIntegerVT(*DAG.getContext(), VT.getScalarSizeInBits() * 2); diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp index d2ed4fe018b5..5ea4c4cded7f 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -1382,10 +1382,12 @@ bool DWARFDebugLine::Prologue::getFileNameByIndex( IncludeDir = dwarf::toStringRef(IncludeDirectories[Entry.DirIdx - 1]); } - // For absolute paths only, include the compilation directory of compile unit. - // We know that FileName is not absolute, the only way to have an absolute - // path at this point would be if IncludeDir is absolute. - if (Kind == FileLineInfoKind::AbsoluteFilePath && !CompDir.empty() && + // For absolute paths only, include the compilation directory of compile unit, + // unless v5 DirIdx == 0 (IncludeDir indicates the compilation directory). We + // know that FileName is not absolute, the only way to have an absolute path + // at this point would be if IncludeDir is absolute. + if (Kind == FileLineInfoKind::AbsoluteFilePath && + (getVersion() < 5 || Entry.DirIdx != 0) && !CompDir.empty() && !isPathAbsoluteOnWindowsOrPosix(IncludeDir)) sys::path::append(FilePath, Style, CompDir); diff --git a/contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp b/contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp index 91a51485026e..d96c0c85d5bd 100644 --- a/contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp +++ b/contrib/llvm-project/llvm/lib/DebugInfo/Symbolize/MarkupFilter.cpp @@ -20,11 +20,14 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/Symbolize/Markup.h" +#include "llvm/DebugInfo/Symbolize/Symbolize.h" #include "llvm/Debuginfod/Debuginfod.h" #include "llvm/Demangle/Demangle.h" #include "llvm/Object/ObjectFile.h" #include "llvm/Support/Error.h" +#include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/WithColor.h" #include "llvm/Support/raw_ostream.h" @@ -32,9 +35,11 @@ using namespace llvm; using namespace llvm::symbolize; -MarkupFilter::MarkupFilter(raw_ostream &OS, Optional ColorsEnabled) - : OS(OS), ColorsEnabled(ColorsEnabled.value_or( - WithColor::defaultAutoDetectFunction()(OS))) {} +MarkupFilter::MarkupFilter(raw_ostream &OS, LLVMSymbolizer &Symbolizer, + Optional ColorsEnabled) + : OS(OS), Symbolizer(Symbolizer), + ColorsEnabled( + ColorsEnabled.value_or(WithColor::defaultAutoDetectFunction()(OS))) {} void MarkupFilter::filter(StringRef Line) { this->Line = Line; @@ -94,10 +99,10 @@ bool MarkupFilter::tryMMap(const MarkupNode &Node, if (!ParsedMMap) return true; - if (const MMap *M = overlappingMMap(*ParsedMMap)) { + if (const MMap *M = getOverlappingMMap(*ParsedMMap)) { WithColor::error(errs()) - << formatv("overlapping mmap: #{0:x} [{1:x},{2:x})\n", M->Mod->ID, - M->Addr, M->Addr + M->Size); + << formatv("overlapping mmap: #{0:x} [{1:x}-{2:x}]\n", M->Mod->ID, + M->Addr, M->Addr + M->Size - 1); reportLocation(Node.Fields[0].begin()); return true; } @@ -160,18 +165,17 @@ bool MarkupFilter::tryModule(const MarkupNode &Node, filterNode(Node); beginModuleInfoLine(&Module); OS << "; BuildID="; - highlightValue(); - OS << toHex(Module.BuildID, /*LowerCase=*/true); - highlight(); + printValue(toHex(Module.BuildID, /*LowerCase=*/true)); return true; } void MarkupFilter::beginModuleInfoLine(const Module *M) { highlight(); OS << "[[[ELF module"; - highlightValue(); - OS << formatv(" #{0:x} \"{1}\"", M->ID, M->Name); - highlight(); + printValue(formatv(" #{0:x} ", M->ID)); + OS << '"'; + printValue(M->Name); + OS << '"'; MIL = ModuleInfoLine{M}; } @@ -182,14 +186,13 @@ void MarkupFilter::endAnyModuleInfoLine() { return A->Addr < B->Addr; }); for (const MMap *M : MIL->MMaps) { - OS << (M == MIL->MMaps.front() ? ' ' : '-'); - highlightValue(); - OS << formatv("{0:x}", M->Addr); - highlight(); - OS << '('; - highlightValue(); - OS << M->Mode; - highlight(); + OS << (M == MIL->MMaps.front() ? ' ' : ','); + OS << '['; + printValue(formatv("{0:x}", M->Addr)); + OS << '-'; + printValue(formatv("{0:x}", M->Addr + M->Size - 1)); + OS << "]("; + printValue(M->Mode); OS << ')'; } OS << "]]]" << lineEnding(); @@ -210,7 +213,13 @@ void MarkupFilter::filterNode(const MarkupNode &Node) { } bool MarkupFilter::tryPresentation(const MarkupNode &Node) { - return trySymbol(Node); + if (trySymbol(Node)) + return true; + if (tryPC(Node)) + return true; + if (tryBackTrace(Node)) + return true; + return tryData(Node); } bool MarkupFilter::trySymbol(const MarkupNode &Node) { @@ -225,6 +234,172 @@ bool MarkupFilter::trySymbol(const MarkupNode &Node) { return true; } +bool MarkupFilter::tryPC(const MarkupNode &Node) { + if (Node.Tag != "pc") + return false; + if (!checkNumFieldsAtLeast(Node, 1)) + return true; + if (!checkNumFieldsAtMost(Node, 2)) + return true; + + Optional Addr = parseAddr(Node.Fields[0]); + if (!Addr) + return true; + + // PC addresses that aren't part of a backtrace are assumed to be precise code + // locations. + PCType Type = PCType::PreciseCode; + if (Node.Fields.size() == 2) { + Optional ParsedType = parsePCType(Node.Fields[1]); + if (!ParsedType) + return true; + Type = *ParsedType; + } + *Addr = adjustAddr(*Addr, Type); + + const MMap *MMap = getContainingMMap(*Addr); + if (!MMap) { + WithColor::error() << "no mmap covers address\n"; + reportLocation(Node.Fields[0].begin()); + printRawElement(Node); + return true; + } + + Expected LI = Symbolizer.symbolizeCode( + MMap->Mod->BuildID, {MMap->getModuleRelativeAddr(*Addr)}); + if (!LI) { + WithColor::defaultErrorHandler(LI.takeError()); + printRawElement(Node); + return true; + } + if (!*LI) { + printRawElement(Node); + return true; + } + + highlight(); + printValue(LI->FunctionName); *** 777 LINES SKIPPED ***