Author: dim
Date: Wed Aug  9 17:32:39 2017
New Revision: 322320
URL: https://svnweb.freebsd.org/changeset/base/322320

Log:
  Upgrade our copies of clang, llvm and libc++ to r310316 from the
  upstream release_50 branch.
  
  MFC after:    2 months
  X-MFC-with:   r321369

Modified:
  head/contrib/libc++/include/__bsd_locale_defaults.h
  head/contrib/libc++/include/__bsd_locale_fallbacks.h
  head/contrib/libc++/include/__locale
  head/contrib/libc++/include/mutex
  head/contrib/libc++/include/sstream
  head/contrib/llvm/include/llvm/Analysis/ValueTracking.h
  head/contrib/llvm/include/llvm/CodeGen/MachineFunction.h
  head/contrib/llvm/include/llvm/CodeGen/MachineInstr.h
  head/contrib/llvm/lib/Analysis/ValueTracking.cpp
  head/contrib/llvm/lib/CodeGen/BranchFolding.cpp
  head/contrib/llvm/lib/CodeGen/MachineFunction.cpp
  head/contrib/llvm/lib/CodeGen/MachineInstr.cpp
  head/contrib/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
  head/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  head/contrib/llvm/lib/CodeGen/StackColoring.cpp
  head/contrib/llvm/lib/IR/ConstantFold.cpp
  head/contrib/llvm/lib/Object/COFFImportFile.cpp
  head/contrib/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
  head/contrib/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
  head/contrib/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  head/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.td
  head/contrib/llvm/lib/Target/AArch64/AArch64MacroFusion.cpp
  head/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp
  head/contrib/llvm/lib/Target/X86/X86InstrSSE.td
  head/contrib/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
  head/contrib/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
  head/contrib/llvm/lib/Transforms/Scalar/SCCP.cpp
  head/contrib/llvm/lib/Transforms/Utils/CloneModule.cpp
  head/contrib/llvm/tools/clang/include/clang/AST/StmtCXX.h
  head/contrib/llvm/tools/clang/include/clang/Basic/BuiltinsX86.def
  head/contrib/llvm/tools/clang/include/clang/Driver/Options.td
  head/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h
  head/contrib/llvm/tools/clang/lib/AST/ODRHash.cpp
  head/contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp
  head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
  head/contrib/llvm/tools/clang/lib/Driver/ToolChains/Arch/Mips.cpp
  head/contrib/llvm/tools/clang/lib/Driver/ToolChains/OpenBSD.cpp
  head/contrib/llvm/tools/clang/lib/Headers/avx2intrin.h
  head/contrib/llvm/tools/clang/lib/Headers/avx512fintrin.h
  head/contrib/llvm/tools/clang/lib/Headers/avxintrin.h
  head/contrib/llvm/tools/clang/lib/Headers/float.h
  head/contrib/llvm/tools/clang/lib/Sema/Sema.cpp
  head/contrib/llvm/tools/clang/lib/Sema/SemaExpr.cpp
  head/contrib/llvm/tools/clang/lib/Serialization/ASTReaderStmt.cpp
  head/contrib/llvm/tools/clang/lib/Serialization/ASTWriterStmt.cpp
  head/lib/clang/include/clang/Basic/Version.inc
  head/lib/clang/include/lld/Config/Version.inc
  head/lib/clang/include/llvm/Support/VCSRevision.h
Directory Properties:
  head/contrib/compiler-rt/   (props changed)
  head/contrib/libc++/   (props changed)
  head/contrib/llvm/   (props changed)
  head/contrib/llvm/tools/clang/   (props changed)
  head/contrib/llvm/tools/lld/   (props changed)
  head/contrib/llvm/tools/lldb/   (props changed)

Modified: head/contrib/libc++/include/__bsd_locale_defaults.h
==============================================================================
--- head/contrib/libc++/include/__bsd_locale_defaults.h Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/libc++/include/__bsd_locale_defaults.h Wed Aug  9 17:32:39 
2017        (r322320)
@@ -15,6 +15,10 @@
 #ifndef _LIBCPP_BSD_LOCALE_DEFAULTS_H
 #define _LIBCPP_BSD_LOCALE_DEFAULTS_H
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 #define __libcpp_mb_cur_max_l(loc)                          MB_CUR_MAX_L(loc)
 #define __libcpp_btowc_l(ch, loc)                           btowc_l(ch, loc)
 #define __libcpp_wctob_l(wch, loc)                          wctob_l(wch, loc)

Modified: head/contrib/libc++/include/__bsd_locale_fallbacks.h
==============================================================================
--- head/contrib/libc++/include/__bsd_locale_fallbacks.h        Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/libc++/include/__bsd_locale_fallbacks.h        Wed Aug  9 
17:32:39 2017        (r322320)
@@ -18,6 +18,10 @@
 #include <stdarg.h>
 #include <memory>
 
+#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
+#pragma GCC system_header
+#endif
+
 _LIBCPP_BEGIN_NAMESPACE_STD
 
 inline _LIBCPP_ALWAYS_INLINE

Modified: head/contrib/libc++/include/__locale
==============================================================================
--- head/contrib/libc++/include/__locale        Wed Aug  9 16:37:37 2017        
(r322319)
+++ head/contrib/libc++/include/__locale        Wed Aug  9 17:32:39 2017        
(r322320)
@@ -34,7 +34,7 @@
 # include <support/solaris/xlocale.h>
 #elif defined(_NEWLIB_VERSION)
 # include <support/newlib/xlocale.h>
-#elif (defined(__GLIBC__) || defined(__APPLE__)      || defined(__FreeBSD__) \
+#elif (defined(__APPLE__)      || defined(__FreeBSD__) \
     || defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
 # include <xlocale.h>
 #elif defined(__Fuchsia__)

Modified: head/contrib/libc++/include/mutex
==============================================================================
--- head/contrib/libc++/include/mutex   Wed Aug  9 16:37:37 2017        
(r322319)
+++ head/contrib/libc++/include/mutex   Wed Aug  9 17:32:39 2017        
(r322320)
@@ -116,7 +116,7 @@ class scoped_lock // C++17 (public)
     using mutex_type = Mutex;  // If MutexTypes... consists of the single type 
Mutex
 
     explicit scoped_lock(MutexTypes&... m);
-    scoped_lock(MutexTypes&... m, adopt_lock_t);
+    scoped_lock(adopt_lock_t, MutexTypes&... m);
     ~scoped_lock();
     scoped_lock(scoped_lock const&) = delete;
     scoped_lock& operator=(scoped_lock const&) = delete;
@@ -500,7 +500,7 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock<_Mutex> { (publ
     ~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) 
{__m_.unlock();}
 
     _LIBCPP_INLINE_VISIBILITY
-    explicit scoped_lock(mutex_type& __m, adopt_lock_t) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
+    explicit scoped_lock(adopt_lock_t, mutex_type& __m) 
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
         : __m_(__m) {}
 
     scoped_lock(scoped_lock const&) = delete;
@@ -522,7 +522,7 @@ class _LIBCPP_TEMPLATE_VIS scoped_lock (public)
     }
 
     _LIBCPP_INLINE_VISIBILITY
-    scoped_lock(_MArgs&... __margs, adopt_lock_t)
+    scoped_lock(adopt_lock_t, _MArgs&... __margs)
         : __t_(__margs...)
     {
     }

Modified: head/contrib/libc++/include/sstream
==============================================================================
--- head/contrib/libc++/include/sstream Wed Aug  9 16:37:37 2017        
(r322319)
+++ head/contrib/libc++/include/sstream Wed Aug  9 17:32:39 2017        
(r322320)
@@ -249,7 +249,8 @@ basic_stringbuf<_CharT, _Traits, _Allocator>::basic_st
 template <class _CharT, class _Traits, class _Allocator>
 basic_stringbuf<_CharT, _Traits, _Allocator>::basic_stringbuf(const 
string_type& __s,
                              ios_base::openmode __wch)
-    : __hm_(0),
+    : __str_(__s.get_allocator()),
+      __hm_(0),
       __mode_(__wch)
 {
     str(__s);

Modified: head/contrib/llvm/include/llvm/Analysis/ValueTracking.h
==============================================================================
--- head/contrib/llvm/include/llvm/Analysis/ValueTracking.h     Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/include/llvm/Analysis/ValueTracking.h     Wed Aug  9 
17:32:39 2017        (r322320)
@@ -312,6 +312,12 @@ template <typename T> class ArrayRef;
                             const DataLayout &DL, LoopInfo *LI = nullptr,
                             unsigned MaxLookup = 6);
 
+  /// This is a wrapper around GetUnderlyingObjects and adds support for basic
+  /// ptrtoint+arithmetic+inttoptr sequences.
+  void getUnderlyingObjectsForCodeGen(const Value *V,
+                            SmallVectorImpl<Value *> &Objects,
+                            const DataLayout &DL);
+
   /// Return true if the only users of this pointer are lifetime markers.
   bool onlyUsedByLifetimeMarkers(const Value *V);
 

Modified: head/contrib/llvm/include/llvm/CodeGen/MachineFunction.h
==============================================================================
--- head/contrib/llvm/include/llvm/CodeGen/MachineFunction.h    Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/include/llvm/CodeGen/MachineFunction.h    Wed Aug  9 
17:32:39 2017        (r322320)
@@ -661,6 +661,12 @@ class MachineFunction { (public)
   MachineMemOperand *getMachineMemOperand(const MachineMemOperand *MMO,
                                           int64_t Offset, uint64_t Size);
 
+  /// Allocate a new MachineMemOperand by copying an existing one,
+  /// replacing only AliasAnalysis information. MachineMemOperands are owned
+  /// by the MachineFunction and need not be explicitly deallocated.
+  MachineMemOperand *getMachineMemOperand(const MachineMemOperand *MMO,
+                                          const AAMDNodes &AAInfo);
+
   using OperandCapacity = ArrayRecycler<MachineOperand>::Capacity;
 
   /// Allocate an array of MachineOperands. This is only intended for use by

Modified: head/contrib/llvm/include/llvm/CodeGen/MachineInstr.h
==============================================================================
--- head/contrib/llvm/include/llvm/CodeGen/MachineInstr.h       Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/include/llvm/CodeGen/MachineInstr.h       Wed Aug  9 
17:32:39 2017        (r322320)
@@ -379,6 +379,9 @@ class MachineInstr (public)
     return NumMemRefs == 1;
   }
 
+  /// Return the number of memory operands.
+  unsigned getNumMemOperands() const { return NumMemRefs; }
+
   /// API for querying MachineInstr properties. They are the same as 
MCInstrDesc
   /// queries but they are bundle aware.
 

Modified: head/contrib/llvm/lib/Analysis/ValueTracking.cpp
==============================================================================
--- head/contrib/llvm/lib/Analysis/ValueTracking.cpp    Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/Analysis/ValueTracking.cpp    Wed Aug  9 17:32:39 
2017        (r322320)
@@ -3277,6 +3277,69 @@ void llvm::GetUnderlyingObjects(Value *V, SmallVectorI
   } while (!Worklist.empty());
 }
 
+/// This is the function that does the work of looking through basic
+/// ptrtoint+arithmetic+inttoptr sequences.
+static const Value *getUnderlyingObjectFromInt(const Value *V) {
+  do {
+    if (const Operator *U = dyn_cast<Operator>(V)) {
+      // If we find a ptrtoint, we can transfer control back to the
+      // regular getUnderlyingObjectFromInt.
+      if (U->getOpcode() == Instruction::PtrToInt)
+        return U->getOperand(0);
+      // If we find an add of a constant, a multiplied value, or a phi, it's
+      // likely that the other operand will lead us to the base
+      // object. We don't have to worry about the case where the
+      // object address is somehow being computed by the multiply,
+      // because our callers only care when the result is an
+      // identifiable object.
+      if (U->getOpcode() != Instruction::Add ||
+          (!isa<ConstantInt>(U->getOperand(1)) &&
+           Operator::getOpcode(U->getOperand(1)) != Instruction::Mul &&
+           !isa<PHINode>(U->getOperand(1))))
+        return V;
+      V = U->getOperand(0);
+    } else {
+      return V;
+    }
+    assert(V->getType()->isIntegerTy() && "Unexpected operand type!");
+  } while (true);
+}
+
+/// This is a wrapper around GetUnderlyingObjects and adds support for basic
+/// ptrtoint+arithmetic+inttoptr sequences.
+void llvm::getUnderlyingObjectsForCodeGen(const Value *V,
+                          SmallVectorImpl<Value *> &Objects,
+                          const DataLayout &DL) {
+  SmallPtrSet<const Value *, 16> Visited;
+  SmallVector<const Value *, 4> Working(1, V);
+  do {
+    V = Working.pop_back_val();
+
+    SmallVector<Value *, 4> Objs;
+    GetUnderlyingObjects(const_cast<Value *>(V), Objs, DL);
+
+    for (Value *V : Objs) {
+      if (!Visited.insert(V).second)
+        continue;
+      if (Operator::getOpcode(V) == Instruction::IntToPtr) {
+        const Value *O =
+          getUnderlyingObjectFromInt(cast<User>(V)->getOperand(0));
+        if (O->getType()->isPointerTy()) {
+          Working.push_back(O);
+          continue;
+        }
+      }
+      // If GetUnderlyingObjects fails to find an identifiable object,
+      // getUnderlyingObjectsForCodeGen also fails for safety.
+      if (!isIdentifiedObject(V)) {
+        Objects.clear();
+        return;
+      }
+      Objects.push_back(const_cast<Value *>(V));
+    }
+  } while (!Working.empty());
+}
+
 /// Return true if the only users of this pointer are lifetime markers.
 bool llvm::onlyUsedByLifetimeMarkers(const Value *V) {
   for (const User *U : V->users()) {

Modified: head/contrib/llvm/lib/CodeGen/BranchFolding.cpp
==============================================================================
--- head/contrib/llvm/lib/CodeGen/BranchFolding.cpp     Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/CodeGen/BranchFolding.cpp     Wed Aug  9 17:32:39 
2017        (r322320)
@@ -1475,13 +1475,14 @@ ReoptimizeBlock:
       bool PredAnalyzable =
           !TII->analyzeBranch(*Pred, PredTBB, PredFBB, PredCond, true);
 
-      if (PredAnalyzable && !PredCond.empty() && PredTBB == MBB) {
+      if (PredAnalyzable && !PredCond.empty() && PredTBB == MBB &&
+          PredTBB != PredFBB) {
         // The predecessor has a conditional branch to this block which 
consists
         // of only a tail call. Try to fold the tail call into the conditional
         // branch.
         if (TII->canMakeTailCallConditional(PredCond, TailCall)) {
           // TODO: It would be nice if analyzeBranch() could provide a pointer
-          // to the branch insturction so replaceBranchWithTailCall() doesn't
+          // to the branch instruction so replaceBranchWithTailCall() doesn't
           // have to search for it.
           TII->replaceBranchWithTailCall(*Pred, PredCond, TailCall);
           ++NumTailCalls;

Modified: head/contrib/llvm/lib/CodeGen/MachineFunction.cpp
==============================================================================
--- head/contrib/llvm/lib/CodeGen/MachineFunction.cpp   Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/CodeGen/MachineFunction.cpp   Wed Aug  9 17:32:39 
2017        (r322320)
@@ -330,6 +330,20 @@ MachineFunction::getMachineMemOperand(const MachineMem
                                MMO->getOrdering(), MMO->getFailureOrdering());
 }
 
+MachineMemOperand *
+MachineFunction::getMachineMemOperand(const MachineMemOperand *MMO,
+                                      const AAMDNodes &AAInfo) {
+  MachinePointerInfo MPI = MMO->getValue() ?
+             MachinePointerInfo(MMO->getValue(), MMO->getOffset()) :
+             MachinePointerInfo(MMO->getPseudoValue(), MMO->getOffset());
+
+  return new (Allocator)
+             MachineMemOperand(MPI, MMO->getFlags(), MMO->getSize(),
+                               MMO->getBaseAlignment(), AAInfo,
+                               MMO->getRanges(), MMO->getSyncScopeID(),
+                               MMO->getOrdering(), MMO->getFailureOrdering());
+}
+
 MachineInstr::mmo_iterator
 MachineFunction::allocateMemRefsArray(unsigned long Num) {
   return Allocator.Allocate<MachineMemOperand *>(Num);

Modified: head/contrib/llvm/lib/CodeGen/MachineInstr.cpp
==============================================================================
--- head/contrib/llvm/lib/CodeGen/MachineInstr.cpp      Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/CodeGen/MachineInstr.cpp      Wed Aug  9 17:32:39 
2017        (r322320)
@@ -578,10 +578,8 @@ bool MachinePointerInfo::isDereferenceable(unsigned Si
   if (BasePtr == nullptr)
     return false;
 
-  return isDereferenceableAndAlignedPointer(BasePtr, 1,
-                                            APInt(DL.getPointerSize(),
-                                                  Offset + Size),
-                                            DL);
+  return isDereferenceableAndAlignedPointer(
+      BasePtr, 1, APInt(DL.getPointerSizeInBits(), Offset + Size), DL);
 }
 
 /// getConstantPool - Return a MachinePointerInfo record that refers to the

Modified: head/contrib/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp
==============================================================================
--- head/contrib/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/CodeGen/ScheduleDAGInstrs.cpp Wed Aug  9 17:32:39 
2017        (r322320)
@@ -121,63 +121,6 @@ ScheduleDAGInstrs::ScheduleDAGInstrs(MachineFunction &
   SchedModel.init(ST.getSchedModel(), &ST, TII);
 }
 
-/// This is the function that does the work of looking through basic
-/// ptrtoint+arithmetic+inttoptr sequences.
-static const Value *getUnderlyingObjectFromInt(const Value *V) {
-  do {
-    if (const Operator *U = dyn_cast<Operator>(V)) {
-      // If we find a ptrtoint, we can transfer control back to the
-      // regular getUnderlyingObjectFromInt.
-      if (U->getOpcode() == Instruction::PtrToInt)
-        return U->getOperand(0);
-      // If we find an add of a constant, a multiplied value, or a phi, it's
-      // likely that the other operand will lead us to the base
-      // object. We don't have to worry about the case where the
-      // object address is somehow being computed by the multiply,
-      // because our callers only care when the result is an
-      // identifiable object.
-      if (U->getOpcode() != Instruction::Add ||
-          (!isa<ConstantInt>(U->getOperand(1)) &&
-           Operator::getOpcode(U->getOperand(1)) != Instruction::Mul &&
-           !isa<PHINode>(U->getOperand(1))))
-        return V;
-      V = U->getOperand(0);
-    } else {
-      return V;
-    }
-    assert(V->getType()->isIntegerTy() && "Unexpected operand type!");
-  } while (true);
-}
-
-/// This is a wrapper around GetUnderlyingObjects and adds support for basic
-/// ptrtoint+arithmetic+inttoptr sequences.
-static void getUnderlyingObjects(const Value *V,
-                                 SmallVectorImpl<Value *> &Objects,
-                                 const DataLayout &DL) {
-  SmallPtrSet<const Value *, 16> Visited;
-  SmallVector<const Value *, 4> Working(1, V);
-  do {
-    V = Working.pop_back_val();
-
-    SmallVector<Value *, 4> Objs;
-    GetUnderlyingObjects(const_cast<Value *>(V), Objs, DL);
-
-    for (Value *V : Objs) {
-      if (!Visited.insert(V).second)
-        continue;
-      if (Operator::getOpcode(V) == Instruction::IntToPtr) {
-        const Value *O =
-          getUnderlyingObjectFromInt(cast<User>(V)->getOperand(0));
-        if (O->getType()->isPointerTy()) {
-          Working.push_back(O);
-          continue;
-        }
-      }
-      Objects.push_back(const_cast<Value *>(V));
-    }
-  } while (!Working.empty());
-}
-
 /// If this machine instr has memory reference information and it can be 
tracked
 /// to a normal reference to a known object, return the Value for that object.
 static void getUnderlyingObjectsForInstr(const MachineInstr *MI,
@@ -208,12 +151,10 @@ static void getUnderlyingObjectsForInstr(const Machine
         Objects.push_back(UnderlyingObjectsVector::value_type(PSV, MayAlias));
       } else if (const Value *V = MMO->getValue()) {
         SmallVector<Value *, 4> Objs;
-        getUnderlyingObjects(V, Objs, DL);
+        getUnderlyingObjectsForCodeGen(V, Objs, DL);
 
         for (Value *V : Objs) {
-          if (!isIdentifiedObject(V))
-            return false;
-
+          assert(isIdentifiedObject(V));
           Objects.push_back(UnderlyingObjectsVector::value_type(V, true));
         }
       } else

Modified: head/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
==============================================================================
--- head/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp  Wed Aug 
 9 16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp  Wed Aug 
 9 17:32:39 2017        (r322320)
@@ -99,6 +99,27 @@ LimitFPPrecision("limit-float-precision",
 // store [4096 x i8] %data, [4096 x i8]* %buffer
 static const unsigned MaxParallelChains = 64;
 
+// True if the Value passed requires ABI mangling as it is a parameter to a
+// function or a return value from a function which is not an intrinsic.
+static bool isABIRegCopy(const Value * V) {
+  const bool IsRetInst = V && isa<ReturnInst>(V);
+  const bool IsCallInst = V && isa<CallInst>(V);
+  const bool IsInLineAsm =
+      IsCallInst && static_cast<const CallInst *>(V)->isInlineAsm();
+  const bool IsIndirectFunctionCall =
+      IsCallInst && !IsInLineAsm &&
+      !static_cast<const CallInst *>(V)->getCalledFunction();
+  // It is possible that the call instruction is an inline asm statement or an
+  // indirect function call in which case the return value of
+  // getCalledFunction() would be nullptr.
+  const bool IsInstrinsicCall =
+      IsCallInst && !IsInLineAsm && !IsIndirectFunctionCall &&
+      static_cast<const CallInst *>(V)->getCalledFunction()->getIntrinsicID() 
!=
+          Intrinsic::not_intrinsic;
+
+  return IsRetInst || (IsCallInst && (!IsInLineAsm && !IsInstrinsicCall));
+}
+
 static SDValue getCopyFromPartsVector(SelectionDAG &DAG, const SDLoc &DL,
                                       const SDValue *Parts, unsigned NumParts,
                                       MVT PartVT, EVT ValueVT, const Value *V,
@@ -1026,13 +1047,9 @@ SDValue SelectionDAGBuilder::getCopyFromRegs(const Val
 
   if (It != FuncInfo.ValueMap.end()) {
     unsigned InReg = It->second;
-    bool IsABIRegCopy =
-        V && ((isa<CallInst>(V) &&
-               !(static_cast<const CallInst *>(V))->isInlineAsm()) ||
-              isa<ReturnInst>(V));
 
     RegsForValue RFV(*DAG.getContext(), DAG.getTargetLoweringInfo(),
-                     DAG.getDataLayout(), InReg, Ty, IsABIRegCopy);
+                     DAG.getDataLayout(), InReg, Ty, isABIRegCopy(V));
     SDValue Chain = DAG.getEntryNode();
     Result = RFV.getCopyFromRegs(DAG, FuncInfo, getCurSDLoc(), Chain, nullptr,
                                  V);
@@ -1221,13 +1238,9 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value 
   // If this is an instruction which fast-isel has deferred, select it now.
   if (const Instruction *Inst = dyn_cast<Instruction>(V)) {
     unsigned InReg = FuncInfo.InitializeRegForValue(Inst);
-    bool IsABIRegCopy =
-        V && ((isa<CallInst>(V) &&
-               !(static_cast<const CallInst *>(V))->isInlineAsm()) ||
-              isa<ReturnInst>(V));
 
     RegsForValue RFV(*DAG.getContext(), TLI, DAG.getDataLayout(), InReg,
-                     Inst->getType(), IsABIRegCopy);
+                     Inst->getType(), isABIRegCopy(V));
     SDValue Chain = DAG.getEntryNode();
     return RFV.getCopyFromRegs(DAG, FuncInfo, getCurSDLoc(), Chain, nullptr, 
V);
   }
@@ -8281,13 +8294,9 @@ SelectionDAGBuilder::CopyValueToVirtualRegister(const 
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   // If this is an InlineAsm we have to match the registers required, not the
   // notional registers required by the type.
-  bool IsABIRegCopy =
-    V && ((isa<CallInst>(V) &&
-           !(static_cast<const CallInst *>(V))->isInlineAsm()) ||
-          isa<ReturnInst>(V));
 
   RegsForValue RFV(V->getContext(), TLI, DAG.getDataLayout(), Reg,
-                   V->getType(), IsABIRegCopy);
+                   V->getType(), isABIRegCopy(V));
   SDValue Chain = DAG.getEntryNode();
 
   ISD::NodeType ExtendType = (FuncInfo.PreferredExtendType.find(V) ==

Modified: head/contrib/llvm/lib/CodeGen/StackColoring.cpp
==============================================================================
--- head/contrib/llvm/lib/CodeGen/StackColoring.cpp     Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/CodeGen/StackColoring.cpp     Wed Aug  9 17:32:39 
2017        (r322320)
@@ -37,6 +37,7 @@
 #include "llvm/CodeGen/MachineRegisterInfo.h"
 #include "llvm/CodeGen/Passes.h"
 #include "llvm/CodeGen/PseudoSourceValue.h"
+#include "llvm/CodeGen/SelectionDAGNodes.h"
 #include "llvm/CodeGen/SlotIndexes.h"
 #include "llvm/CodeGen/StackProtector.h"
 #include "llvm/CodeGen/WinEHFuncInfo.h"
@@ -889,6 +890,10 @@ void StackColoring::remapInstructions(DenseMap<int, in
 
   // Keep a list of *allocas* which need to be remapped.
   DenseMap<const AllocaInst*, const AllocaInst*> Allocas;
+
+  // Keep a list of allocas which has been affected by the remap.
+  SmallPtrSet<const AllocaInst*, 32> MergedAllocas;
+
   for (const std::pair<int, int> &SI : SlotRemap) {
     const AllocaInst *From = MFI->getObjectAllocation(SI.first);
     const AllocaInst *To = MFI->getObjectAllocation(SI.second);
@@ -908,6 +913,10 @@ void StackColoring::remapInstructions(DenseMap<int, in
       Inst = Cast;
     }
 
+    // We keep both slots to maintain AliasAnalysis metadata later.
+    MergedAllocas.insert(From);
+    MergedAllocas.insert(To);
+
     // Allow the stack protector to adjust its value map to account for the
     // upcoming replacement.
     SP->adjustForColoring(From, To);
@@ -939,13 +948,6 @@ void StackColoring::remapInstructions(DenseMap<int, in
 
       // Update the MachineMemOperand to use the new alloca.
       for (MachineMemOperand *MMO : I.memoperands()) {
-        // FIXME: In order to enable the use of TBAA when using AA in CodeGen,
-        // we'll also need to update the TBAA nodes in MMOs with values
-        // derived from the merged allocas. When doing this, we'll need to use
-        // the same variant of GetUnderlyingObjects that is used by the
-        // instruction scheduler (that can look through ptrtoint/inttoptr
-        // pairs).
-
         // We've replaced IR-level uses of the remapped allocas, so we only
         // need to replace direct uses here.
         const AllocaInst *AI = dyn_cast_or_null<AllocaInst>(MMO->getValue());
@@ -997,6 +999,48 @@ void StackColoring::remapInstructions(DenseMap<int, in
         MO.setIndex(ToSlot);
         FixedInstr++;
       }
+
+      // We adjust AliasAnalysis information for merged stack slots.
+      MachineSDNode::mmo_iterator NewMemOps =
+          MF->allocateMemRefsArray(I.getNumMemOperands());
+      unsigned MemOpIdx = 0;
+      bool ReplaceMemOps = false;
+      for (MachineMemOperand *MMO : I.memoperands()) {
+        // If this memory location can be a slot remapped here,
+        // we remove AA information.
+        bool MayHaveConflictingAAMD = false;
+        if (MMO->getAAInfo()) {
+          if (const Value *MMOV = MMO->getValue()) {
+            SmallVector<Value *, 4> Objs;
+            getUnderlyingObjectsForCodeGen(MMOV, Objs, MF->getDataLayout());
+
+            if (Objs.empty())
+              MayHaveConflictingAAMD = true;
+            else
+              for (Value *V : Objs) {
+                // If this memory location comes from a known stack slot
+                // that is not remapped, we continue checking.
+                // Otherwise, we need to invalidate AA infomation.
+                const AllocaInst *AI = dyn_cast_or_null<AllocaInst>(V);
+                if (AI && MergedAllocas.count(AI)) {
+                  MayHaveConflictingAAMD = true;
+                  break;
+                }
+              }
+          }
+        }
+        if (MayHaveConflictingAAMD) {
+          NewMemOps[MemOpIdx++] = MF->getMachineMemOperand(MMO, AAMDNodes());
+          ReplaceMemOps = true;
+        }
+        else
+          NewMemOps[MemOpIdx++] = MMO;
+      }
+
+      // If any memory operand is updated, set memory references of
+      // this instruction.
+      if (ReplaceMemOps)
+        I.setMemRefs(std::make_pair(NewMemOps, I.getNumMemOperands()));
     }
 
   // Update the location of C++ catch objects for the MSVC personality routine.

Modified: head/contrib/llvm/lib/IR/ConstantFold.cpp
==============================================================================
--- head/contrib/llvm/lib/IR/ConstantFold.cpp   Wed Aug  9 16:37:37 2017        
(r322319)
+++ head/contrib/llvm/lib/IR/ConstantFold.cpp   Wed Aug  9 17:32:39 2017        
(r322320)
@@ -2097,15 +2097,19 @@ Constant *llvm::ConstantFoldGetElementPtr(Type *Pointe
       // Subsequent evaluation would get confused and produce erroneous 
results.
       //
       // The following prohibits such a GEP from being formed by checking to 
see
-      // if the index is in-range with respect to an array or vector.
+      // if the index is in-range with respect to an array.
+      // TODO: This code may be extended to handle vectors as well.
       bool PerformFold = false;
       if (Idx0->isNullValue())
         PerformFold = true;
       else if (LastI.isSequential())
         if (ConstantInt *CI = dyn_cast<ConstantInt>(Idx0))
-          PerformFold =
-              !LastI.isBoundedSequential() ||
-              isIndexInRangeOfArrayType(LastI.getSequentialNumElements(), CI);
+          PerformFold = (!LastI.isBoundedSequential() ||
+                         isIndexInRangeOfArrayType(
+                             LastI.getSequentialNumElements(), CI)) &&
+                        !CE->getOperand(CE->getNumOperands() - 1)
+                             ->getType()
+                             ->isVectorTy();
 
       if (PerformFold) {
         SmallVector<Value*, 16> NewIndices;

Modified: head/contrib/llvm/lib/Object/COFFImportFile.cpp
==============================================================================
--- head/contrib/llvm/lib/Object/COFFImportFile.cpp     Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/Object/COFFImportFile.cpp     Wed Aug  9 17:32:39 
2017        (r322320)
@@ -542,15 +542,12 @@ NewArchiveMember ObjectFactory::createWeakExternal(Str
   SymbolTable[2].Name.Offset.Offset = sizeof(uint32_t);
 
   //__imp_ String Table
-  if (Imp) {
-    SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 7;
-    writeStringTable(Buffer, {std::string("__imp_").append(Sym),
-                              std::string("__imp_").append(Weak)});
-  } else {
-    SymbolTable[3].Name.Offset.Offset = sizeof(uint32_t) + Sym.size() + 1;
-    writeStringTable(Buffer, {Sym, Weak});
-  }
+  StringRef Prefix = Imp ? "__imp_" : "";
+  SymbolTable[3].Name.Offset.Offset =
+      sizeof(uint32_t) + Sym.size() + Prefix.size() + 1;
   append(Buffer, SymbolTable);
+  writeStringTable(Buffer, {(Prefix + Sym).str(),
+                            (Prefix + Weak).str()});
 
   // Copied here so we can still use writeStringTable
   char *Buf = Alloc.Allocate<char>(Buffer.size());

Modified: head/contrib/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp
==============================================================================
--- head/contrib/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp   Wed Aug 
 9 16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Target/AArch64/AArch64ExpandPseudoInsts.cpp   Wed Aug 
 9 17:32:39 2017        (r322320)
@@ -946,6 +946,18 @@ bool AArch64ExpandPseudo::expandMI(MachineBasicBlock &
   case AArch64::CMP_SWAP_128:
     return expandCMP_SWAP_128(MBB, MBBI, NextMBBI);
 
+  case AArch64::AESMCrrTied:
+  case AArch64::AESIMCrrTied: {
+    MachineInstrBuilder MIB =
+    BuildMI(MBB, MBBI, MI.getDebugLoc(),
+            TII->get(Opcode == AArch64::AESMCrrTied ? AArch64::AESMCrr :
+                                                      AArch64::AESIMCrr))
+      .add(MI.getOperand(0))
+      .add(MI.getOperand(1));
+    transferImpOps(MI, MIB, MIB);
+    MI.eraseFromParent();
+    return true;
+   }
   }
   return false;
 }

Modified: head/contrib/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp
==============================================================================
--- head/contrib/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp       Wed Aug 
 9 16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Target/AArch64/AArch64FrameLowering.cpp       Wed Aug 
 9 17:32:39 2017        (r322320)
@@ -506,19 +506,23 @@ void AArch64FrameLowering::emitPrologue(MachineFunctio
     return;
   }
 
-  auto CSStackSize = AFI->getCalleeSavedStackSize();
+  bool IsWin64 =
+      Subtarget.isCallingConvWin64(MF.getFunction()->getCallingConv());
+  unsigned FixedObject = IsWin64 ? alignTo(AFI->getVarArgsGPRSize(), 16) : 0;
+
+  auto PrologueSaveSize = AFI->getCalleeSavedStackSize() + FixedObject;
   // All of the remaining stack allocations are for locals.
-  AFI->setLocalStackSize(NumBytes - CSStackSize);
+  AFI->setLocalStackSize(NumBytes - PrologueSaveSize);
 
   bool CombineSPBump = shouldCombineCSRLocalStackBump(MF, NumBytes);
   if (CombineSPBump) {
     emitFrameOffset(MBB, MBBI, DL, AArch64::SP, AArch64::SP, -NumBytes, TII,
                     MachineInstr::FrameSetup);
     NumBytes = 0;
-  } else if (CSStackSize != 0) {
+  } else if (PrologueSaveSize != 0) {
     MBBI = convertCalleeSaveRestoreToSPPrePostIncDec(MBB, MBBI, DL, TII,
-                                                     -CSStackSize);
-    NumBytes -= CSStackSize;
+                                                     -PrologueSaveSize);
+    NumBytes -= PrologueSaveSize;
   }
   assert(NumBytes >= 0 && "Negative stack allocation size!?");
 
@@ -532,8 +536,9 @@ void AArch64FrameLowering::emitPrologue(MachineFunctio
     ++MBBI;
   }
   if (HasFP) {
-    // Only set up FP if we actually need to. Frame pointer is fp = sp - 16.
-    int FPOffset = CSStackSize - 16;
+    // Only set up FP if we actually need to. Frame pointer is fp =
+    // sp - fixedobject - 16.
+    int FPOffset = AFI->getCalleeSavedStackSize() - 16;
     if (CombineSPBump)
       FPOffset += AFI->getLocalStackSize();
 
@@ -672,8 +677,8 @@ void AArch64FrameLowering::emitPrologue(MachineFunctio
     if (HasFP) {
       // Define the current CFA rule to use the provided FP.
       unsigned Reg = RegInfo->getDwarfRegNum(FramePtr, true);
-      unsigned CFIIndex = MF.addFrameInst(
-          MCCFIInstruction::createDefCfa(nullptr, Reg, 2 * StackGrowth));
+      unsigned CFIIndex = MF.addFrameInst(MCCFIInstruction::createDefCfa(
+          nullptr, Reg, 2 * StackGrowth - FixedObject));
       BuildMI(MBB, MBBI, DL, TII->get(TargetOpcode::CFI_INSTRUCTION))
           .addCFIIndex(CFIIndex)
           .setMIFlags(MachineInstr::FrameSetup);
@@ -759,12 +764,16 @@ void AArch64FrameLowering::emitEpilogue(MachineFunctio
   // AArch64TargetLowering::LowerCall figures out ArgumentPopSize and keeps
   // it as the 2nd argument of AArch64ISD::TC_RETURN.
 
-  auto CSStackSize = AFI->getCalleeSavedStackSize();
+  bool IsWin64 =
+      Subtarget.isCallingConvWin64(MF.getFunction()->getCallingConv());
+  unsigned FixedObject = IsWin64 ? alignTo(AFI->getVarArgsGPRSize(), 16) : 0;
+
+  auto PrologueSaveSize = AFI->getCalleeSavedStackSize() + FixedObject;
   bool CombineSPBump = shouldCombineCSRLocalStackBump(MF, NumBytes);
 
-  if (!CombineSPBump && CSStackSize != 0)
+  if (!CombineSPBump && PrologueSaveSize != 0)
     convertCalleeSaveRestoreToSPPrePostIncDec(
-        MBB, std::prev(MBB.getFirstTerminator()), DL, TII, CSStackSize);
+        MBB, std::prev(MBB.getFirstTerminator()), DL, TII, PrologueSaveSize);
 
   // Move past the restores of the callee-saved registers.
   MachineBasicBlock::iterator LastPopI = MBB.getFirstTerminator();
@@ -786,7 +795,7 @@ void AArch64FrameLowering::emitEpilogue(MachineFunctio
     return;
   }
 
-  NumBytes -= CSStackSize;
+  NumBytes -= PrologueSaveSize;
   assert(NumBytes >= 0 && "Negative stack allocation size!?");
 
   if (!hasFP(MF)) {
@@ -796,7 +805,7 @@ void AArch64FrameLowering::emitEpilogue(MachineFunctio
     if (RedZone && ArgumentPopSize == 0)
       return;
 
-    bool NoCalleeSaveRestore = CSStackSize == 0;
+    bool NoCalleeSaveRestore = PrologueSaveSize == 0;
     int StackRestoreBytes = RedZone ? 0 : NumBytes;
     if (NoCalleeSaveRestore)
       StackRestoreBytes += ArgumentPopSize;
@@ -815,7 +824,8 @@ void AArch64FrameLowering::emitEpilogue(MachineFunctio
   // be able to save any instructions.
   if (MFI.hasVarSizedObjects() || AFI->isStackRealigned())
     emitFrameOffset(MBB, LastPopI, DL, AArch64::SP, AArch64::FP,
-                    -CSStackSize + 16, TII, MachineInstr::FrameDestroy);
+                    -AFI->getCalleeSavedStackSize() + 16, TII,
+                    MachineInstr::FrameDestroy);
   else if (NumBytes)
     emitFrameOffset(MBB, LastPopI, DL, AArch64::SP, AArch64::SP, NumBytes, TII,
                     MachineInstr::FrameDestroy);
@@ -845,7 +855,11 @@ int AArch64FrameLowering::resolveFrameIndexReference(c
   const AArch64RegisterInfo *RegInfo = static_cast<const AArch64RegisterInfo 
*>(
       MF.getSubtarget().getRegisterInfo());
   const AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
-  int FPOffset = MFI.getObjectOffset(FI) + 16;
+  const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>();
+  bool IsWin64 =
+      Subtarget.isCallingConvWin64(MF.getFunction()->getCallingConv());
+  unsigned FixedObject = IsWin64 ? alignTo(AFI->getVarArgsGPRSize(), 16) : 0;
+  int FPOffset = MFI.getObjectOffset(FI) + FixedObject + 16;
   int Offset = MFI.getObjectOffset(FI) + MFI.getStackSize();
   bool isFixed = MFI.isFixedObjectIndex(FI);
 
@@ -955,12 +969,6 @@ static void computeCalleeSaveRegisterPairs(
           (Count & 1) == 0) &&
          "Odd number of callee-saved regs to spill!");
   int Offset = AFI->getCalleeSavedStackSize();
-
-  unsigned GPRSaveSize = AFI->getVarArgsGPRSize();
-  const AArch64Subtarget &Subtarget = MF.getSubtarget<AArch64Subtarget>();
-  bool IsWin64 = 
Subtarget.isCallingConvWin64(MF.getFunction()->getCallingConv());
-  if (IsWin64)
-    Offset -= alignTo(GPRSaveSize, 16);
 
   for (unsigned i = 0; i < Count; ++i) {
     RegPairInfo RPI;

Modified: head/contrib/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
==============================================================================
--- head/contrib/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp        Wed Aug 
 9 16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Target/AArch64/AArch64ISelLowering.cpp        Wed Aug 
 9 17:32:39 2017        (r322320)
@@ -9586,8 +9586,8 @@ static bool performTBISimplification(SDValue Addr,
                                      SelectionDAG &DAG) {
   APInt DemandedMask = APInt::getLowBitsSet(64, 56);
   KnownBits Known;
-  TargetLowering::TargetLoweringOpt TLO(DAG, DCI.isBeforeLegalize(),
-                                        DCI.isBeforeLegalizeOps());
+  TargetLowering::TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(),
+                                        !DCI.isBeforeLegalizeOps());
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   if (TLI.SimplifyDemandedBits(Addr, DemandedMask, Known, TLO)) {
     DCI.CommitTargetLoweringOpt(TLO);

Modified: head/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.td
==============================================================================
--- head/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.td    Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Target/AArch64/AArch64InstrInfo.td    Wed Aug  9 
17:32:39 2017        (r322320)
@@ -37,6 +37,9 @@ def HasFullFP16      : Predicate<"Subtarget->hasFullFP
                                  AssemblerPredicate<"FeatureFullFP16", 
"fullfp16">;
 def HasSPE           : Predicate<"Subtarget->hasSPE()">,
                                  AssemblerPredicate<"FeatureSPE", "spe">;
+def HasFuseAES       : Predicate<"Subtarget->hasFuseAES()">,
+                                 AssemblerPredicate<"FeatureFuseAES",
+                                 "fuse-aes">;
 def HasSVE           : Predicate<"Subtarget->hasSVE()">,
                                  AssemblerPredicate<"FeatureSVE", "sve">;
 
@@ -5303,6 +5306,31 @@ def AESErr   : AESTiedInst<0b0100, "aese",   int_aarch
 def AESDrr   : AESTiedInst<0b0101, "aesd",   int_aarch64_crypto_aesd>;
 def AESMCrr  : AESInst<    0b0110, "aesmc",  int_aarch64_crypto_aesmc>;
 def AESIMCrr : AESInst<    0b0111, "aesimc", int_aarch64_crypto_aesimc>;
+
+// Pseudo instructions for AESMCrr/AESIMCrr with a register constraint required
+// for AES fusion on some CPUs.
+let hasSideEffects = 0, mayStore = 0, mayLoad = 0 in {
+def AESMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
+                        Sched<[WriteV]>;
+def AESIMCrrTied: Pseudo<(outs V128:$Rd), (ins V128:$Rn), [], "$Rn = $Rd">,
+                         Sched<[WriteV]>;
+}
+
+// Only use constrained versions of AES(I)MC instructions if they are paired 
with
+// AESE/AESD.
+def : Pat<(v16i8 (int_aarch64_crypto_aesmc
+            (v16i8 (int_aarch64_crypto_aese (v16i8 V128:$src1),
+                                            (v16i8 V128:$src2))))),
+          (v16i8 (AESMCrrTied (v16i8 (AESErr (v16i8 V128:$src1),
+                                             (v16i8 V128:$src2)))))>,
+          Requires<[HasFuseAES]>;
+
+def : Pat<(v16i8 (int_aarch64_crypto_aesimc
+            (v16i8 (int_aarch64_crypto_aesd (v16i8 V128:$src1),
+                                            (v16i8 V128:$src2))))),
+          (v16i8 (AESIMCrrTied (v16i8 (AESDrr (v16i8 V128:$src1),
+                                              (v16i8 V128:$src2)))))>,
+          Requires<[HasFuseAES]>;
 
 def SHA1Crrr     : SHATiedInstQSV<0b000, "sha1c",   int_aarch64_crypto_sha1c>;
 def SHA1Prrr     : SHATiedInstQSV<0b001, "sha1p",   int_aarch64_crypto_sha1p>;

Modified: head/contrib/llvm/lib/Target/AArch64/AArch64MacroFusion.cpp
==============================================================================
--- head/contrib/llvm/lib/Target/AArch64/AArch64MacroFusion.cpp Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Target/AArch64/AArch64MacroFusion.cpp Wed Aug  9 
17:32:39 2017        (r322320)
@@ -118,11 +118,13 @@ static bool shouldScheduleAdjacent(const TargetInstrIn
     // Fuse AES crypto operations.
     switch(SecondOpcode) {
     // AES encode.
-    case AArch64::AESMCrr :
+    case AArch64::AESMCrr:
+    case AArch64::AESMCrrTied:
       return FirstOpcode == AArch64::AESErr ||
              FirstOpcode == AArch64::INSTRUCTION_LIST_END;
     // AES decode.
     case AArch64::AESIMCrr:
+    case AArch64::AESIMCrrTied:
       return FirstOpcode == AArch64::AESDrr ||
              FirstOpcode == AArch64::INSTRUCTION_LIST_END;
     }

Modified: head/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp
==============================================================================
--- head/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp        Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Target/X86/X86ISelLowering.cpp        Wed Aug  9 
17:32:39 2017        (r322320)
@@ -3984,6 +3984,13 @@ bool MatchingStackOffset(SDValue Arg, unsigned Offset,
   if (Offset != MFI.getObjectOffset(FI))
     return false;
 
+  // If this is not byval, check that the argument stack object is immutable.
+  // inalloca and argument copy elision can create mutable argument stack
+  // objects. Byval objects can be mutated, but a byval call intends to pass 
the
+  // mutated memory.
+  if (!Flags.isByVal() && !MFI.isImmutableObjectIndex(FI))
+    return false;
+
   if (VA.getLocVT().getSizeInBits() > Arg.getValueSizeInBits()) {
     // If the argument location is wider than the argument type, check that any
     // extension flags match.
@@ -30605,8 +30612,8 @@ static SDValue combineSelect(SDNode *N, SelectionDAG &
     assert(BitWidth >= 8 && BitWidth <= 64 && "Invalid mask size");
     APInt DemandedMask(APInt::getSignMask(BitWidth));
     KnownBits Known;
-    TargetLowering::TargetLoweringOpt TLO(DAG, DCI.isBeforeLegalize(),
-                                          DCI.isBeforeLegalizeOps());
+    TargetLowering::TargetLoweringOpt TLO(DAG, !DCI.isBeforeLegalize(),
+                                          !DCI.isBeforeLegalizeOps());
     if (TLI.ShrinkDemandedConstant(Cond, DemandedMask, TLO) ||
         TLI.SimplifyDemandedBits(Cond, DemandedMask, Known, TLO)) {
       // If we changed the computation somewhere in the DAG, this change will

Modified: head/contrib/llvm/lib/Target/X86/X86InstrSSE.td
==============================================================================
--- head/contrib/llvm/lib/Target/X86/X86InstrSSE.td     Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/Target/X86/X86InstrSSE.td     Wed Aug  9 17:32:39 
2017        (r322320)
@@ -3697,8 +3697,7 @@ let SchedRW = [WriteNop] in {
 // Pause. This "instruction" is encoded as "rep; nop", so even though it
 // was introduced with SSE2, it's backward compatible.
 def PAUSE : I<0x90, RawFrm, (outs), (ins),
-              "pause", [(int_x86_sse2_pause)], IIC_SSE_PAUSE>,
-              OBXS, Requires<[HasSSE2]>;
+              "pause", [(int_x86_sse2_pause)], IIC_SSE_PAUSE>, OBXS;
 }
 
 let SchedRW = [WriteFence] in {

Modified: head/contrib/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp
==============================================================================
--- head/contrib/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp  Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp  Wed Aug  9 
17:32:39 2017        (r322320)
@@ -356,7 +356,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &
       // Just add all the struct element types.
       Type *AgTy = cast<PointerType>(I->getType())->getElementType();
       Value *TheAlloca = new AllocaInst(AgTy, DL.getAllocaAddrSpace(), nullptr,
-                                        "", InsertPt);
+                                        I->getParamAlignment(), "", InsertPt);
       StructType *STy = cast<StructType>(AgTy);
       Value *Idxs[2] = {ConstantInt::get(Type::getInt32Ty(F->getContext()), 0),
                         nullptr};

Modified: head/contrib/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
==============================================================================
--- head/contrib/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp       
Wed Aug  9 16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp       
Wed Aug  9 17:32:39 2017        (r322320)
@@ -756,7 +756,8 @@ struct FunctionStackPoisoner : public InstVisitor<Func
   bool runOnFunction() {
     if (!ClStack) return false;
 
-    if (ClRedzoneByvalArgs) copyArgsPassedByValToAllocas();
+    if (ClRedzoneByvalArgs && Mapping.Offset != kDynamicShadowSentinel)
+      copyArgsPassedByValToAllocas();
 
     // Collect alloca, ret, lifetime instructions etc.
     for (BasicBlock *BB : depth_first(&F.getEntryBlock())) visit(*BB);

Modified: head/contrib/llvm/lib/Transforms/Scalar/SCCP.cpp
==============================================================================
--- head/contrib/llvm/lib/Transforms/Scalar/SCCP.cpp    Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/lib/Transforms/Scalar/SCCP.cpp    Wed Aug  9 17:32:39 
2017        (r322320)
@@ -1790,7 +1790,8 @@ static bool runIPSCCP(Module &M, const DataLayout &DL,
   // variables that do not have their 'addresses taken'.  If they don't have
   // their addresses taken, we can propagate constants through them.
   for (GlobalVariable &G : M.globals())
-    if (!G.isConstant() && G.hasLocalLinkage() && !AddressIsTaken(&G))
+    if (!G.isConstant() && G.hasLocalLinkage() &&
+        G.hasDefinitiveInitializer() && !AddressIsTaken(&G))
       Solver.TrackValueOfGlobalVariable(&G);
 
   // Solve for constants.

Modified: head/contrib/llvm/lib/Transforms/Utils/CloneModule.cpp
==============================================================================
--- head/contrib/llvm/lib/Transforms/Utils/CloneModule.cpp      Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/lib/Transforms/Utils/CloneModule.cpp      Wed Aug  9 
17:32:39 2017        (r322320)
@@ -132,7 +132,8 @@ std::unique_ptr<Module> llvm::CloneModule(
     SmallVector<std::pair<unsigned, MDNode *>, 1> MDs;
     I->getAllMetadata(MDs);
     for (auto MD : MDs)
-      GV->addMetadata(MD.first, *MapMetadata(MD.second, VMap));
+      GV->addMetadata(MD.first,
+                      *MapMetadata(MD.second, VMap, RF_MoveDistinctMDs));
 
     copyComdat(GV, &*I);
   }

Modified: head/contrib/llvm/tools/clang/include/clang/AST/StmtCXX.h
==============================================================================
--- head/contrib/llvm/tools/clang/include/clang/AST/StmtCXX.h   Wed Aug  9 
16:37:37 2017        (r322319)
+++ head/contrib/llvm/tools/clang/include/clang/AST/StmtCXX.h   Wed Aug  9 
17:32:39 2017        (r322320)
@@ -317,6 +317,7 @@ class CoroutineBodyStmt final
   unsigned NumParams;
 
   friend class ASTStmtReader;
+  friend class ASTReader;
   friend TrailingObjects;
 
   Stmt **getStoredStmts() { return getTrailingObjects<Stmt *>(); }
@@ -347,6 +348,8 @@ class CoroutineBodyStmt final
 
 public:
   static CoroutineBodyStmt *Create(const ASTContext &C, CtorArgs const &Args);
+  static CoroutineBodyStmt *Create(const ASTContext &C, EmptyShell,
+                                   unsigned NumParams);
 
   bool hasDependentPromiseType() const {
     return getPromiseDecl()->getType()->isDependentType();
@@ -443,6 +446,8 @@ class CoreturnStmt : public Stmt { (public)
     SubStmts[SubStmt::Operand] = Operand;
     SubStmts[SubStmt::PromiseCall] = PromiseCall;
   }
+
+  CoreturnStmt(EmptyShell) : CoreturnStmt({}, {}, {}) {}
 
   SourceLocation getKeywordLoc() const { return CoreturnLoc; }
 

Modified: head/contrib/llvm/tools/clang/include/clang/Basic/BuiltinsX86.def
==============================================================================
--- head/contrib/llvm/tools/clang/include/clang/Basic/BuiltinsX86.def   Wed Aug 
 9 16:37:37 2017        (r322319)
+++ head/contrib/llvm/tools/clang/include/clang/Basic/BuiltinsX86.def   Wed Aug 
 9 17:32:39 2017        (r322320)
@@ -338,8 +338,8 @@ TARGET_BUILTIN(__builtin_ia32_lfence, "v", "", "sse2")
 TARGET_HEADER_BUILTIN(_mm_lfence, "v", "h", "emmintrin.h", ALL_LANGUAGES, 
"sse2")
 TARGET_BUILTIN(__builtin_ia32_mfence, "v", "", "sse2")
 TARGET_HEADER_BUILTIN(_mm_mfence, "v", "h", "emmintrin.h", ALL_LANGUAGES, 
"sse2")
-TARGET_BUILTIN(__builtin_ia32_pause, "v", "", "sse2")
-TARGET_HEADER_BUILTIN(_mm_pause, "v", "h", "emmintrin.h", ALL_LANGUAGES, 
"sse2")
+TARGET_BUILTIN(__builtin_ia32_pause, "v", "", "")
+TARGET_HEADER_BUILTIN(_mm_pause, "v", "h", "emmintrin.h", ALL_LANGUAGES, "")
 TARGET_BUILTIN(__builtin_ia32_pmuludq128, "V2LLiV4iV4i", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psraw128, "V8sV8sV8s", "", "sse2")
 TARGET_BUILTIN(__builtin_ia32_psrad128, "V4iV4iV4i", "", "sse2")

Modified: head/contrib/llvm/tools/clang/include/clang/Driver/Options.td
==============================================================================
--- head/contrib/llvm/tools/clang/include/clang/Driver/Options.td       Wed Aug 
 9 16:37:37 2017        (r322319)
+++ head/contrib/llvm/tools/clang/include/clang/Driver/Options.td       Wed Aug 
 9 17:32:39 2017        (r322320)
@@ -2019,10 +2019,6 @@ def mdspr2 : Flag<["-"], "mdspr2">, Group<m_Group>;
 def mno_dspr2 : Flag<["-"], "mno-dspr2">, Group<m_Group>;
 def msingle_float : Flag<["-"], "msingle-float">, Group<m_Group>;
 def mdouble_float : Flag<["-"], "mdouble-float">, Group<m_Group>;
-def mmadd4 : Flag<["-"], "mmadd4">, Group<m_Group>,
-  HelpText<"Enable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
-def mno_madd4 : Flag<["-"], "mno-madd4">, Group<m_Group>,
-  HelpText<"Disable the generation of 4-operand madd.s, madd.d and related 
instructions.">;
 def mmsa : Flag<["-"], "mmsa">, Group<m_Group>,
   HelpText<"Enable MSA ASE (MIPS only)">;
 def mno_msa : Flag<["-"], "mno-msa">, Group<m_Group>,

Modified: 
head/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h
==============================================================================
--- head/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h     
Wed Aug  9 16:37:37 2017        (r322319)
+++ head/contrib/llvm/tools/clang/include/clang/Serialization/ASTBitCodes.h     
Wed Aug  9 17:32:39 2017        (r322320)
@@ -1545,9 +1545,14 @@ namespace clang {
 
       // ARC
       EXPR_OBJC_BRIDGED_CAST,     // ObjCBridgedCastExpr
-      
+
       STMT_MS_DEPENDENT_EXISTS,   // MSDependentExistsStmt
-      EXPR_LAMBDA                 // LambdaExpr
+      EXPR_LAMBDA,                // LambdaExpr
+      STMT_COROUTINE_BODY,
+      STMT_CORETURN,
+      EXPR_COAWAIT,
+      EXPR_COYIELD,
+      EXPR_DEPENDENT_COAWAIT,
     };
 
     /// \brief The kinds of designators that can occur in a

Modified: head/contrib/llvm/tools/clang/lib/AST/ODRHash.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/AST/ODRHash.cpp   Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/tools/clang/lib/AST/ODRHash.cpp   Wed Aug  9 17:32:39 
2017        (r322320)
@@ -378,8 +378,12 @@ void ODRHash::AddCXXRecordDecl(const CXXRecordDecl *Re
   assert(Record && Record->hasDefinition() &&
          "Expected non-null record to be a definition.");
 
-  if (isa<ClassTemplateSpecializationDecl>(Record)) {
-    return;
+  const DeclContext *DC = Record;
+  while (DC) {
+    if (isa<ClassTemplateSpecializationDecl>(DC)) {
+      return;
+    }
+    DC = DC->getParent();
   }
 
   AddDecl(Record);

Modified: head/contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp   Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/tools/clang/lib/AST/StmtCXX.cpp   Wed Aug  9 17:32:39 
2017        (r322320)
@@ -96,6 +96,20 @@ CoroutineBodyStmt *CoroutineBodyStmt::Create(
   return new (Mem) CoroutineBodyStmt(Args);
 }
 
+CoroutineBodyStmt *CoroutineBodyStmt::Create(const ASTContext &C, EmptyShell,
+                                             unsigned NumParams) {
+  std::size_t Size = totalSizeToAlloc<Stmt *>(
+      CoroutineBodyStmt::FirstParamMove + NumParams);
+
+  void *Mem = C.Allocate(Size, alignof(CoroutineBodyStmt));
+  auto *Result = new (Mem) CoroutineBodyStmt(CtorArgs());
+  Result->NumParams = NumParams;
+  auto *ParamBegin = Result->getStoredStmts() + SubStmt::FirstParamMove;
+  std::uninitialized_fill(ParamBegin, ParamBegin + NumParams,
+                          static_cast<Stmt *>(nullptr));
+  return Result;
+}
+
 CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const &Args)
     : Stmt(CoroutineBodyStmtClass), NumParams(Args.ParamMoves.size()) {
   Stmt **SubStmts = getStoredStmts();

Modified: head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp Wed Aug  9 16:37:37 
2017        (r322319)
+++ head/contrib/llvm/tools/clang/lib/Basic/Targets.cpp Wed Aug  9 17:32:39 
2017        (r322320)
@@ -8050,7 +8050,6 @@ class MipsTargetInfo : public TargetInfo {
     NoDSP, DSP1, DSP2
   } DspRev;
   bool HasMSA;
-  bool DisableMadd4;
 
 protected:
   bool HasFP64;
@@ -8061,7 +8060,7 @@ class MipsTargetInfo : public TargetInfo {
       : TargetInfo(Triple), IsMips16(false), IsMicromips(false),
         IsNan2008(false), IsSingleFloat(false), IsNoABICalls(false),
         CanUseBSDABICalls(false), FloatABI(HardFloat), DspRev(NoDSP),
-        HasMSA(false), DisableMadd4(false), HasFP64(false) {
+        HasMSA(false), HasFP64(false) {
     TheCXXABI.set(TargetCXXABI::GenericMIPS);
 
     setABI((getTriple().getArch() == llvm::Triple::mips ||
@@ -8307,9 +8306,6 @@ class MipsTargetInfo : public TargetInfo {
     if (HasMSA)
       Builder.defineMacro("__mips_msa", Twine(1));
 
-    if (DisableMadd4)
-      Builder.defineMacro("__mips_no_madd4", Twine(1));
-
     Builder.defineMacro("_MIPS_SZPTR", Twine(getPointerWidth(0)));
     Builder.defineMacro("_MIPS_SZINT", Twine(getIntWidth()));
     Builder.defineMacro("_MIPS_SZLONG", Twine(getLongWidth()));

*** DIFF OUTPUT TRUNCATED AT 1000 LINES ***
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to