Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 25 Dec 2021 11:55:27 GMT
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: e405b2dc913c - stable/12 - Merge llvm-project 12.0.0 release
Message-ID:  <202112251155.1BPBtRBf006288@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/12 has been updated by dim:

URL: https://cgit.FreeBSD.org/src/commit/?id=e405b2dc913c99189aa9b923ed686a790253cc7e

commit e405b2dc913c99189aa9b923ed686a790253cc7e
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2021-04-26 11:23:24 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2021-12-25 11:51:06 +0000

    Merge llvm-project 12.0.0 release
    
    This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
    openmp to llvmorg-12.0.0-0-gd28af7c654d8, a.k.a. 12.0.0 release.
    
    PR:             255570
    MFC after:      6 weeks
    
    (cherry picked from commit d409305fa3838fb39b38c26fc085fb729b8766d5)
---
 .../clang/include/clang/AST/ASTContext.h           |    3 +
 .../llvm-project/clang/include/clang/AST/Decl.h    |   11 +-
 .../llvm-project/clang/include/clang/AST/DeclCXX.h |    6 +
 .../llvm-project/clang/include/clang/AST/Expr.h    |    3 +-
 .../llvm-project/clang/include/clang/AST/Mangle.h  |    3 +
 .../include/clang/AST/MangleNumberingContext.h     |    5 +
 .../clang/include/clang/AST/RecursiveASTVisitor.h  |   12 +
 .../clang/include/clang/ASTMatchers/ASTMatchers.h  |    2 +-
 .../clang/include/clang/Basic/CodeGenOptions.def   |    3 +
 .../clang/include/clang/Basic/CodeGenOptions.h     |    6 +
 .../clang/include/clang/Driver/Options.td          |    7 +-
 .../clang/include/clang/Lex/VariadicMacroSupport.h |   10 +-
 .../llvm-project/clang/include/clang/Sema/Sema.h   |   18 +-
 contrib/llvm-project/clang/lib/AST/ASTImporter.cpp |    2 +
 contrib/llvm-project/clang/lib/AST/CXXABI.h        |    5 +-
 contrib/llvm-project/clang/lib/AST/Decl.cpp        |   29 +-
 contrib/llvm-project/clang/lib/AST/DeclCXX.cpp     |   14 +
 .../llvm-project/clang/lib/AST/ExprConstant.cpp    |   50 +-
 .../llvm-project/clang/lib/AST/ItaniumCXXABI.cpp   |    6 +
 .../llvm-project/clang/lib/AST/ItaniumMangle.cpp   |  346 +++--
 .../llvm-project/clang/lib/AST/MicrosoftCXXABI.cpp |   33 +-
 .../clang/lib/ASTMatchers/ASTMatchFinder.cpp       |   48 +-
 .../clang/lib/ASTMatchers/ASTMatchersInternal.cpp  |    2 +-
 .../llvm-project/clang/lib/Basic/ProfileList.cpp   |    1 +
 .../llvm-project/clang/lib/Basic/Targets/PPC.cpp   |    3 -
 .../llvm-project/clang/lib/Basic/Targets/RISCV.cpp |    6 +-
 .../llvm-project/clang/lib/CodeGen/CGBuiltin.cpp   |    2 +
 .../llvm-project/clang/lib/CodeGen/CGCUDANV.cpp    |    8 +
 contrib/llvm-project/clang/lib/CodeGen/CGCall.cpp  |    5 +
 .../clang/lib/CodeGen/CGExprConstant.cpp           |    2 +-
 .../clang/lib/CodeGen/CGOpenMPRuntime.cpp          |   34 +-
 .../clang/lib/CodeGen/CodeGenFunction.h            |   11 +
 .../clang/lib/Driver/ToolChains/Arch/RISCV.cpp     |    2 +-
 .../clang/lib/Driver/ToolChains/Clang.cpp          |   15 +-
 .../clang/lib/Driver/ToolChains/CommonArgs.cpp     |    5 +
 .../clang/lib/Driver/ToolChains/Linux.cpp          |    9 -
 .../clang/lib/Driver/ToolChains/MSVC.cpp           |    6 +-
 .../clang/lib/Driver/ToolChains/OpenBSD.cpp        |    1 +
 .../clang/lib/Format/UnwrappedLineFormatter.cpp    |    2 +-
 .../clang/lib/Frontend/CompilerInvocation.cpp      |    7 +-
 .../clang/lib/Frontend/InitPreprocessor.cpp        |    2 +-
 .../llvm-project/clang/lib/Headers/avx512fintrin.h |   16 +-
 .../llvm-project/clang/lib/Lex/Preprocessor.cpp    |    8 +-
 contrib/llvm-project/clang/lib/Lex/TokenLexer.cpp  |   10 +-
 contrib/llvm-project/clang/lib/Parse/ParseDecl.cpp |    3 +-
 contrib/llvm-project/clang/lib/Sema/Sema.cpp       |   43 +-
 .../clang/lib/Sema/SemaCodeComplete.cpp            |   21 +-
 contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp   |   88 +-
 contrib/llvm-project/clang/lib/Sema/SemaExpr.cpp   |    2 +-
 contrib/llvm-project/clang/lib/Sema/SemaLambda.cpp |   10 +-
 contrib/llvm-project/clang/lib/Sema/SemaOpenMP.cpp |   23 +-
 .../llvm-project/clang/lib/Sema/TreeTransform.h    |    7 +-
 .../clang/lib/Serialization/ASTReaderDecl.cpp      |    1 +
 .../clang/lib/Serialization/ASTWriter.cpp          |    1 +
 .../sanitizer_platform_interceptors.h              |    2 +-
 contrib/llvm-project/libcxx/include/__locale       |   20 +-
 .../libcxx/include/__threading_support             |    2 +-
 contrib/llvm-project/libcxx/include/bit            |    2 +-
 contrib/llvm-project/libcxx/include/limits         |    4 +-
 contrib/llvm-project/libcxx/include/memory         |    2 +-
 contrib/llvm-project/libcxx/src/atomic.cpp         |    6 +
 contrib/llvm-project/libcxx/src/locale.cpp         |    2 +-
 contrib/llvm-project/lld/ELF/InputSection.cpp      |    5 +-
 contrib/llvm-project/lld/docs/ReleaseNotes.rst     |  108 +-
 .../source/Host/common/NativeProcessProtocol.cpp   |   11 +-
 .../Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp   |   48 +-
 .../Plugins/Platform/FreeBSD/PlatformFreeBSD.h     |    3 -
 .../Plugins/Process/FreeBSD/FreeBSDThread.cpp      |  615 ---------
 .../source/Plugins/Process/FreeBSD/FreeBSDThread.h |  111 --
 .../NativeProcessFreeBSD.cpp                       |   57 +-
 .../NativeProcessFreeBSD.h                         |   11 +-
 .../NativeRegisterContextFreeBSD.cpp               |    2 +-
 .../NativeRegisterContextFreeBSD.h                 |    0
 .../FreeBSD/NativeRegisterContextFreeBSD_arm.cpp   |  202 +++
 .../FreeBSD/NativeRegisterContextFreeBSD_arm.h     |   68 +
 .../FreeBSD/NativeRegisterContextFreeBSD_arm64.cpp |  288 ++++
 .../FreeBSD/NativeRegisterContextFreeBSD_arm64.h   |   86 ++
 .../NativeRegisterContextFreeBSD_mips64.cpp        |  186 +++
 .../FreeBSD/NativeRegisterContextFreeBSD_mips64.h  |   71 +
 .../NativeRegisterContextFreeBSD_powerpc.cpp       |  289 ++++
 .../FreeBSD/NativeRegisterContextFreeBSD_powerpc.h |   74 +
 .../NativeRegisterContextFreeBSD_x86_64.cpp        |    0
 .../NativeRegisterContextFreeBSD_x86_64.h          |    6 +-
 .../NativeThreadFreeBSD.cpp                        |    5 +
 .../NativeThreadFreeBSD.h                          |    2 +-
 .../Plugins/Process/FreeBSD/POSIXStopInfo.cpp      |   44 -
 .../source/Plugins/Process/FreeBSD/POSIXStopInfo.h |   66 -
 .../Plugins/Process/FreeBSD/ProcessFreeBSD.cpp     | 1080 ---------------
 .../Plugins/Process/FreeBSD/ProcessFreeBSD.h       |  221 ---
 .../Plugins/Process/FreeBSD/ProcessMonitor.cpp     | 1424 --------------------
 .../Plugins/Process/FreeBSD/ProcessMonitor.h       |  279 ----
 .../Plugins/Process/FreeBSD/RegisterContextPOSIX.h |   63 -
 .../RegisterContextPOSIXProcessMonitor_arm.cpp     |  260 ----
 .../RegisterContextPOSIXProcessMonitor_arm.h       |   80 --
 .../RegisterContextPOSIXProcessMonitor_arm64.cpp   |  267 ----
 .../RegisterContextPOSIXProcessMonitor_arm64.h     |   82 --
 .../RegisterContextPOSIXProcessMonitor_mips64.cpp  |  262 ----
 .../RegisterContextPOSIXProcessMonitor_mips64.h    |   82 --
 .../RegisterContextPOSIXProcessMonitor_powerpc.cpp |  274 ----
 .../RegisterContextPOSIXProcessMonitor_powerpc.h   |   84 --
 .../RegisterContextPOSIXProcessMonitor_x86.cpp     |  613 ---------
 .../RegisterContextPOSIXProcessMonitor_x86.h       |   81 --
 .../NetBSD/NativeRegisterContextNetBSD_x86_64.h    |    4 +-
 .../Utility/NativeProcessSoftwareSingleStep.cpp    |  182 +++
 .../Utility/NativeProcessSoftwareSingleStep.h      |   31 +
 .../Utility/NativeRegisterContextDBReg_arm64.cpp   |  466 +++++++
 .../Utility/NativeRegisterContextDBReg_arm64.h     |   79 ++
 ..._x86.cpp => NativeRegisterContextDBReg_x86.cpp} |   38 +-
 ...oint_x86.h => NativeRegisterContextDBReg_x86.h} |   10 +-
 .../Process/Utility/RegisterInfos_powerpc.h        |    4 +-
 .../lldb/tools/lldb-server/lldb-gdbserver.cpp      |    2 +-
 contrib/llvm-project/llvm/include/llvm-c/Core.h    |    6 +-
 contrib/llvm-project/llvm/include/llvm-c/Orc.h     |    7 +-
 .../llvm/include/llvm/Analysis/AssumptionCache.h   |    2 +-
 .../llvm/include/llvm/CodeGen/FastISel.h           |    5 +-
 .../llvm/include/llvm/CodeGen/MachineInstr.h       |    7 +
 .../llvm/include/llvm/CodeGen/TargetLowering.h     |    4 +
 .../llvm/include/llvm/Demangle/ItaniumDemangle.h   |   68 +-
 .../llvm/include/llvm/Frontend/OpenMP/OMPKinds.def |    4 +-
 .../llvm-project/llvm/include/llvm/IR/InstrTypes.h |    3 -
 .../llvm/include/llvm/IR/Instruction.h             |    7 +
 .../llvm/include/llvm/IR/IntrinsicInst.h           |    8 +-
 .../llvm/include/llvm/IR/Intrinsics.td             |    2 +-
 .../llvm/include/llvm/IR/IntrinsicsRISCV.td        |    7 +-
 .../llvm-project/llvm/include/llvm/IR/Metadata.h   |   18 +
 .../llvm-project/llvm/include/llvm/IR/Operator.h   |    5 +
 .../llvm/include/llvm/IR/PseudoProbe.h             |   27 +-
 .../include/llvm/Passes/StandardInstrumentations.h |    2 +
 .../llvm/include/llvm/ProfileData/ProfileCommon.h  |    3 +
 .../llvm/include/llvm/ProfileData/SampleProf.h     |   29 +-
 .../include/llvm/ProfileData/SampleProfReader.h    |    4 +
 .../llvm/include/llvm/Support/CommandLine.h        |   13 +
 .../llvm/Transforms/IPO/SampleContextTracker.h     |   19 +-
 .../llvm/Transforms/IPO/SampleProfileProbe.h       |   41 +
 .../llvm/include/llvm/Transforms/Utils/Cloning.h   |    7 +
 .../llvm/lib/Analysis/DemandedBits.cpp             |    2 +-
 .../llvm/lib/Analysis/IVDescriptors.cpp            |    5 +-
 .../llvm-project/llvm/lib/Analysis/MemorySSA.cpp   |   26 -
 .../llvm/lib/Analysis/TypeBasedAliasAnalysis.cpp   |   81 ++
 .../llvm/lib/Analysis/ValueTracking.cpp            |   28 +-
 .../llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp |    9 +-
 .../lib/CodeGen/GlobalISel/LegalizerHelper.cpp     |    5 +
 .../llvm/lib/CodeGen/LiveRangeShrink.cpp           |    3 +-
 .../llvm-project/llvm/lib/CodeGen/MachineInstr.cpp |    3 +-
 .../llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp  |   17 +-
 .../llvm/lib/CodeGen/SelectionDAG/FastISel.cpp     |   10 +-
 .../CodeGen/SelectionDAG/SelectionDAGBuilder.cpp   |    5 +-
 .../lib/CodeGen/SelectionDAG/TargetLowering.cpp    |   31 +-
 .../llvm/lib/CodeGen/StackProtector.cpp            |    2 +-
 .../llvm/lib/CodeGen/TwoAddressInstructionPass.cpp |    8 +-
 .../lib/ExecutionEngine/Orc/OrcV2CBindings.cpp     |    2 +-
 contrib/llvm-project/llvm/lib/IR/AutoUpgrade.cpp   |   42 +
 contrib/llvm-project/llvm/lib/IR/ConstantFold.cpp  |   59 +-
 contrib/llvm-project/llvm/lib/IR/Instruction.cpp   |   14 +
 contrib/llvm-project/llvm/lib/IR/Operator.cpp      |   20 +-
 contrib/llvm-project/llvm/lib/IR/PseudoProbe.cpp   |   41 +
 contrib/llvm-project/llvm/lib/IR/Verifier.cpp      |    6 -
 .../llvm-project/llvm/lib/MC/ELFObjectWriter.cpp   |   11 +
 .../llvm-project/llvm/lib/Passes/PassBuilder.cpp   |    6 +
 .../llvm-project/llvm/lib/Passes/PassRegistry.def  |    1 +
 .../llvm/lib/Passes/StandardInstrumentations.cpp   |    1 +
 .../lib/ProfileData/Coverage/CoverageMapping.cpp   |    1 -
 .../llvm/lib/ProfileData/ProfileSummaryBuilder.cpp |   34 +
 .../llvm/lib/ProfileData/SampleProfReader.cpp      |   99 +-
 .../llvm/lib/ProfileData/SampleProfWriter.cpp      |   15 +-
 .../llvm-project/llvm/lib/Support/CommandLine.cpp  |   25 +-
 .../llvm-project/llvm/lib/Support/Windows/Path.inc |   24 +-
 .../lib/Target/AArch64/AArch64ISelLowering.cpp     |    7 +-
 .../AArch64/MCTargetDesc/AArch64MCAsmInfo.cpp      |    2 +-
 .../lib/Target/AMDGPU/SIShrinkInstructions.cpp     |   24 +-
 .../llvm/lib/Target/ARM/ARMISelLowering.cpp        |    6 +-
 .../llvm/lib/Target/PowerPC/PPCISelDAGToDAG.cpp    |    6 +
 .../llvm/lib/Target/PowerPC/PPCISelLowering.cpp    |   12 +-
 .../llvm/lib/Target/PowerPC/PPCISelLowering.h      |    3 +
 .../lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp  |    6 +-
 .../RISCV/MCTargetDesc/RISCVTargetStreamer.cpp     |    6 +-
 .../llvm/lib/Target/RISCV/RISCVCleanupVSETVLI.cpp  |   37 +-
 .../lib/Target/RISCV/RISCVExpandPseudoInsts.cpp    |   11 +-
 .../llvm/lib/Target/RISCV/RISCVISelDAGToDAG.cpp    |  118 +-
 .../llvm/lib/Target/RISCV/RISCVISelDAGToDAG.h      |    5 +-
 .../llvm/lib/Target/RISCV/RISCVInstrFormatsV.td    |   23 +-
 .../llvm/lib/Target/RISCV/RISCVInstrInfoB.td       |   67 -
 .../llvm/lib/Target/RISCV/RISCVInstrInfoV.td       |  116 +-
 .../lib/Target/RISCV/RISCVInstrInfoVPseudos.td     |  239 ++--
 .../lib/Target/RISCV/RISCVInstrInfoVSDPatterns.td  |    6 +-
 contrib/llvm-project/llvm/lib/Target/VE/VE.h       |   10 +-
 .../Target/X86/Disassembler/X86Disassembler.cpp    |    1 +
 .../llvm/lib/Target/X86/X86FastISel.cpp            |    8 +
 .../llvm/lib/Target/X86/X86ISelLowering.cpp        |    9 +-
 .../llvm/lib/Target/X86/X86InstrAVX512.td          |    4 +-
 .../llvm/lib/Target/X86/X86InstrSSE.td             |   16 +-
 .../llvm/lib/Transforms/IPO/FunctionAttrs.cpp      |   10 +-
 .../lib/Transforms/IPO/SampleContextTracker.cpp    |  118 +-
 .../llvm/lib/Transforms/IPO/SampleProfile.cpp      |  713 ++++++++--
 .../llvm/lib/Transforms/IPO/SampleProfileProbe.cpp |  162 ++-
 .../Transforms/InstCombine/InstCombineCasts.cpp    |    1 +
 .../lib/Transforms/InstCombine/InstCombinePHI.cpp  |    8 +-
 .../InstCombine/InstCombineSimplifyDemanded.cpp    |    8 +-
 .../InstCombine/InstructionCombining.cpp           |    7 +-
 .../llvm/lib/Transforms/Scalar/ADCE.cpp            |    2 +-
 .../llvm/lib/Transforms/Scalar/JumpThreading.cpp   |   10 +
 .../llvm/lib/Transforms/Scalar/LoopUnswitch.cpp    |   10 +-
 .../llvm/lib/Transforms/Scalar/SROA.cpp            |   38 +-
 .../llvm/lib/Transforms/Utils/BuildLibCalls.cpp    |   67 -
 .../llvm/lib/Transforms/Utils/CloneFunction.cpp    |    8 +
 .../llvm/lib/Transforms/Utils/InlineFunction.cpp   |   12 +-
 .../llvm/lib/Transforms/Utils/Local.cpp            |   33 +-
 .../llvm/lib/Transforms/Utils/LoopPeel.cpp         |   19 +-
 .../llvm/lib/Transforms/Utils/SimplifyCFG.cpp      |   19 +-
 .../Vectorize/LoopVectorizationPlanner.h           |    4 +
 .../lib/Transforms/Vectorize/LoopVectorize.cpp     |   40 +-
 .../llvm-project/llvm/tools/llvm-dwp/llvm-dwp.cpp  |    4 +-
 .../llvm/tools/llvm-objdump/llvm-objdump.cpp       |   30 +-
 .../llvm/tools/llvm-profdata/llvm-profdata.cpp     |    2 +-
 .../llvm/tools/llvm-symbolizer/llvm-symbolizer.cpp |    7 +-
 .../llvm/utils/TableGen/IntrinsicEmitter.cpp       |    4 +-
 .../openmp/runtime/src/kmp_config.h.cmake          |    4 +-
 .../openmp/runtime/src/kmp_runtime.cpp             |   21 +-
 .../openmp/runtime/src/kmp_settings.cpp            |   10 +-
 .../openmp/runtime/src/kmp_tasking.cpp             |    3 +-
 etc/mtree/BSD.include.dist                         |    2 +
 lib/clang/include/Plugins/Plugins.def              |    1 -
 lib/clang/include/VCSVersion.inc                   |    8 +-
 lib/clang/include/clang/Config/config.h            |    2 +-
 lib/clang/include/llvm/Config/config.h             |    4 +-
 lib/clang/include/llvm/Config/llvm-config.h        |    2 +-
 lib/clang/include/llvm/Support/VCSRevision.h       |    2 +-
 lib/clang/liblldb/Makefile                         |   36 +-
 lib/clang/libllvm/Makefile                         |    1 +
 lib/libc++/Makefile                                |   26 +-
 lib/libc++/__config_site                           |   40 +
 lib/libomp/kmp_config.h                            |   18 +
 lib/libomp/kmp_i18n_default.inc                    |   10 +-
 lib/libomp/kmp_i18n_id.inc                         |    4 +-
 lib/libomp/omp-tools.h                             |  141 +-
 lib/libomp/omp.h                                   |  144 +-
 sys/sys/param.h                                    |    2 +-
 tools/build/mk/OptionalObsoleteFiles.inc           |   11 +
 usr.bin/clang/Makefile                             |    1 +
 usr.bin/clang/bugpoint/bugpoint.1                  |    8 +-
 usr.bin/clang/clang/clang.1                        |   42 +-
 usr.bin/clang/llc/llc.1                            |   22 +-
 usr.bin/clang/lldb-server/Makefile                 |   53 +
 usr.bin/clang/lldb-server/lldb-server.1            |  262 ++++
 usr.bin/clang/lldb/lldb.1                          |   39 +-
 usr.bin/clang/lli/lli.1                            |   10 +-
 usr.bin/clang/llvm-ar/llvm-ar.1                    |   10 +-
 usr.bin/clang/llvm-ar/llvm-ranlib.1                |    8 +-
 usr.bin/clang/llvm-as/llvm-as.1                    |    8 +-
 usr.bin/clang/llvm-bcanalyzer/llvm-bcanalyzer.1    |    8 +-
 usr.bin/clang/llvm-cov/llvm-cov.1                  |   25 +-
 usr.bin/clang/llvm-cxxfilt/llvm-cxxfilt.1          |   18 +-
 usr.bin/clang/llvm-diff/llvm-diff.1                |    8 +-
 usr.bin/clang/llvm-dis/llvm-dis.1                  |    8 +-
 usr.bin/clang/llvm-dwarfdump/llvm-dwarfdump.1      |   54 +-
 usr.bin/clang/llvm-extract/llvm-extract.1          |   56 +-
 usr.bin/clang/llvm-link/llvm-link.1                |    8 +-
 usr.bin/clang/llvm-mca/llvm-mca.1                  |   25 +-
 usr.bin/clang/llvm-nm/llvm-nm.1                    |   15 +-
 usr.bin/clang/llvm-objcopy/llvm-objcopy.1          |  116 +-
 usr.bin/clang/llvm-objdump/llvm-objdump.1          |  683 +++++++---
 usr.bin/clang/llvm-pdbutil/llvm-pdbutil.1          |    8 +-
 usr.bin/clang/llvm-profdata/llvm-profdata.1        |   85 +-
 usr.bin/clang/llvm-size/llvm-size.1                |   10 +-
 usr.bin/clang/llvm-strings/llvm-strings.1          |   10 +-
 usr.bin/clang/llvm-symbolizer/llvm-addr2line.1     |   29 +-
 usr.bin/clang/llvm-symbolizer/llvm-symbolizer.1    |   98 +-
 usr.bin/clang/llvm-tblgen/llvm-tblgen.1            |  806 ++++++++++-
 usr.bin/clang/opt/opt.1                            |    8 +-
 269 files changed, 7470 insertions(+), 7919 deletions(-)

diff --git a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
index ce47d54e44b0..ae69a68608b7 100644
--- a/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
+++ b/contrib/llvm-project/clang/include/clang/AST/ASTContext.h
@@ -538,6 +538,9 @@ private:
   /// need them (like static local vars).
   llvm::MapVector<const NamedDecl *, unsigned> MangleNumbers;
   llvm::MapVector<const VarDecl *, unsigned> StaticLocalNumbers;
+  /// Mapping the associated device lambda mangling number if present.
+  mutable llvm::DenseMap<const CXXRecordDecl *, unsigned>
+      DeviceLambdaManglingNumbers;
 
   /// Mapping that stores parameterIndex values for ParmVarDecls when
   /// that value exceeds the bitfield size of ParmVarDeclBits.ParameterIndex.
diff --git a/contrib/llvm-project/clang/include/clang/AST/Decl.h b/contrib/llvm-project/clang/include/clang/AST/Decl.h
index 47c282f0a63d..1c5827b9c3a4 100644
--- a/contrib/llvm-project/clang/include/clang/AST/Decl.h
+++ b/contrib/llvm-project/clang/include/clang/AST/Decl.h
@@ -1276,15 +1276,12 @@ public:
   EvaluatedStmt *getEvaluatedStmt() const;
 
   /// Attempt to evaluate the value of the initializer attached to this
-  /// declaration, and produce notes explaining why it cannot be evaluated.
-  /// Returns a pointer to the value if evaluation succeeded, 0 otherwise.
+  /// declaration, and produce notes explaining why it cannot be evaluated or is
+  /// not a constant expression. Returns a pointer to the value if evaluation
+  /// succeeded, 0 otherwise.
   APValue *evaluateValue() const;
+  APValue *evaluateValue(SmallVectorImpl<PartialDiagnosticAt> &Notes) const;
 
-private:
-  APValue *evaluateValueImpl(SmallVectorImpl<PartialDiagnosticAt> &Notes,
-                             bool IsConstantInitialization) const;
-
-public:
   /// Return the already-evaluated value of this variable's
   /// initializer, or NULL if the value is not yet known. Returns pointer
   /// to untyped APValue if the value could not be evaluated.
diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h b/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h
index e32101bb2276..89006b1cfa7f 100644
--- a/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h
+++ b/contrib/llvm-project/clang/include/clang/AST/DeclCXX.h
@@ -1735,6 +1735,12 @@ public:
     getLambdaData().HasKnownInternalLinkage = HasKnownInternalLinkage;
   }
 
+  /// Set the device side mangling number.
+  void setDeviceLambdaManglingNumber(unsigned Num) const;
+
+  /// Retrieve the device side mangling number.
+  unsigned getDeviceLambdaManglingNumber() const;
+
   /// Returns the inheritance model used for this record.
   MSInheritanceModel getMSInheritanceModel() const;
 
diff --git a/contrib/llvm-project/clang/include/clang/AST/Expr.h b/contrib/llvm-project/clang/include/clang/AST/Expr.h
index a44d06967431..52f8f18af205 100644
--- a/contrib/llvm-project/clang/include/clang/AST/Expr.h
+++ b/contrib/llvm-project/clang/include/clang/AST/Expr.h
@@ -699,8 +699,7 @@ public:
   /// notes will be produced if the expression is not a constant expression.
   bool EvaluateAsInitializer(APValue &Result, const ASTContext &Ctx,
                              const VarDecl *VD,
-                             SmallVectorImpl<PartialDiagnosticAt> &Notes,
-                             bool IsConstantInitializer) const;
+                             SmallVectorImpl<PartialDiagnosticAt> &Notes) const;
 
   /// EvaluateWithSubstitution - Evaluate an expression as if from the context
   /// of a call to the given function with the given arguments, inside an
diff --git a/contrib/llvm-project/clang/include/clang/AST/Mangle.h b/contrib/llvm-project/clang/include/clang/AST/Mangle.h
index 0e8d6dd53d8a..7b6495d85eb6 100644
--- a/contrib/llvm-project/clang/include/clang/AST/Mangle.h
+++ b/contrib/llvm-project/clang/include/clang/AST/Mangle.h
@@ -96,6 +96,9 @@ public:
   virtual bool shouldMangleCXXName(const NamedDecl *D) = 0;
   virtual bool shouldMangleStringLiteral(const StringLiteral *SL) = 0;
 
+  virtual bool isDeviceMangleContext() const { return false; }
+  virtual void setDeviceMangleContext(bool) {}
+
   // FIXME: consider replacing raw_ostream & with something like SmallString &.
   void mangleName(GlobalDecl GD, raw_ostream &);
   virtual void mangleCXXName(GlobalDecl GD, raw_ostream &) = 0;
diff --git a/contrib/llvm-project/clang/include/clang/AST/MangleNumberingContext.h b/contrib/llvm-project/clang/include/clang/AST/MangleNumberingContext.h
index f1ca6a05dbaf..eb33759682d6 100644
--- a/contrib/llvm-project/clang/include/clang/AST/MangleNumberingContext.h
+++ b/contrib/llvm-project/clang/include/clang/AST/MangleNumberingContext.h
@@ -52,6 +52,11 @@ public:
   /// this context.
   virtual unsigned getManglingNumber(const TagDecl *TD,
                                      unsigned MSLocalManglingNumber) = 0;
+
+  /// Retrieve the mangling number of a new lambda expression with the
+  /// given call operator within the device context. No device number is
+  /// assigned if there's no device numbering context is associated.
+  virtual unsigned getDeviceManglingNumber(const CXXMethodDecl *) { return 0; }
 };
 
 } // end namespace clang
diff --git a/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h b/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h
index 505ea700fd0e..7870cea198a7 100644
--- a/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h
+++ b/contrib/llvm-project/clang/include/clang/AST/RecursiveASTVisitor.h
@@ -186,6 +186,9 @@ public:
   /// code, e.g., implicit constructors and destructors.
   bool shouldVisitImplicitCode() const { return false; }
 
+  /// Return whether this visitor should recurse into lambda body
+  bool shouldVisitLambdaBody() const { return true; }
+
   /// Return whether this visitor should traverse post-order.
   bool shouldTraversePostOrder() const { return false; }
 
@@ -2057,6 +2060,15 @@ bool RecursiveASTVisitor<Derived>::TraverseFunctionHelper(FunctionDecl *D) {
       // by clang.
       (!D->isDefaulted() || getDerived().shouldVisitImplicitCode());
 
+  if (const auto *MD = dyn_cast<CXXMethodDecl>(D)) {
+    if (const CXXRecordDecl *RD = MD->getParent()) {
+      if (RD->isLambda() &&
+          declaresSameEntity(RD->getLambdaCallOperator(), MD)) {
+        VisitBody = VisitBody && getDerived().shouldVisitLambdaBody();
+      }
+    }
+  }
+
   if (VisitBody) {
     TRY_TO(TraverseStmt(D->getBody())); // Function body.
   }
diff --git a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h
index 6f6dfab59a39..031fa4682c3a 100644
--- a/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/contrib/llvm-project/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -344,7 +344,7 @@ extern const internal::VariadicAllOfMatcher<Decl> decl;
 ///   int number = 42;
 ///   auto [foo, bar] = std::make_pair{42, 42};
 /// \endcode
-extern const internal::VariadicAllOfMatcher<DecompositionDecl>
+extern const internal::VariadicDynCastAllOfMatcher<Decl, DecompositionDecl>
     decompositionDecl;
 
 /// Matches a declaration of a linkage specification.
diff --git a/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.def b/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.def
index 5c8af65326ed..9d53b5b923bb 100644
--- a/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.def
+++ b/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.def
@@ -266,6 +266,9 @@ CODEGENOPT(VectorizeLoop     , 1, 0) ///< Run loop vectorizer.
 CODEGENOPT(VectorizeSLP      , 1, 0) ///< Run SLP vectorizer.
 CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
 
+/// Treat loops as finite: language, always, never.
+ENUM_CODEGENOPT(FiniteLoops, FiniteLoopsKind, 2, FiniteLoopsKind::Language)
+
   /// Attempt to use register sized accesses to bit-fields in structures, when
   /// possible.
 CODEGENOPT(UseRegisterSizedBitfieldAccess , 1, 0)
diff --git a/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.h b/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.h
index 73d41e3293c6..c550817f0f69 100644
--- a/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.h
+++ b/contrib/llvm-project/clang/include/clang/Basic/CodeGenOptions.h
@@ -140,6 +140,12 @@ public:
     All,         // Keep all frame pointers.
   };
 
+  enum FiniteLoopsKind {
+    Language, // Not specified, use language standard.
+    Always,   // All loops are assumed to be finite.
+    Never,    // No loop is assumed to be finite.
+  };
+
   /// The code model to use (-mcmodel).
   std::string CodeModel;
 
diff --git a/contrib/llvm-project/clang/include/clang/Driver/Options.td b/contrib/llvm-project/clang/include/clang/Driver/Options.td
index 42c5319041d0..817798926650 100644
--- a/contrib/llvm-project/clang/include/clang/Driver/Options.td
+++ b/contrib/llvm-project/clang/include/clang/Driver/Options.td
@@ -1147,7 +1147,7 @@ def fprofile_update_EQ : Joined<["-"], "fprofile-update=">,
 defm pseudo_probe_for_profiling : BoolFOption<"pseudo-probe-for-profiling",
   CodeGenOpts<"PseudoProbeForProfiling">, DefaultFalse,
   PosFlag<SetTrue, [], "Emit">, NegFlag<SetFalse, [], "Do not emit">,
-  BothFlags<[NoXarchOption, CC1Option], " pseudo probes for sample profiler">>;
+  BothFlags<[NoXarchOption, CC1Option], " pseudo probes for sample profiling">>;
 def forder_file_instrumentation : Flag<["-"], "forder-file-instrumentation">,
     Group<f_Group>, Flags<[CC1Option, CoreOption]>,
     HelpText<"Generate instrumented code to collect order file into default.profraw file (overridden by '=' form of option or LLVM_PROFILE_FILE env var)">;
@@ -2410,6 +2410,11 @@ def fno_unroll_loops : Flag<["-"], "fno-unroll-loops">, Group<f_Group>,
 defm reroll_loops : BoolFOption<"reroll-loops",
   CodeGenOpts<"RerollLoops">, DefaultFalse,
   PosFlag<SetTrue, [CC1Option], "Turn on loop reroller">, NegFlag<SetFalse>>;
+def ffinite_loops: Flag<["-"],  "ffinite-loops">, Group<f_Group>,
+  HelpText<"Assume all loops are finite.">, Flags<[CC1Option]>;
+def fno_finite_loops: Flag<["-"], "fno-finite-loops">, Group<f_Group>,
+  HelpText<"Do not assume that any loop is finite.">, Flags<[CC1Option]>;
+
 def ftrigraphs : Flag<["-"], "ftrigraphs">, Group<f_Group>,
   HelpText<"Process trigraph sequences">, Flags<[CC1Option]>;
 def fno_trigraphs : Flag<["-"], "fno-trigraphs">, Group<f_Group>,
diff --git a/contrib/llvm-project/clang/include/clang/Lex/VariadicMacroSupport.h b/contrib/llvm-project/clang/include/clang/Lex/VariadicMacroSupport.h
index 989e0ac703c9..119f02201fc6 100644
--- a/contrib/llvm-project/clang/include/clang/Lex/VariadicMacroSupport.h
+++ b/contrib/llvm-project/clang/include/clang/Lex/VariadicMacroSupport.h
@@ -39,17 +39,14 @@ namespace clang {
       assert(Ident__VA_ARGS__->isPoisoned() && "__VA_ARGS__ should be poisoned "
                                               "outside an ISO C/C++ variadic "
                                               "macro definition!");
-      assert(
-          !Ident__VA_OPT__ ||
-          (Ident__VA_OPT__->isPoisoned() && "__VA_OPT__ should be poisoned!"));
+      assert(Ident__VA_OPT__->isPoisoned() && "__VA_OPT__ should be poisoned!");
     }
 
     /// Client code should call this function just before the Preprocessor is
     /// about to Lex tokens from the definition of a variadic (ISO C/C++) macro.
     void enterScope() {
       Ident__VA_ARGS__->setIsPoisoned(false);
-      if (Ident__VA_OPT__)
-        Ident__VA_OPT__->setIsPoisoned(false);
+      Ident__VA_OPT__->setIsPoisoned(false);
     }
 
     /// Client code should call this function as soon as the Preprocessor has
@@ -58,8 +55,7 @@ namespace clang {
     /// (might be explicitly called, and then reinvoked via the destructor).
     void exitScope() {
       Ident__VA_ARGS__->setIsPoisoned(true);
-      if (Ident__VA_OPT__)
-        Ident__VA_OPT__->setIsPoisoned(true);
+      Ident__VA_OPT__->setIsPoisoned(true);
     }
 
     ~VariadicMacroScopeGuard() { exitScope(); }
diff --git a/contrib/llvm-project/clang/include/clang/Sema/Sema.h b/contrib/llvm-project/clang/include/clang/Sema/Sema.h
index 7f7c84eb1b1d..2530a2776373 100644
--- a/contrib/llvm-project/clang/include/clang/Sema/Sema.h
+++ b/contrib/llvm-project/clang/include/clang/Sema/Sema.h
@@ -6558,7 +6558,7 @@ public:
   /// Number lambda for linkage purposes if necessary.
   void handleLambdaNumbering(
       CXXRecordDecl *Class, CXXMethodDecl *Method,
-      Optional<std::tuple<unsigned, bool, Decl *>> Mangling = None);
+      Optional<std::tuple<bool, unsigned, unsigned, Decl *>> Mangling = None);
 
   /// Endow the lambda scope info with the relevant properties.
   void buildLambdaScope(sema::LambdaScopeInfo *LSI,
@@ -11948,8 +11948,8 @@ public:
   ///  if (diagIfOpenMPDeviceCode(Loc, diag::err_vla_unsupported))
   ///    return ExprError();
   ///  // Otherwise, continue parsing as normal.
-  SemaDiagnosticBuilder diagIfOpenMPDeviceCode(SourceLocation Loc,
-                                               unsigned DiagID);
+  SemaDiagnosticBuilder
+  diagIfOpenMPDeviceCode(SourceLocation Loc, unsigned DiagID, FunctionDecl *FD);
 
   /// Creates a SemaDiagnosticBuilder that emits the diagnostic if the current
   /// context is "used as host code".
@@ -11965,17 +11965,19 @@ public:
   ///    return ExprError();
   ///  // Otherwise, continue parsing as normal.
   SemaDiagnosticBuilder diagIfOpenMPHostCode(SourceLocation Loc,
-                                             unsigned DiagID);
+                                             unsigned DiagID, FunctionDecl *FD);
 
-  SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID);
+  SemaDiagnosticBuilder targetDiag(SourceLocation Loc, unsigned DiagID,
+                                   FunctionDecl *FD = nullptr);
   SemaDiagnosticBuilder targetDiag(SourceLocation Loc,
-                                   const PartialDiagnostic &PD) {
-    return targetDiag(Loc, PD.getDiagID()) << PD;
+                                   const PartialDiagnostic &PD,
+                                   FunctionDecl *FD = nullptr) {
+    return targetDiag(Loc, PD.getDiagID(), FD) << PD;
   }
 
   /// Check if the expression is allowed to be used in expressions for the
   /// offloading devices.
-  void checkDeviceDecl(const ValueDecl *D, SourceLocation Loc);
+  void checkDeviceDecl(ValueDecl *D, SourceLocation Loc);
 
   enum CUDAFunctionTarget {
     CFT_Device,
diff --git a/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp b/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp
index 085c50c0667b..0d723fbbcd8c 100644
--- a/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp
+++ b/contrib/llvm-project/clang/lib/AST/ASTImporter.cpp
@@ -2848,6 +2848,8 @@ ExpectedDecl ASTNodeImporter::VisitRecordDecl(RecordDecl *D) {
         return CDeclOrErr.takeError();
       D2CXX->setLambdaMangling(DCXX->getLambdaManglingNumber(), *CDeclOrErr,
                                DCXX->hasKnownLambdaInternalLinkage());
+      D2CXX->setDeviceLambdaManglingNumber(
+          DCXX->getDeviceLambdaManglingNumber());
    } else if (DCXX->isInjectedClassName()) {
       // We have to be careful to do a similar dance to the one in
       // Sema::ActOnStartCXXMemberDeclarations
diff --git a/contrib/llvm-project/clang/lib/AST/CXXABI.h b/contrib/llvm-project/clang/lib/AST/CXXABI.h
index 31cb36918726..ca9424bcb7a4 100644
--- a/contrib/llvm-project/clang/lib/AST/CXXABI.h
+++ b/contrib/llvm-project/clang/lib/AST/CXXABI.h
@@ -22,8 +22,9 @@ class ASTContext;
 class CXXConstructorDecl;
 class DeclaratorDecl;
 class Expr;
-class MemberPointerType;
+class MangleContext;
 class MangleNumberingContext;
+class MemberPointerType;
 
 /// Implements C++ ABI-specific semantic analysis functions.
 class CXXABI {
@@ -75,6 +76,8 @@ public:
 /// Creates an instance of a C++ ABI class.
 CXXABI *CreateItaniumCXXABI(ASTContext &Ctx);
 CXXABI *CreateMicrosoftCXXABI(ASTContext &Ctx);
+std::unique_ptr<MangleNumberingContext>
+createItaniumNumberingContext(MangleContext *);
 }
 
 #endif
diff --git a/contrib/llvm-project/clang/lib/AST/Decl.cpp b/contrib/llvm-project/clang/lib/AST/Decl.cpp
index feb9b0645ebc..10cfe145b3f0 100644
--- a/contrib/llvm-project/clang/lib/AST/Decl.cpp
+++ b/contrib/llvm-project/clang/lib/AST/Decl.cpp
@@ -2384,11 +2384,11 @@ EvaluatedStmt *VarDecl::getEvaluatedStmt() const {
 
 APValue *VarDecl::evaluateValue() const {
   SmallVector<PartialDiagnosticAt, 8> Notes;
-  return evaluateValueImpl(Notes, hasConstantInitialization());
+  return evaluateValue(Notes);
 }
 
-APValue *VarDecl::evaluateValueImpl(SmallVectorImpl<PartialDiagnosticAt> &Notes,
-                                    bool IsConstantInitialization) const {
+APValue *VarDecl::evaluateValue(
+    SmallVectorImpl<PartialDiagnosticAt> &Notes) const {
   EvaluatedStmt *Eval = ensureEvaluatedStmt();
 
   const auto *Init = cast<Expr>(Eval->Value);
@@ -2407,16 +2407,8 @@ APValue *VarDecl::evaluateValueImpl(SmallVectorImpl<PartialDiagnosticAt> &Notes,
 
   Eval->IsEvaluating = true;
 
-  ASTContext &Ctx = getASTContext();
-  bool Result = Init->EvaluateAsInitializer(Eval->Evaluated, Ctx, this, Notes,
-                                            IsConstantInitialization);
-
-  // In C++11, this isn't a constant initializer if we produced notes. In that
-  // case, we can't keep the result, because it may only be correct under the
-  // assumption that the initializer is a constant context.
-  if (IsConstantInitialization && Ctx.getLangOpts().CPlusPlus11 &&
-      !Notes.empty())
-    Result = false;
+  bool Result = Init->EvaluateAsInitializer(Eval->Evaluated, getASTContext(),
+                                            this, Notes);
 
   // Ensure the computed APValue is cleaned up later if evaluation succeeded,
   // or that it's empty (so that there's nothing to clean up) if evaluation
@@ -2424,7 +2416,7 @@ APValue *VarDecl::evaluateValueImpl(SmallVectorImpl<PartialDiagnosticAt> &Notes,
   if (!Result)
     Eval->Evaluated = APValue();
   else if (Eval->Evaluated.needsCleanup())
-    Ctx.addDestruction(&Eval->Evaluated);
+    getASTContext().addDestruction(&Eval->Evaluated);
 
   Eval->IsEvaluating = false;
   Eval->WasEvaluated = true;
@@ -2478,14 +2470,7 @@ bool VarDecl::checkForConstantInitialization(
   assert(!cast<Expr>(Eval->Value)->isValueDependent());
 
   // Evaluate the initializer to check whether it's a constant expression.
-  Eval->HasConstantInitialization =
-      evaluateValueImpl(Notes, true) && Notes.empty();
-
-  // If evaluation as a constant initializer failed, allow re-evaluation as a
-  // non-constant initializer if we later find we want the value.
-  if (!Eval->HasConstantInitialization)
-    Eval->WasEvaluated = false;
-
+  Eval->HasConstantInitialization = evaluateValue(Notes) && Notes.empty();
   return Eval->HasConstantInitialization;
 }
 
diff --git a/contrib/llvm-project/clang/lib/AST/DeclCXX.cpp b/contrib/llvm-project/clang/lib/AST/DeclCXX.cpp
index 0368ada0b81c..0375f9b4432e 100644
--- a/contrib/llvm-project/clang/lib/AST/DeclCXX.cpp
+++ b/contrib/llvm-project/clang/lib/AST/DeclCXX.cpp
@@ -1593,6 +1593,20 @@ Decl *CXXRecordDecl::getLambdaContextDecl() const {
   return getLambdaData().ContextDecl.get(Source);
 }
 
+void CXXRecordDecl::setDeviceLambdaManglingNumber(unsigned Num) const {
+  assert(isLambda() && "Not a lambda closure type!");
+  if (Num)
+    getASTContext().DeviceLambdaManglingNumbers[this] = Num;
+}
+
+unsigned CXXRecordDecl::getDeviceLambdaManglingNumber() const {
+  assert(isLambda() && "Not a lambda closure type!");
+  auto I = getASTContext().DeviceLambdaManglingNumbers.find(this);
+  if (I != getASTContext().DeviceLambdaManglingNumbers.end())
+    return I->second;
+  return 0;
+}
+
 static CanQualType GetConversionType(ASTContext &Context, NamedDecl *Conv) {
   QualType T =
       cast<CXXConversionDecl>(Conv->getUnderlyingDecl()->getAsFunction())
diff --git a/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp b/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
index 56181bbe1166..b24025664684 100644
--- a/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
+++ b/contrib/llvm-project/clang/lib/AST/ExprConstant.cpp
@@ -3302,9 +3302,12 @@ static bool evaluateVarDeclInit(EvalInfo &Info, const Expr *E,
 
   // Check that we can fold the initializer. In C++, we will have already done
   // this in the cases where it matters for conformance.
-  if (!VD->evaluateValue()) {
-    Info.FFDiag(E, diag::note_constexpr_var_init_non_constant, 1) << VD;
+  SmallVector<PartialDiagnosticAt, 8> Notes;
+  if (!VD->evaluateValue(Notes)) {
+    Info.FFDiag(E, diag::note_constexpr_var_init_non_constant,
+              Notes.size() + 1) << VD;
     NoteLValueLocation(Info, Base);
+    Info.addNotes(Notes);
     return false;
   }
 
@@ -3497,8 +3500,8 @@ static bool diagnoseMutableFields(EvalInfo &Info, const Expr *E, AccessKinds AK,
 static bool lifetimeStartedInEvaluation(EvalInfo &Info,
                                         APValue::LValueBase Base,
                                         bool MutableSubobject = false) {
-  // A temporary we created.
-  if (Base.getCallIndex())
+  // A temporary or transient heap allocation we created.
+  if (Base.getCallIndex() || Base.is<DynamicAllocLValue>())
     return true;
 
   switch (Info.IsEvaluatingDecl) {
@@ -10009,6 +10012,7 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
   auto *CaptureInitIt = E->capture_init_begin();
   const LambdaCapture *CaptureIt = ClosureClass->captures_begin();
   bool Success = true;
+  const ASTRecordLayout &Layout = Info.Ctx.getASTRecordLayout(ClosureClass);
   for (const auto *Field : ClosureClass->fields()) {
     assert(CaptureInitIt != E->capture_init_end());
     // Get the initializer for this field
@@ -10019,8 +10023,13 @@ bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
     if (!CurFieldInit)
       return Error(E);
 
+    LValue Subobject = This;
+
+    if (!HandleLValueMember(Info, E, Subobject, Field, &Layout))
+      return false;
+
     APValue &FieldVal = Result.getStructField(Field->getFieldIndex());
-    if (!EvaluateInPlace(FieldVal, Info, This, CurFieldInit)) {
+    if (!EvaluateInPlace(FieldVal, Info, Subobject, CurFieldInit)) {
       if (!Info.keepEvaluatingAfterFailure())
         return false;
       Success = false;
@@ -14786,11 +14795,14 @@ bool Expr::EvaluateAsLValue(EvalResult &Result, const ASTContext &Ctx,
 
 static bool EvaluateDestruction(const ASTContext &Ctx, APValue::LValueBase Base,
                                 APValue DestroyedValue, QualType Type,
-                                SourceLocation Loc, Expr::EvalStatus &EStatus) {
-  EvalInfo Info(Ctx, EStatus, EvalInfo::EM_ConstantExpression);
+                                SourceLocation Loc, Expr::EvalStatus &EStatus,
+                                bool IsConstantDestruction) {
+  EvalInfo Info(Ctx, EStatus,
+                IsConstantDestruction ? EvalInfo::EM_ConstantExpression
+                                      : EvalInfo::EM_ConstantFold);
   Info.setEvaluatingDecl(Base, DestroyedValue,
                          EvalInfo::EvaluatingDeclKind::Dtor);
-  Info.InConstantContext = true;
+  Info.InConstantContext = IsConstantDestruction;
 
   LValue LVal;
   LVal.set(Base);
@@ -14844,7 +14856,8 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
   // If this is a class template argument, it's required to have constant
   // destruction too.
   if (Kind == ConstantExprKind::ClassTemplateArgument &&
-      (!EvaluateDestruction(Ctx, Base, Result.Val, T, getBeginLoc(), Result) ||
+      (!EvaluateDestruction(Ctx, Base, Result.Val, T, getBeginLoc(), Result,
+                            true) ||
        Result.HasSideEffects)) {
     // FIXME: Prefix a note to indicate that the problem is lack of constant
     // destruction.
@@ -14856,8 +14869,7 @@ bool Expr::EvaluateAsConstantExpr(EvalResult &Result, const ASTContext &Ctx,
 
 bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
                                  const VarDecl *VD,
-                                 SmallVectorImpl<PartialDiagnosticAt> &Notes,
-                                 bool IsConstantInitialization) const {
+                            SmallVectorImpl<PartialDiagnosticAt> &Notes) const {
   assert(!isValueDependent() &&
          "Expression evaluator can't be called on a dependent expression.");
 
@@ -14870,12 +14882,11 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
   Expr::EvalStatus EStatus;
   EStatus.Diag = &Notes;
 
-  EvalInfo Info(Ctx, EStatus,
-                (IsConstantInitialization && Ctx.getLangOpts().CPlusPlus11)
-                    ? EvalInfo::EM_ConstantExpression
-                    : EvalInfo::EM_ConstantFold);
+  EvalInfo Info(Ctx, EStatus, VD->isConstexpr()
+                                      ? EvalInfo::EM_ConstantExpression
+                                      : EvalInfo::EM_ConstantFold);
   Info.setEvaluatingDecl(VD, Value);
-  Info.InConstantContext = IsConstantInitialization;
+  Info.InConstantContext = true;
 
   SourceLocation DeclLoc = VD->getLocation();
   QualType DeclTy = VD->getType();
@@ -14910,6 +14921,10 @@ bool VarDecl::evaluateDestruction(
   Expr::EvalStatus EStatus;
   EStatus.Diag = &Notes;
 
+  // Only treat the destruction as constant destruction if we formally have
+  // constant initialization (or are usable in a constant expression).
+  bool IsConstantDestruction = hasConstantInitialization();
+
   // Make a copy of the value for the destructor to mutate, if we know it.
   // Otherwise, treat the value as default-initialized; if the destructor works
   // anyway, then the destruction is constant (and must be essentially empty).
@@ -14920,7 +14935,8 @@ bool VarDecl::evaluateDestruction(
     return false;
 
   if (!EvaluateDestruction(getASTContext(), this, std::move(DestroyedValue),
-                           getType(), getLocation(), EStatus) ||
+                           getType(), getLocation(), EStatus,
+                           IsConstantDestruction) ||
       EStatus.HasSideEffects)
     return false;
 
diff --git a/contrib/llvm-project/clang/lib/AST/ItaniumCXXABI.cpp b/contrib/llvm-project/clang/lib/AST/ItaniumCXXABI.cpp
index 069add8464ae..be10258a2d77 100644
--- a/contrib/llvm-project/clang/lib/AST/ItaniumCXXABI.cpp
+++ b/contrib/llvm-project/clang/lib/AST/ItaniumCXXABI.cpp
@@ -258,3 +258,9 @@ public:
 CXXABI *clang::CreateItaniumCXXABI(ASTContext &Ctx) {
   return new ItaniumCXXABI(Ctx);
 }
+
+std::unique_ptr<MangleNumberingContext>
+clang::createItaniumNumberingContext(MangleContext *Mangler) {
+  return std::make_unique<ItaniumNumberingContext>(
+      cast<ItaniumMangleContext>(Mangler));
+}
diff --git a/contrib/llvm-project/clang/lib/AST/ItaniumMangle.cpp b/contrib/llvm-project/clang/lib/AST/ItaniumMangle.cpp
index 6c8d5687c64a..5cad84a96845 100644
--- a/contrib/llvm-project/clang/lib/AST/ItaniumMangle.cpp
+++ b/contrib/llvm-project/clang/lib/AST/ItaniumMangle.cpp
@@ -125,6 +125,8 @@ class ItaniumMangleContextImpl : public ItaniumMangleContext {
   llvm::DenseMap<DiscriminatorKeyTy, unsigned> Discriminator;
   llvm::DenseMap<const NamedDecl*, unsigned> Uniquifier;
 
+  bool IsDevCtx = false;
+
 public:
   explicit ItaniumMangleContextImpl(ASTContext &Context,
                                     DiagnosticsEngine &Diags)
@@ -137,6 +139,10 @@ public:
   bool shouldMangleStringLiteral(const StringLiteral *) override {
     return false;
   }
+
+  bool isDeviceMangleContext() const override { return IsDevCtx; }
+  void setDeviceMangleContext(bool IsDev) override { IsDevCtx = IsDev; }
+
   void mangleCXXName(GlobalDecl GD, raw_ostream &) override;
   void mangleThunk(const CXXMethodDecl *MD, const ThunkInfo &Thunk,
                    raw_ostream &) override;
@@ -546,8 +552,8 @@ private:
                         unsigned knownArity);
   void mangleCastExpression(const Expr *E, StringRef CastEncoding);
   void mangleInitListElements(const InitListExpr *InitList);
-  void mangleDeclRefExpr(const NamedDecl *D);
-  void mangleExpression(const Expr *E, unsigned Arity = UnknownArity);
+  void mangleExpression(const Expr *E, unsigned Arity = UnknownArity,
+                        bool AsTemplateArg = false);
   void mangleCXXCtorType(CXXCtorType T, const CXXRecordDecl *InheritedFrom);
   void mangleCXXDtorType(CXXDtorType T);
 
@@ -558,6 +564,7 @@ private:
                           unsigned NumTemplateArgs);
   void mangleTemplateArgs(TemplateName TN, const TemplateArgumentList &AL);
   void mangleTemplateArg(TemplateArgument A, bool NeedExactType);
+  void mangleTemplateArgExpr(const Expr *E);
   void mangleValueInTemplateArg(QualType T, const APValue &V, bool TopLevel,
                                 bool NeedExactType = false);
 
@@ -726,9 +733,17 @@ void CXXNameMangler::mangleFunctionEncodingBareType(const FunctionDecl *FD) {
       EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
       if (!EIA)
         continue;
-      Out << 'X';
-      mangleExpression(EIA->getCond());
-      Out << 'E';
+      if (Context.getASTContext().getLangOpts().getClangABICompat() >
+          LangOptions::ClangABI::Ver11) {
+        mangleTemplateArgExpr(EIA->getCond());
+      } else {
+        // Prior to Clang 12, we hardcoded the X/E around enable-if's argument,
+        // even though <template-arg> should not include an X/E around
+        // <expr-primary>.
+        Out << 'X';
+        mangleExpression(EIA->getCond());
+        Out << 'E';
+      }
     }
     Out << 'E';
     FunctionTypeDepth.pop(Saved);
@@ -1837,7 +1852,15 @@ void CXXNameMangler::mangleLambda(const CXXRecordDecl *Lambda) {
   // (in lexical order) with that same <lambda-sig> and context.
   //
   // The AST keeps track of the number for us.
-  unsigned Number = Lambda->getLambdaManglingNumber();
+  //
+  // In CUDA/HIP, to ensure the consistent lamba numbering between the device-
+  // and host-side compilations, an extra device mangle context may be created
+  // if the host-side CXX ABI has different numbering for lambda. In such case,
+  // if the mangle context is that device-side one, use the device-side lambda
+  // mangling number for this lambda.
+  unsigned Number = Context.isDeviceMangleContext()
+                        ? Lambda->getDeviceLambdaManglingNumber()
+                        : Lambda->getLambdaManglingNumber();
   assert(Number > 0 && "Lambda should be mangled as an unnamed class");
   if (Number > 1)
     mangleNumber(Number - 2);
@@ -3528,8 +3551,8 @@ void CXXNameMangler::mangleType(const DependentSizedMatrixType *T) {
   Out << "u" << VendorQualifier.size() << VendorQualifier;
 
   Out << "I";
-  mangleTemplateArg(T->getRowExpr(), false);
-  mangleTemplateArg(T->getColumnExpr(), false);
+  mangleTemplateArgExpr(T->getRowExpr());
+  mangleTemplateArgExpr(T->getColumnExpr());
   mangleType(T->getElementType());
   Out << "E";
 }
@@ -3871,33 +3894,8 @@ void CXXNameMangler::mangleInitListElements(const InitListExpr *InitList) {
     mangleExpression(InitList->getInit(i));
 }
 
-void CXXNameMangler::mangleDeclRefExpr(const NamedDecl *D) {
-  switch (D->getKind()) {
-  default:
-    //  <expr-primary> ::= L <mangled-name> E # external name
-    Out << 'L';
-    mangle(D);
-    Out << 'E';
-    break;
-
-  case Decl::ParmVar:
-    mangleFunctionParam(cast<ParmVarDecl>(D));
-    break;
-
-  case Decl::EnumConstant: {
-    const EnumConstantDecl *ED = cast<EnumConstantDecl>(D);
-    mangleIntegerLiteral(ED->getType(), ED->getInitVal());
-    break;
-  }
-
-  case Decl::NonTypeTemplateParm:
-    const NonTypeTemplateParmDecl *PD = cast<NonTypeTemplateParmDecl>(D);
-    mangleTemplateParameter(PD->getDepth(), PD->getIndex());
-    break;
-  }
-}
-
-void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) {
+void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity,
+                                      bool AsTemplateArg) {
   // <expression> ::= <unary operator-name> <expression>
   //              ::= <binary operator-name> <expression> <expression>
   //              ::= <trinary operator-name> <expression> <expression> <expression>
@@ -3911,18 +3909,64 @@ void CXXNameMangler::mangleExpression(const Expr *E, unsigned Arity) {
   //              ::= at <type>                      # alignof (a type)
   //              ::= <template-param>
   //              ::= <function-param>
+  //              ::= fpT                            # 'this' expression (part of <function-param>)
   //              ::= sr <type> <unqualified-name>                   # dependent name
   //              ::= sr <type> <unqualified-name> <template-args>   # dependent template-id
   //              ::= ds <expression> <expression>                   # expr.*expr
   //              ::= sZ <template-param>                            # size of a parameter pack
   //              ::= sZ <function-param>    # size of a function parameter pack
+  //              ::= u <source-name> <template-arg>* E # vendor extended expression
   //              ::= <expr-primary>
   // <expr-primary> ::= L <type> <value number> E    # integer literal
-  //                ::= L <type <value float> E      # floating literal
+  //                ::= L <type> <value float> E     # floating literal
+  //                ::= L <type> <string type> E     # string literal
+  //                ::= L <nullptr type> E           # nullptr literal "LDnE"
+  //                ::= L <pointer type> 0 E         # null pointer template argument
+  //                ::= L <type> <real-part float> _ <imag-part float> E    # complex floating point literal (C99); not used by clang
*** 21874 LINES SKIPPED ***



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202112251155.1BPBtRBf006288>