git: a2e927433f9d - stable/13 - Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d

From: Dimitry Andric <dim_at_FreeBSD.org>
Date: Sun, 09 Apr 2023 21:35:17 UTC
The branch stable/13 has been updated by dim:

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

commit a2e927433f9d66b477247c4d36da79c008cfa8a4
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2022-08-13 15:37:04 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-04-09 14:54:49 +0000

    Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d
    
    This updates llvm, clang, compiler-rt, libc++, libunwind, lld, lldb and
    openmp to llvmorg-15.0.0-rc2-40-gfbd2950d8d0d.
    
    PR:             265425
    MFC after:      2 weeks
    
    (cherry picked from commit 61cfbce3347e4372143bcabf7b197577b9f3958a)
---
 .../clang/include/clang/AST/DeclTemplate.h         |   8 +-
 .../clang/include/clang/Basic/Module.h             |   5 +
 .../llvm-project/clang/include/clang/Sema/Sema.h   |   2 +
 .../clang/include/clang/Serialization/ASTReader.h  |   3 +-
 contrib/llvm-project/clang/lib/AST/APValue.cpp     |   8 +-
 .../llvm-project/clang/lib/Basic/Targets/X86.cpp   |   2 +
 contrib/llvm-project/clang/lib/Basic/Targets/X86.h |   4 +
 .../llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp   |   8 +-
 contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp  |  15 +
 .../clang/lib/CodeGen/CodeGenModule.cpp            |  10 +-
 .../llvm-project/clang/lib/CodeGen/TargetInfo.cpp  |  13 +-
 .../clang/lib/Driver/ToolChains/Arch/Sparc.cpp     |  25 +
 .../clang/lib/Driver/ToolChains/Arch/Sparc.h       |   3 +
 .../clang/lib/Driver/ToolChains/Clang.cpp          |  21 +-
 .../clang/lib/Driver/ToolChains/CommonArgs.cpp     |  11 +-
 .../clang/lib/Driver/ToolChains/Gnu.cpp            |  10 +
 .../clang/lib/Frontend/FrontendAction.cpp          |   2 +-
 contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp   |  76 ++-
 .../llvm-project/clang/lib/Sema/SemaOverload.cpp   |   5 +-
 .../llvm-project/clang/lib/Sema/SemaTemplate.cpp   |   8 +-
 .../clang/lib/Serialization/ASTReader.cpp          |  89 ++--
 .../compiler-rt/lib/builtins/fp_trunc.h            |   2 +-
 .../compiler-rt/lib/builtins/int_types.h           |   2 +-
 .../lib/sanitizer_common/sanitizer_platform.h      |   2 +-
 .../libcxx/include/__algorithm/adjacent_find.h     |  32 +-
 .../libcxx/include/__algorithm/clamp.h             |   4 +-
 .../llvm-project/libcxx/include/__algorithm/copy.h |  10 +-
 .../libcxx/include/__algorithm/copy_backward.h     |   6 +-
 .../llvm-project/libcxx/include/__algorithm/fill.h |   2 +
 .../libcxx/include/__algorithm/fill_n.h            |   2 +
 .../libcxx/include/__algorithm/find_first_of.h     |   3 +-
 .../libcxx/include/__algorithm/inplace_merge.h     |  91 ++--
 .../libcxx/include/__algorithm/is_permutation.h    | 259 ++++++----
 .../include/__algorithm/iterator_operations.h      |  83 ++-
 .../libcxx/include/__algorithm/make_heap.h         |   4 +-
 .../libcxx/include/__algorithm/make_projected.h    |  98 ++--
 .../llvm-project/libcxx/include/__algorithm/move.h |  26 +-
 .../libcxx/include/__algorithm/move_backward.h     |  38 +-
 .../libcxx/include/__algorithm/next_permutation.h  |  36 +-
 .../libcxx/include/__algorithm/partial_sort.h      |  10 +-
 .../libcxx/include/__algorithm/partial_sort_copy.h |  42 +-
 .../libcxx/include/__algorithm/pop_heap.h          |   4 +-
 .../libcxx/include/__algorithm/prev_permutation.h  |  36 +-
 .../libcxx/include/__algorithm/push_heap.h         |   2 +-
 .../libcxx/include/__algorithm/ranges_clamp.h      |  65 +++
 .../include/__algorithm/ranges_inplace_merge.h     |  52 +-
 .../libcxx/include/__algorithm/ranges_is_heap.h    |   2 +-
 .../include/__algorithm/ranges_is_heap_until.h     |   2 +-
 .../include/__algorithm/ranges_is_permutation.h    |  89 ++++
 .../libcxx/include/__algorithm/ranges_make_heap.h  |   2 +-
 .../libcxx/include/__algorithm/ranges_move.h       |  15 +-
 .../include/__algorithm/ranges_move_backward.h     |   5 +-
 .../include/__algorithm/ranges_next_permutation.h  |  72 +++
 .../include/__algorithm/ranges_nth_element.h       |   2 +-
 .../include/__algorithm/ranges_partial_sort.h      |   2 +-
 .../include/__algorithm/ranges_partial_sort_copy.h |  19 +-
 .../libcxx/include/__algorithm/ranges_partition.h  |   2 +-
 .../libcxx/include/__algorithm/ranges_pop_heap.h   |   2 +-
 .../include/__algorithm/ranges_prev_permutation.h  |  76 +++
 .../libcxx/include/__algorithm/ranges_push_heap.h  |   2 +-
 .../include/__algorithm/ranges_remove_copy.h       |  55 +-
 .../include/__algorithm/ranges_remove_copy_if.h    |  58 ++-
 .../include/__algorithm/ranges_replace_copy.h      |  69 +--
 .../include/__algorithm/ranges_replace_copy_if.h   |  72 +--
 .../libcxx/include/__algorithm/ranges_rotate.h     |  71 +++
 .../libcxx/include/__algorithm/ranges_sample.h     |  74 +++
 .../libcxx/include/__algorithm/ranges_shuffle.h    |  34 +-
 .../libcxx/include/__algorithm/ranges_sort.h       |   2 +-
 .../libcxx/include/__algorithm/ranges_sort_heap.h  |   2 +-
 .../include/__algorithm/ranges_stable_partition.h  |   2 +-
 .../include/__algorithm/ranges_stable_sort.h       |   2 +-
 .../include/__algorithm/ranges_swap_ranges.h       |  11 +-
 .../libcxx/include/__algorithm/ranges_unique.h     |  46 +-
 .../include/__algorithm/ranges_unique_copy.h       |  73 ++-
 .../libcxx/include/__algorithm/reverse.h           |  23 +-
 .../libcxx/include/__algorithm/rotate.h            |  57 ++-
 .../libcxx/include/__algorithm/sample.h            |  48 +-
 .../libcxx/include/__algorithm/sift_down.h         |   4 +-
 .../libcxx/include/__algorithm/sort_heap.h         |   4 +-
 .../libcxx/include/__algorithm/stable_partition.h  |   4 +-
 .../libcxx/include/__algorithm/stable_sort.h       |   2 +-
 .../libcxx/include/__algorithm/swap_ranges.h       |  37 +-
 .../uniform_random_bit_generator_adaptor.h         |  62 +++
 .../libcxx/include/__algorithm/unique.h            |  48 +-
 .../libcxx/include/__algorithm/unique_copy.h       | 147 +++---
 .../libcxx/include/__algorithm/unwrap_range.h      |  97 ++++
 contrib/llvm-project/libcxx/include/__assert       |  11 +-
 contrib/llvm-project/libcxx/include/__availability |  41 +-
 .../llvm-project/libcxx/include/__bit_reference    | 243 +++++----
 .../include/__iterator/incrementable_traits.h      |   1 +
 .../libcxx/include/__iterator/iterator_traits.h    |   7 +
 .../libcxx/include/__iterator/reverse_iterator.h   |  14 +-
 .../libcxx/include/__memory/construct_at.h         |   3 +-
 .../libcxx/include/__memory/pointer_traits.h       |  28 +-
 .../include/__memory/uninitialized_algorithms.h    |   7 +-
 .../llvm-project/libcxx/include/__ranges/size.h    |   1 +
 contrib/llvm-project/libcxx/include/__split_buffer | 134 +++--
 .../llvm-project/libcxx/include/__verbose_abort    |  51 ++
 contrib/llvm-project/libcxx/include/algorithm      | 219 +++++++-
 contrib/llvm-project/libcxx/include/format         | 101 ++--
 contrib/llvm-project/libcxx/include/memory         |  26 +-
 .../libcxx/include/module.modulemap.in             |  16 +-
 contrib/llvm-project/libcxx/include/vector         | 557 ++++++++++++---------
 contrib/llvm-project/libcxx/include/version        |   8 +-
 .../libcxx/src/include/sso_allocator.h             |   5 +
 .../libcxx/src/{assert.cpp => verbose_abort.cpp}   |  22 +-
 contrib/llvm-project/lld/COFF/Driver.cpp           |  17 +-
 contrib/llvm-project/lld/COFF/Driver.h             |   4 +-
 contrib/llvm-project/lld/COFF/DriverUtils.cpp      |   3 +
 contrib/llvm-project/lld/COFF/MinGW.cpp            |  10 +-
 contrib/llvm-project/lld/COFF/MinGW.h              |   6 +-
 contrib/llvm-project/lld/COFF/Options.td           |   2 +
 contrib/llvm-project/lld/COFF/PDB.cpp              |   4 +
 contrib/llvm-project/lld/ELF/Arch/AArch64.cpp      |   4 +-
 contrib/llvm-project/lld/ELF/Config.h              |   1 +
 contrib/llvm-project/lld/ELF/Driver.cpp            |   6 +-
 contrib/llvm-project/lld/ELF/Options.td            |   2 +
 contrib/llvm-project/lld/ELF/Relocations.cpp       |   3 +-
 contrib/llvm-project/lld/ELF/SyntheticSections.cpp |  17 +
 contrib/llvm-project/lld/ELF/SyntheticSections.h   |  10 +
 contrib/llvm-project/lld/ELF/Writer.cpp            |   5 +
 contrib/llvm-project/lld/MachO/Arch/ARM64.cpp      |   2 +-
 contrib/llvm-project/lld/MachO/DriverUtils.cpp     |   2 +-
 contrib/llvm-project/lld/MachO/EhFrame.cpp         |  10 +-
 contrib/llvm-project/lld/MachO/EhFrame.h           |   8 +-
 contrib/llvm-project/lld/MachO/InputFiles.cpp      | 118 ++++-
 contrib/llvm-project/lld/MachO/InputFiles.h        |  17 +-
 .../llvm-project/lld/MachO/UnwindInfoSection.cpp   |   8 +-
 contrib/llvm-project/lld/MachO/Writer.cpp          | 122 ++---
 contrib/llvm-project/lld/docs/ReleaseNotes.rst     | 144 +++++-
 .../llvm-project/lldb/source/Core/Disassembler.cpp |   1 +
 .../include/llvm/Analysis/TargetTransformInfo.h    |   9 +
 .../llvm/Analysis/TargetTransformInfoImpl.h        |   2 +
 .../llvm/include/llvm/BinaryFormat/ELF.h           |   1 +
 .../llvm/include/llvm/CodeGen/ISDOpcodes.h         |   5 +
 .../include/llvm/DebugInfo/CodeView/CodeView.h     |   3 +
 .../ExecutorSharedMemoryMapperService.h            |   3 +
 .../Orc/TargetProcess/JITLoaderGDB.h               |   3 +
 contrib/llvm-project/llvm/include/llvm/IR/Type.h   |   5 +
 .../llvm/include/llvm/Support/ErrorHandling.h      |   6 +-
 .../llvm-project/llvm/include/llvm/Support/Host.h  |   1 +
 .../llvm/lib/Analysis/ConstantFolding.cpp          |   4 +-
 .../llvm/lib/Analysis/TargetTransformInfo.cpp      |   4 +
 .../llvm/lib/CodeGen/MachineScheduler.cpp          |   2 +-
 .../llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp  |  45 +-
 .../llvm/lib/DebugInfo/PDB/Native/FormatUtil.cpp   |   7 +
 .../IntelJITEvents/IntelJITEventListener.cpp       |   1 +
 .../llvm/lib/ExecutionEngine/Orc/MemoryMapper.cpp  |  22 +-
 .../ExecutorSharedMemoryMapperService.cpp          |   7 +-
 contrib/llvm-project/llvm/lib/Support/Host.cpp     | 108 ++++
 .../lib/Target/AArch64/AArch64ISelLowering.cpp     |  47 +-
 .../Target/AArch64/AArch64TargetTransformInfo.h    |   4 +
 .../Target/AArch64/GISel/AArch64LegalizerInfo.cpp  |   2 +-
 contrib/llvm-project/llvm/lib/Target/ARM/ARM.td    |   9 +
 .../llvm/lib/Target/ARM/ARMISelLowering.cpp        |   3 +-
 .../llvm/lib/Target/PowerPC/PPCFastISel.cpp        |   5 +-
 .../llvm/lib/Target/RISCV/RISCVISelLowering.cpp    |   8 +-
 .../llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp   |  25 +-
 .../llvm/lib/Target/X86/X86ISelLowering.cpp        |  96 ++--
 .../llvm/lib/Target/X86/X86ISelLowering.h          |  12 +
 .../lib/Transforms/IPO/AttributorAttributes.cpp    |  13 +-
 .../llvm/lib/Transforms/IPO/OpenMPOpt.cpp          |  12 +
 .../Transforms/Utils/RelLookupTableConverter.cpp   |   8 +-
 .../lib/Transforms/Vectorize/LoopVectorize.cpp     |  15 +-
 contrib/llvm-project/llvm/tools/lli/lli.cpp        |   3 +-
 .../llvm-project/llvm/tools/llvm-ar/llvm-ar.cpp    |  33 +-
 .../openmp/runtime/src/kmp_dispatch.cpp            |   2 +-
 lib/clang/include/VCSVersion.inc                   |   6 +-
 lib/clang/include/lld/Common/Version.inc           |   2 +-
 lib/clang/include/llvm/Support/VCSRevision.h       |   2 +-
 lib/clang/libllvm/Makefile                         |   4 +-
 lib/libc++/Makefile                                |  11 +-
 sys/conf/kern.mk                                   |  10 +-
 173 files changed, 3754 insertions(+), 1472 deletions(-)

diff --git a/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h b/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h
index 725bb0bced9c..baed5ca22fa7 100755
--- a/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h
+++ b/contrib/llvm-project/clang/include/clang/AST/DeclTemplate.h
@@ -3287,8 +3287,12 @@ public:
     return isa<TemplateTypeParmDecl>(getTemplateParameters()->getParam(0));
   }
 
-  ConceptDecl *getCanonicalDecl() override { return getFirstDecl(); }
-  const ConceptDecl *getCanonicalDecl() const { return getFirstDecl(); }
+  ConceptDecl *getCanonicalDecl() override {
+    return cast<ConceptDecl>(getPrimaryMergedDecl(this));
+  }
+  const ConceptDecl *getCanonicalDecl() const {
+    return const_cast<ConceptDecl *>(this)->getCanonicalDecl();
+  }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return classofKind(D->getKind()); }
diff --git a/contrib/llvm-project/clang/include/clang/Basic/Module.h b/contrib/llvm-project/clang/include/clang/Basic/Module.h
index 47d736a3b455..8ef1c5991c56 100644
--- a/contrib/llvm-project/clang/include/clang/Basic/Module.h
+++ b/contrib/llvm-project/clang/include/clang/Basic/Module.h
@@ -525,6 +525,11 @@ public:
     Parent->SubModules.push_back(this);
   }
 
+  /// Is this module have similar semantics as headers.
+  bool isHeaderLikeModule() const {
+    return isModuleMapModule() || isHeaderUnit();
+  }
+
   /// Is this a module partition.
   bool isModulePartition() const {
     return Kind == ModulePartitionInterface ||
diff --git a/contrib/llvm-project/clang/include/clang/Sema/Sema.h b/contrib/llvm-project/clang/include/clang/Sema/Sema.h
index 06ea0b417cb3..681a76dfa56a 100644
--- a/contrib/llvm-project/clang/include/clang/Sema/Sema.h
+++ b/contrib/llvm-project/clang/include/clang/Sema/Sema.h
@@ -4479,6 +4479,8 @@ public:
   bool CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old);
   bool CheckRedeclarationExported(NamedDecl *New, NamedDecl *Old);
   bool CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old);
+  bool IsRedefinitionInModule(const NamedDecl *New,
+                                 const NamedDecl *Old) const;
 
   void DiagnoseAmbiguousLookup(LookupResult &Result);
   //@}
diff --git a/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h b/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
index cc4ced02876e..dee2744516d5 100644
--- a/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
+++ b/contrib/llvm-project/clang/include/clang/Serialization/ASTReader.h
@@ -1738,7 +1738,8 @@ public:
                                   const LangOptions &LangOpts,
                                   const TargetOptions &TargetOpts,
                                   const PreprocessorOptions &PPOpts,
-                                  StringRef ExistingModuleCachePath);
+                                  StringRef ExistingModuleCachePath,
+                                  bool RequireStrictOptionMatches = false);
 
   /// Returns the suggested contents of the predefines buffer,
   /// which contains a (typically-empty) subset of the predefines
diff --git a/contrib/llvm-project/clang/lib/AST/APValue.cpp b/contrib/llvm-project/clang/lib/AST/APValue.cpp
index a22031142c7c..d522c87388a5 100644
--- a/contrib/llvm-project/clang/lib/AST/APValue.cpp
+++ b/contrib/llvm-project/clang/lib/AST/APValue.cpp
@@ -637,10 +637,10 @@ static bool TryPrintAsStringLiteral(raw_ostream &Out,
     return false;
 
   // Nothing we can do about a sequence that is not null-terminated
-  if (!Inits.back().getInt().isZero())
+  if (!Inits.back().isInt() || !Inits.back().getInt().isZero())
     return false;
-  else
-    Inits = Inits.drop_back();
+
+  Inits = Inits.drop_back();
 
   llvm::SmallString<40> Buf;
   Buf.push_back('"');
@@ -655,6 +655,8 @@ static bool TryPrintAsStringLiteral(raw_ostream &Out,
   }
 
   for (auto &Val : Inits) {
+    if (!Val.isInt())
+      return false;
     int64_t Char64 = Val.getInt().getExtValue();
     if (!isASCII(Char64))
       return false; // Bye bye, see you in integers.
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp b/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
index 69afdf8a3584..0f5c366816df 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/X86.cpp
@@ -358,6 +358,8 @@ bool X86TargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
 
     HasFloat16 = SSELevel >= SSE2;
 
+    HasBFloat16 = SSELevel >= SSE2;
+
     MMX3DNowEnum ThreeDNowLevel = llvm::StringSwitch<MMX3DNowEnum>(Feature)
                                       .Case("+3dnowa", AMD3DNowAthlon)
                                       .Case("+3dnow", AMD3DNow)
diff --git a/contrib/llvm-project/clang/lib/Basic/Targets/X86.h b/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
index 224145f4b020..136047a5055c 100644
--- a/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
+++ b/contrib/llvm-project/clang/lib/Basic/Targets/X86.h
@@ -156,6 +156,8 @@ protected:
 public:
   X86TargetInfo(const llvm::Triple &Triple, const TargetOptions &)
       : TargetInfo(Triple) {
+    BFloat16Width = BFloat16Align = 16;
+    BFloat16Format = &llvm::APFloat::BFloat();
     LongDoubleFormat = &llvm::APFloat::x87DoubleExtended();
     AddrSpaceMap = &X86AddrSpaceMap;
     HasStrictFP = true;
@@ -400,6 +402,8 @@ public:
   uint64_t getPointerAlignV(unsigned AddrSpace) const override {
     return getPointerWidthV(AddrSpace);
   }
+
+  const char *getBFloat16Mangling() const override { return "u6__bf16"; };
 };
 
 // X86-32 generic target
diff --git a/contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp b/contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp
index 949112c63cc9..6915f950b6ce 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/CGDeclCXX.cpp
@@ -649,8 +649,8 @@ void CodeGenModule::EmitCXXModuleInitFunc(Module *Primary) {
 
   SmallVector<llvm::Function *, 8> ModuleInits;
   for (Module *M : AllImports) {
-    // No Itanium initializer in module map modules.
-    if (M->isModuleMapModule())
+    // No Itanium initializer in header like modules.
+    if (M->isHeaderLikeModule())
       continue; // TODO: warn of mixed use of module map modules and C++20?
     llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
     SmallString<256> FnName;
@@ -778,8 +778,8 @@ CodeGenModule::EmitCXXGlobalInitFunc() {
   SmallVector<llvm::Function *, 8> ModuleInits;
   if (CXX20ModuleInits)
     for (Module *M : ImportedModules) {
-      // No Itanium initializer in module map modules.
-      if (M->isModuleMapModule())
+      // No Itanium initializer in header like modules.
+      if (M->isHeaderLikeModule())
         continue;
       llvm::FunctionType *FTy = llvm::FunctionType::get(VoidTy, false);
       SmallString<256> FnName;
diff --git a/contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp b/contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp
index 05ab16668743..481438de0e53 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/CGStmt.cpp
@@ -2343,6 +2343,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
   std::vector<llvm::Type *> ArgElemTypes;
   std::vector<llvm::Value*> Args;
   llvm::BitVector ResultTypeRequiresCast;
+  llvm::BitVector ResultRegIsFlagReg;
 
   // Keep track of inout constraints.
   std::string InOutConstraints;
@@ -2400,6 +2401,9 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
       ResultRegQualTys.push_back(QTy);
       ResultRegDests.push_back(Dest);
 
+      bool IsFlagReg = llvm::StringRef(OutputConstraint).startswith("{@cc");
+      ResultRegIsFlagReg.push_back(IsFlagReg);
+
       llvm::Type *Ty = ConvertTypeForMem(QTy);
       const bool RequiresCast = Info.allowsRegister() &&
           (getTargetHooks().isScalarizableAsmOperand(*this, Ty) ||
@@ -2717,10 +2721,21 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
   // ResultRegDests can be also populated by addReturnRegisterOutputs() above,
   // in which case its size may grow.
   assert(ResultTypeRequiresCast.size() <= ResultRegDests.size());
+  assert(ResultRegIsFlagReg.size() <= ResultRegDests.size());
   for (unsigned i = 0, e = RegResults.size(); i != e; ++i) {
     llvm::Value *Tmp = RegResults[i];
     llvm::Type *TruncTy = ResultTruncRegTypes[i];
 
+    if ((i < ResultRegIsFlagReg.size()) && ResultRegIsFlagReg[i]) {
+      // Target must guarantee the Value `Tmp` here is lowered to a boolean
+      // value.
+      llvm::Constant *Two = llvm::ConstantInt::get(Tmp->getType(), 2);
+      llvm::Value *IsBooleanValue =
+          Builder.CreateCmp(llvm::CmpInst::ICMP_ULT, Tmp, Two);
+      llvm::Function *FnAssume = CGM.getIntrinsic(llvm::Intrinsic::assume);
+      Builder.CreateCall(FnAssume, IsBooleanValue);
+    }
+
     // If the result type of the LLVM IR asm doesn't match the result type of
     // the expression, do the conversion.
     if (ResultRegTypes[i] != ResultTruncRegTypes[i]) {
diff --git a/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp b/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
index 4e8e120d89df..d87692face2a 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/CodeGenModule.cpp
@@ -521,7 +521,7 @@ static void setVisibilityFromDLLStorageClass(const clang::LangOptions &LO,
 
 void CodeGenModule::Release() {
   Module *Primary = getContext().getModuleForCodeGen();
-  if (CXX20ModuleInits && Primary && !Primary->isModuleMapModule())
+  if (CXX20ModuleInits && Primary && !Primary->isHeaderLikeModule())
     EmitModuleInitializers(Primary);
   EmitDeferred();
   DeferredDecls.insert(EmittedDeferredDecls.begin(),
@@ -2521,21 +2521,23 @@ void CodeGenModule::EmitModuleInitializers(clang::Module *Primary) {
   // source, first Global Module Fragments, if present.
   if (auto GMF = Primary->getGlobalModuleFragment()) {
     for (Decl *D : getContext().getModuleInitializers(GMF)) {
-      assert(D->getKind() == Decl::Var && "GMF initializer decl is not a var?");
+      if (isa<ImportDecl>(D))
+        continue;
+      assert(isa<VarDecl>(D) && "GMF initializer decl is not a var?");
       EmitTopLevelDecl(D);
     }
   }
   // Second any associated with the module, itself.
   for (Decl *D : getContext().getModuleInitializers(Primary)) {
     // Skip import decls, the inits for those are called explicitly.
-    if (D->getKind() == Decl::Import)
+    if (isa<ImportDecl>(D))
       continue;
     EmitTopLevelDecl(D);
   }
   // Third any associated with the Privat eMOdule Fragment, if present.
   if (auto PMF = Primary->getPrivateModuleFragment()) {
     for (Decl *D : getContext().getModuleInitializers(PMF)) {
-      assert(D->getKind() == Decl::Var && "PMF initializer decl is not a var?");
+      assert(isa<VarDecl>(D) && "PMF initializer decl is not a var?");
       EmitTopLevelDecl(D);
     }
   }
diff --git a/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp b/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp
index d1ee61eab9d6..195ad8cdc13e 100644
--- a/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp
+++ b/contrib/llvm-project/clang/lib/CodeGen/TargetInfo.cpp
@@ -2871,7 +2871,7 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo,
     } else if (k >= BuiltinType::Bool && k <= BuiltinType::LongLong) {
       Current = Integer;
     } else if (k == BuiltinType::Float || k == BuiltinType::Double ||
-               k == BuiltinType::Float16) {
+               k == BuiltinType::Float16 || k == BuiltinType::BFloat16) {
       Current = SSE;
     } else if (k == BuiltinType::LongDouble) {
       const llvm::fltSemantics *LDF = &getTarget().getLongDoubleFormat();
@@ -3002,7 +3002,8 @@ void X86_64ABIInfo::classify(QualType Ty, uint64_t OffsetBase, Class &Lo,
         Current = Integer;
       else if (Size <= 128)
         Lo = Hi = Integer;
-    } else if (ET->isFloat16Type() || ET == getContext().FloatTy) {
+    } else if (ET->isFloat16Type() || ET == getContext().FloatTy ||
+               ET->isBFloat16Type()) {
       Current = SSE;
     } else if (ET == getContext().DoubleTy) {
       Lo = Hi = SSE;
@@ -3474,9 +3475,9 @@ GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
   if (SourceSize > T0Size)
       T1 = getFPTypeAtOffset(IRType, IROffset + T0Size, TD);
   if (T1 == nullptr) {
-    // Check if IRType is a half + float. float type will be in IROffset+4 due
+    // Check if IRType is a half/bfloat + float. float type will be in IROffset+4 due
     // to its alignment.
-    if (T0->isHalfTy() && SourceSize > 4)
+    if (T0->is16bitFPTy() && SourceSize > 4)
       T1 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
     // If we can't get a second FP type, return a simple half or float.
     // avx512fp16-abi.c:pr51813_2 shows it works to return float for
@@ -3488,7 +3489,7 @@ GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
   if (T0->isFloatTy() && T1->isFloatTy())
     return llvm::FixedVectorType::get(T0, 2);
 
-  if (T0->isHalfTy() && T1->isHalfTy()) {
+  if (T0->is16bitFPTy() && T1->is16bitFPTy()) {
     llvm::Type *T2 = nullptr;
     if (SourceSize > 4)
       T2 = getFPTypeAtOffset(IRType, IROffset + 4, TD);
@@ -3497,7 +3498,7 @@ GetSSETypeAtOffset(llvm::Type *IRType, unsigned IROffset,
     return llvm::FixedVectorType::get(T0, 4);
   }
 
-  if (T0->isHalfTy() || T1->isHalfTy())
+  if (T0->is16bitFPTy() || T1->is16bitFPTy())
     return llvm::FixedVectorType::get(llvm::Type::getHalfTy(getVMContext()), 4);
 
   return llvm::Type::getDoubleTy(getVMContext());
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
index 70ba8eb2a7d0..2c9d65e7714a 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.cpp
@@ -12,6 +12,7 @@
 #include "clang/Driver/Options.h"
 #include "llvm/ADT/StringSwitch.h"
 #include "llvm/Option/ArgList.h"
+#include "llvm/Support/Host.h"
 
 using namespace clang::driver;
 using namespace clang::driver::tools;
@@ -113,6 +114,30 @@ sparc::FloatABI sparc::getSparcFloatABI(const Driver &D,
   return ABI;
 }
 
+std::string sparc::getSparcTargetCPU(const Driver &D, const ArgList &Args,
+                                     const llvm::Triple &Triple) {
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_march_EQ)) {
+    D.Diag(diag::err_drv_unsupported_opt_for_target)
+        << A->getSpelling() << Triple.getTriple();
+    return "";
+  }
+
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mcpu_EQ)) {
+    StringRef CPUName = A->getValue();
+    if (CPUName == "native") {
+      std::string CPU = std::string(llvm::sys::getHostCPUName());
+      if (!CPU.empty() && CPU != "generic")
+        return CPU;
+      return "";
+    }
+    return std::string(CPUName);
+  }
+
+  if (Triple.getArch() == llvm::Triple::sparc && Triple.isOSSolaris())
+    return "v9";
+  return "";
+}
+
 void sparc::getSparcTargetFeatures(const Driver &D, const ArgList &Args,
                                    std::vector<StringRef> &Features) {
   sparc::FloatABI FloatABI = sparc::getSparcFloatABI(D, Args);
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h
index d12a9a70e264..44658c4259c6 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Arch/Sparc.h
@@ -28,6 +28,9 @@ enum class FloatABI {
 
 FloatABI getSparcFloatABI(const Driver &D, const llvm::opt::ArgList &Args);
 
+std::string getSparcTargetCPU(const Driver &D, const llvm::opt::ArgList &Args,
+                              const llvm::Triple &Triple);
+
 void getSparcTargetFeatures(const Driver &D, const llvm::opt::ArgList &Args,
                             std::vector<llvm::StringRef> &Features);
 const char *getSparcAsmModeForCPU(llvm::StringRef Name,
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
index b62a025c5072..3704ed858668 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Clang.cpp
@@ -2205,6 +2205,18 @@ void Clang::AddSparcTargetArgs(const ArgList &Args,
     CmdArgs.push_back("-mfloat-abi");
     CmdArgs.push_back("hard");
   }
+
+  if (const Arg *A = Args.getLastArg(clang::driver::options::OPT_mtune_EQ)) {
+    StringRef Name = A->getValue();
+    std::string TuneCPU;
+    if (Name == "native")
+      TuneCPU = std::string(llvm::sys::getHostCPUName());
+    else
+      TuneCPU = std::string(Name);
+
+    CmdArgs.push_back("-tune-cpu");
+    CmdArgs.push_back(Args.MakeArgString(TuneCPU));
+  }
 }
 
 void Clang::AddSystemZTargetArgs(const ArgList &Args,
@@ -4610,8 +4622,13 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   TC.addClangWarningOptions(CmdArgs);
 
   // FIXME: Subclass ToolChain for SPIR and move this to addClangWarningOptions.
-  if (Triple.isSPIR() || Triple.isSPIRV())
+  if (Triple.isSPIR() || Triple.isSPIRV()) {
     CmdArgs.push_back("-Wspir-compat");
+    // SPIR-V support still needs pointer types in some cases as recovering
+    // type from pointer uses is not always possible e.g. for extern functions
+    // (see PR56660).
+    CmdArgs.push_back("-no-opaque-pointers");
+  }
 
   // Select the appropriate action.
   RewriteKind rewriteKind = RK_None;
@@ -6576,7 +6593,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   // support by default, or just assume that all languages do.
   bool HaveModules =
       Std && (Std->containsValue("c++2a") || Std->containsValue("c++20") ||
-              Std->containsValue("c++latest"));
+              Std->containsValue("c++2b") || Std->containsValue("c++latest"));
   RenderModulesOptions(C, D, Args, Input, Output, CmdArgs, HaveModules);
 
   if (Args.hasFlag(options::OPT_fpch_validate_input_files_content,
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 1d2c085d683e..443725f7d8a8 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -12,6 +12,7 @@
 #include "Arch/M68k.h"
 #include "Arch/Mips.h"
 #include "Arch/PPC.h"
+#include "Arch/Sparc.h"
 #include "Arch/SystemZ.h"
 #include "Arch/VE.h"
 #include "Arch/X86.h"
@@ -431,15 +432,15 @@ std::string tools::getCPUName(const Driver &D, const ArgList &Args,
 
   case llvm::Triple::bpfel:
   case llvm::Triple::bpfeb:
-  case llvm::Triple::sparc:
-  case llvm::Triple::sparcel:
-  case llvm::Triple::sparcv9:
     if (const Arg *A = Args.getLastArg(options::OPT_mcpu_EQ))
       return A->getValue();
-    if (T.getArch() == llvm::Triple::sparc && T.isOSSolaris())
-      return "v9";
     return "";
 
+  case llvm::Triple::sparc:
+  case llvm::Triple::sparcel:
+  case llvm::Triple::sparcv9:
+    return sparc::getSparcTargetCPU(D, Args, T);
+
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
     return x86::getX86TargetCPU(D, Args, T);
diff --git a/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp b/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp
index 34396b0b59c2..f203cae1d329 100644
--- a/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/contrib/llvm-project/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -631,6 +631,16 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
 
       AddRunTimeLibs(ToolChain, D, CmdArgs, Args);
 
+      // LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
+      // forcibly link with libatomic as a workaround.
+      // TODO: Issue #41880 and D118021.
+      if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
+        CmdArgs.push_back("--push-state");
+        CmdArgs.push_back("--as-needed");
+        CmdArgs.push_back("-latomic");
+        CmdArgs.push_back("--pop-state");
+      }
+
       if (WantPthread && !isAndroid)
         CmdArgs.push_back("-lpthread");
 
diff --git a/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp b/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp
index 7b07ab948f64..53cb48d2de9e 100644
--- a/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp
+++ b/contrib/llvm-project/clang/lib/Frontend/FrontendAction.cpp
@@ -772,7 +772,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
         if (ASTReader::isAcceptableASTFile(
                 Dir->path(), FileMgr, CI.getPCHContainerReader(),
                 CI.getLangOpts(), CI.getTargetOpts(), CI.getPreprocessorOpts(),
-                SpecificModuleCachePath)) {
+                SpecificModuleCachePath, /*RequireStrictOptionMatches=*/true)) {
           PPOpts.ImplicitPCHInclude = std::string(Dir->path());
           Found = true;
           break;
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp b/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp
index 985005d0b79b..75ffa8b0a90a 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaDecl.cpp
@@ -1711,6 +1711,80 @@ bool Sema::CheckRedeclarationInModule(NamedDecl *New, NamedDecl *Old) {
   return false;
 }
 
+// Check the redefinition in C++20 Modules.
+//
+// [basic.def.odr]p14:
+// For any definable item D with definitions in multiple translation units,
+// - if D is a non-inline non-templated function or variable, or
+// - if the definitions in different translation units do not satisfy the
+// following requirements,
+//   the program is ill-formed; a diagnostic is required only if the definable
+//   item is attached to a named module and a prior definition is reachable at
+//   the point where a later definition occurs.
+// - Each such definition shall not be attached to a named module
+// ([module.unit]).
+// - Each such definition shall consist of the same sequence of tokens, ...
+// ...
+//
+// Return true if the redefinition is not allowed. Return false otherwise.
+bool Sema::IsRedefinitionInModule(const NamedDecl *New,
+                                     const NamedDecl *Old) const {
+  assert(getASTContext().isSameEntity(New, Old) &&
+         "New and Old are not the same definition, we should diagnostic it "
+         "immediately instead of checking it.");
+  assert(const_cast<Sema *>(this)->isReachable(New) &&
+         const_cast<Sema *>(this)->isReachable(Old) &&
+         "We shouldn't see unreachable definitions here.");
+
+  Module *NewM = New->getOwningModule();
+  Module *OldM = Old->getOwningModule();
+
+  // We only checks for named modules here. The header like modules is skipped.
+  // FIXME: This is not right if we import the header like modules in the module
+  // purview.
+  //
+  // For example, assuming "header.h" provides definition for `D`.
+  // ```C++
+  // //--- M.cppm
+  // export module M;
+  // import "header.h"; // or #include "header.h" but import it by clang modules
+  // actually.
+  //
+  // //--- Use.cpp
+  // import M;
+  // import "header.h"; // or uses clang modules.
+  // ```
+  //
+  // In this case, `D` has multiple definitions in multiple TU (M.cppm and
+  // Use.cpp) and `D` is attached to a named module `M`. The compiler should
+  // reject it. But the current implementation couldn't detect the case since we
+  // don't record the information about the importee modules.
+  //
+  // But this might not be painful in practice. Since the design of C++20 Named
+  // Modules suggests us to use headers in global module fragment instead of
+  // module purview.
+  if (NewM && NewM->isHeaderLikeModule())
+    NewM = nullptr;
+  if (OldM && OldM->isHeaderLikeModule())
+    OldM = nullptr;
+
+  if (!NewM && !OldM)
+    return true;
+
+  // [basic.def.odr]p14.3
+  // Each such definition shall not be attached to a named module
+  // ([module.unit]).
+  if ((NewM && NewM->isModulePurview()) || (OldM && OldM->isModulePurview()))
+    return true;
+
+  // Then New and Old lives in the same TU if their share one same module unit.
+  if (NewM)
+    NewM = NewM->getTopLevelModule();
+  if (OldM)
+    OldM = OldM->getTopLevelModule();
+  return OldM == NewM;
+}
+
 static bool isUsingDecl(NamedDecl *D) {
   return isa<UsingShadowDecl>(D) ||
          isa<UnresolvedUsingTypenameDecl>(D) ||
@@ -3960,7 +4034,7 @@ bool Sema::MergeFunctionDecl(FunctionDecl *New, NamedDecl *&OldD, Scope *S,
     // default argument promotion rules were already checked by
     // ASTContext::typesAreCompatible().
     if (Old->hasPrototype() && !New->hasWrittenPrototype() && NewDeclIsDefn &&
-        Old->getNumParams() != New->getNumParams()) {
+        Old->getNumParams() != New->getNumParams() && !Old->isImplicit()) {
       if (Old->hasInheritedPrototype())
         Old = Old->getCanonicalDecl();
       Diag(New->getLocation(), diag::err_conflicting_types) << New;
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp b/contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp
index d72cc33ed0f5..5dc0aadb2d5f 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaOverload.cpp
@@ -63,9 +63,8 @@ static ExprResult CreateFunctionRefExpr(
   // being used.
   if (FoundDecl != Fn && S.DiagnoseUseOfDecl(Fn, Loc))
     return ExprError();
-  DeclRefExpr *DRE =
-      DeclRefExpr::Create(S.Context, Fn->getQualifierLoc(), SourceLocation(),
-                          Fn, false, Loc, Fn->getType(), VK_LValue, FoundDecl);
+  DeclRefExpr *DRE = new (S.Context)
+      DeclRefExpr(S.Context, Fn, false, Fn->getType(), VK_LValue, Loc, LocInfo);
   if (HadMultipleCandidates)
     DRE->setHadMultipleCandidates(true);
 
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp b/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
index 1542a07713fb..ecc9596a87f0 100644
--- a/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
+++ b/contrib/llvm-project/clang/lib/Sema/SemaTemplate.cpp
@@ -8728,7 +8728,7 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
   if (Previous.empty())
     return;
 
-  auto *OldConcept = dyn_cast<ConceptDecl>(Previous.getRepresentativeDecl());
+  auto *OldConcept = dyn_cast<ConceptDecl>(Previous.getRepresentativeDecl()->getUnderlyingDecl());
   if (!OldConcept) {
     auto *Old = Previous.getRepresentativeDecl();
     Diag(NewDecl->getLocation(), diag::err_redefinition_different_kind)
@@ -8746,7 +8746,8 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
     AddToScope = false;
     return;
   }
-  if (hasReachableDefinition(OldConcept)) {
+  if (hasReachableDefinition(OldConcept) &&
+      IsRedefinitionInModule(NewDecl, OldConcept)) {
     Diag(NewDecl->getLocation(), diag::err_redefinition)
         << NewDecl->getDeclName();
     notePreviousDefinition(OldConcept, NewDecl->getLocation());
@@ -8758,7 +8759,8 @@ void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
     //        Other decls (e.g. namespaces) also have this shortcoming.
     return;
   }
-  Context.setPrimaryMergedDecl(NewDecl, OldConcept);
+  // We unwrap canonical decl late to check for module visibility.
+  Context.setPrimaryMergedDecl(NewDecl, OldConcept->getCanonicalDecl());
 }
 
 /// \brief Strips various properties off an implicit instantiation
diff --git a/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp b/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
index 76281d26b2ae..d1e47c1045de 100644
--- a/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
+++ b/contrib/llvm-project/clang/lib/Serialization/ASTReader.cpp
@@ -624,20 +624,28 @@ collectMacroDefinitions(const PreprocessorOptions &PPOpts,
   }
 }
 
+enum OptionValidation {
+  OptionValidateNone,
+  OptionValidateContradictions,
+  OptionValidateStrictMatches,
+};
+
 /// Check the preprocessor options deserialized from the control block
 /// against the preprocessor options in an existing preprocessor.
 ///
 /// \param Diags If non-null, produce diagnostics for any mismatches incurred.
-/// \param Validate If true, validate preprocessor options. If false, allow
-///        macros defined by \p ExistingPPOpts to override those defined by
-///        \p PPOpts in SuggestedPredefines.
-static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
-                                     const PreprocessorOptions &ExistingPPOpts,
-                                     DiagnosticsEngine *Diags,
-                                     FileManager &FileMgr,
-                                     std::string &SuggestedPredefines,
-                                     const LangOptions &LangOpts,
-                                     bool Validate = true) {
+/// \param Validation If set to OptionValidateNone, ignore differences in
+///        preprocessor options. If set to OptionValidateContradictions,
+///        require that options passed both in the AST file and on the command
+///        line (-D or -U) match, but tolerate options missing in one or the
+///        other. If set to OptionValidateContradictions, require that there
+///        are no differences in the options between the two.
+static bool checkPreprocessorOptions(
+    const PreprocessorOptions &PPOpts,
+    const PreprocessorOptions &ExistingPPOpts, DiagnosticsEngine *Diags,
+    FileManager &FileMgr, std::string &SuggestedPredefines,
+    const LangOptions &LangOpts,
+    OptionValidation Validation = OptionValidateContradictions) {
   // Check macro definitions.
   MacroDefinitionsMap ASTFileMacros;
   collectMacroDefinitions(PPOpts, ASTFileMacros);
@@ -653,7 +661,15 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
     // Check whether we know anything about this macro name or not.
     llvm::StringMap<std::pair<StringRef, bool /*IsUndef*/>>::iterator Known =
         ASTFileMacros.find(MacroName);
-    if (!Validate || Known == ASTFileMacros.end()) {
+    if (Validation == OptionValidateNone || Known == ASTFileMacros.end()) {
+      if (Validation == OptionValidateStrictMatches) {
+        // If strict matches are requested, don't tolerate any extra defines on
+        // the command line that are missing in the AST file.
+        if (Diags) {
+          Diags->Report(diag::err_pch_macro_def_undef) << MacroName << true;
+        }
+        return true;
+      }
       // FIXME: Check whether this identifier was referenced anywhere in the
       // AST file. If so, we should reject the AST file. Unfortunately, this
       // information isn't in the control block. What shall we do about it?
@@ -684,8 +700,10 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
 
     // If the macro was #undef'd in both, or if the macro bodies are identical,
     // it's fine.
-    if (Existing.second || Existing.first == Known->second.first)
+    if (Existing.second || Existing.first == Known->second.first) {
+      ASTFileMacros.erase(Known);
       continue;
+    }
 
     // The macro bodies differ; complain.
     if (Diags) {
@@ -694,9 +712,20 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
     }
     return true;
   }
+  if (Validation == OptionValidateStrictMatches) {
+    // If strict matches are requested, don't tolerate any extra defines in
+    // the AST file that are missing on the command line.
+    for (const auto &MacroName : ASTFileMacros.keys()) {
+      if (Diags) {
+        Diags->Report(diag::err_pch_macro_def_undef) << MacroName << false;
+      }
+      return true;
+    }
+  }
 
   // Check whether we're using predefines.
-  if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines && Validate) {
+  if (PPOpts.UsePredefines != ExistingPPOpts.UsePredefines &&
+      Validation != OptionValidateNone) {
     if (Diags) {
       Diags->Report(diag::err_pch_undef) << ExistingPPOpts.UsePredefines;
     }
@@ -705,7 +734,8 @@ static bool checkPreprocessorOptions(const PreprocessorOptions &PPOpts,
 
   // Detailed record is important since it is used for the module cache hash.
   if (LangOpts.Modules &&
-      PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord && Validate) {
+      PPOpts.DetailedRecord != ExistingPPOpts.DetailedRecord &&
+      Validation != OptionValidateNone) {
     if (Diags) {
       Diags->Report(diag::err_pch_pp_detailed_record) << PPOpts.DetailedRecord;
     }
@@ -766,13 +796,9 @@ bool SimpleASTReaderListener::ReadPreprocessorOptions(
                                   const PreprocessorOptions &PPOpts,
                                   bool Complain,
                                   std::string &SuggestedPredefines) {
-  return checkPreprocessorOptions(PPOpts,
-                                  PP.getPreprocessorOpts(),
-                                  nullptr,
-                                  PP.getFileManager(),
-                                  SuggestedPredefines,
-                                  PP.getLangOpts(),
-                                  false);
+  return checkPreprocessorOptions(PPOpts, PP.getPreprocessorOpts(), nullptr,
+                                  PP.getFileManager(), SuggestedPredefines,
+                                  PP.getLangOpts(), OptionValidateNone);
 }
 
 /// Check the header search options deserialized from the control block
@@ -5138,16 +5164,19 @@ namespace {
     const PreprocessorOptions &ExistingPPOpts;
     std::string ExistingModuleCachePath;
     FileManager &FileMgr;
+    bool StrictOptionMatches;
 
   public:
     SimplePCHValidator(const LangOptions &ExistingLangOpts,
                        const TargetOptions &ExistingTargetOpts,
                        const PreprocessorOptions &ExistingPPOpts,
-                       StringRef ExistingModuleCachePath, FileManager &FileMgr)
+                       StringRef ExistingModuleCachePath, FileManager &FileMgr,
+                       bool StrictOptionMatches)
         : ExistingLangOpts(ExistingLangOpts),
           ExistingTargetOpts(ExistingTargetOpts),
           ExistingPPOpts(ExistingPPOpts),
-          ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr) {}
+          ExistingModuleCachePath(ExistingModuleCachePath), FileMgr(FileMgr),
+          StrictOptionMatches(StrictOptionMatches) {}
 
     bool ReadLanguageOptions(const LangOptions &LangOpts, bool Complain,
                              bool AllowCompatibleDifferences) override {
@@ -5172,9 +5201,11 @@ namespace {
     bool ReadPreprocessorOptions(const PreprocessorOptions &PPOpts,
                                  bool Complain,
                                  std::string &SuggestedPredefines) override {
-      return checkPreprocessorOptions(PPOpts, ExistingPPOpts, /*Diags=*/nullptr,
-                                      FileMgr, SuggestedPredefines,
-                                      ExistingLangOpts);
+      return checkPreprocessorOptions(
+          PPOpts, ExistingPPOpts, /*Diags=*/nullptr, FileMgr,
+          SuggestedPredefines, ExistingLangOpts,
+          StrictOptionMatches ? OptionValidateStrictMatches
+                              : OptionValidateContradictions);
     }
   };
 
@@ -5451,9 +5482,11 @@ bool ASTReader::isAcceptableASTFile(StringRef Filename, FileManager &FileMgr,
                                     const LangOptions &LangOpts,
                                     const TargetOptions &TargetOpts,
                                     const PreprocessorOptions &PPOpts,
-                                    StringRef ExistingModuleCachePath) {
+                                    StringRef ExistingModuleCachePath,
+                                    bool RequireStrictOptionMatches) {
   SimplePCHValidator validator(LangOpts, TargetOpts, PPOpts,
-                               ExistingModuleCachePath, FileMgr);
+                               ExistingModuleCachePath, FileMgr,
+                               RequireStrictOptionMatches);
   return !readASTFileControlBlock(Filename, FileMgr, PCHContainerRdr,
                                   /*FindModuleFileExtensions=*/false,
                                   validator,
diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h b/contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h
index 7a54564a3520..91f614528ab3 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/fp_trunc.h
@@ -60,7 +60,7 @@ typedef uint16_t dst_rep_t;
 static const int dstSigBits = 10;
 
 #elif defined DST_BFLOAT
-typedef uint16_t dst_t;
+typedef __bf16 dst_t;
 typedef uint16_t dst_rep_t;
 #define DST_REP_C UINT16_C
 static const int dstSigBits = 7;
diff --git a/contrib/llvm-project/compiler-rt/lib/builtins/int_types.h b/contrib/llvm-project/compiler-rt/lib/builtins/int_types.h
index 9ee5a327b28a..7a72de480676 100644
--- a/contrib/llvm-project/compiler-rt/lib/builtins/int_types.h
+++ b/contrib/llvm-project/compiler-rt/lib/builtins/int_types.h
@@ -64,7 +64,7 @@ typedef union {
 } udwords;
*** 10317 LINES SKIPPED ***