Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Dec 2017 18:06:30 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r326909 - in head: contrib/llvm/lib/Target/BPF contrib/llvm/lib/Transforms/Scalar contrib/llvm/tools/clang/lib/Basic contrib/llvm/tools/clang/lib/Sema contrib/llvm/tools/lld/lib/ReaderW...
Message-ID:  <201712161806.vBGI6UX2016281@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sat Dec 16 18:06:30 2017
New Revision: 326909
URL: https://svnweb.freebsd.org/changeset/base/326909

Log:
  Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
  5.0.1 release (upstream r320880).
  
  Relnotes:	yes
  MFC after:	2 weeks

Modified:
  head/contrib/llvm/lib/Target/BPF/BPFISelLowering.cpp
  head/contrib/llvm/lib/Target/BPF/BPFInstrInfo.td
  head/contrib/llvm/lib/Transforms/Scalar/NewGVN.cpp
  head/contrib/llvm/tools/clang/lib/Basic/Version.cpp
  head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp
  head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp
  head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h
  head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
  head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
  head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
  head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
  head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.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/llvm/lib/Target/BPF/BPFISelLowering.cpp
==============================================================================
--- head/contrib/llvm/lib/Target/BPF/BPFISelLowering.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/lib/Target/BPF/BPFISelLowering.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -578,11 +578,15 @@ BPFTargetLowering::EmitInstrWithCustomInserter(Machine
         .addReg(LHS)
         .addReg(MI.getOperand(2).getReg())
         .addMBB(Copy1MBB);
-  else
+  else {
+    int64_t imm32 = MI.getOperand(2).getImm();
+    // sanity check before we build J*_ri instruction.
+    assert (isInt<32>(imm32));
     BuildMI(BB, DL, TII.get(NewCC))
         .addReg(LHS)
-        .addImm(MI.getOperand(2).getImm())
+        .addImm(imm32)
         .addMBB(Copy1MBB);
+  }
 
   // Copy0MBB:
   //  %FalseValue = ...

Modified: head/contrib/llvm/lib/Target/BPF/BPFInstrInfo.td
==============================================================================
--- head/contrib/llvm/lib/Target/BPF/BPFInstrInfo.td	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/lib/Target/BPF/BPFInstrInfo.td	Sat Dec 16 18:06:30 2017	(r326909)
@@ -464,7 +464,7 @@ let usesCustomInserter = 1 in {
                       (ins GPR:$lhs, i64imm:$rhs, i64imm:$imm, GPR:$src, GPR:$src2),
                       "# Select PSEUDO $dst = $lhs $imm $rhs ? $src : $src2",
                       [(set i64:$dst,
-                       (BPFselectcc i64:$lhs, (i64 imm:$rhs), (i64 imm:$imm), i64:$src, i64:$src2))]>;
+                       (BPFselectcc i64:$lhs, (i64 i64immSExt32:$rhs), (i64 imm:$imm), i64:$src, i64:$src2))]>;
 }
 
 // load 64-bit global addr into register

Modified: head/contrib/llvm/lib/Transforms/Scalar/NewGVN.cpp
==============================================================================
--- head/contrib/llvm/lib/Transforms/Scalar/NewGVN.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/lib/Transforms/Scalar/NewGVN.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -586,8 +586,8 @@ class NewGVN { (public)
 private:
   // Expression handling.
   const Expression *createExpression(Instruction *) const;
-  const Expression *createBinaryExpression(unsigned, Type *, Value *,
-                                           Value *) const;
+  const Expression *createBinaryExpression(unsigned, Type *, Value *, Value *,
+                                           Instruction *) const;
   PHIExpression *createPHIExpression(Instruction *, bool &HasBackEdge,
                                      bool &OriginalOpsConstant) const;
   const DeadExpression *createDeadExpression() const;
@@ -902,8 +902,8 @@ bool NewGVN::setBasicExpressionInfo(Instruction *I, Ba
 }
 
 const Expression *NewGVN::createBinaryExpression(unsigned Opcode, Type *T,
-                                                 Value *Arg1,
-                                                 Value *Arg2) const {
+                                                 Value *Arg1, Value *Arg2,
+                                                 Instruction *I) const {
   auto *E = new (ExpressionAllocator) BasicExpression(2);
 
   E->setType(T);
@@ -921,7 +921,7 @@ const Expression *NewGVN::createBinaryExpression(unsig
   E->op_push_back(lookupOperandLeader(Arg2));
 
   Value *V = SimplifyBinOp(Opcode, E->getOperand(0), E->getOperand(1), SQ);
-  if (const Expression *SimplifiedE = checkSimplificationResults(E, nullptr, V))
+  if (const Expression *SimplifiedE = checkSimplificationResults(E, I, V))
     return SimplifiedE;
   return E;
 }
@@ -1699,8 +1699,9 @@ NewGVN::performSymbolicAggrValueEvaluation(Instruction
         // expression.
         assert(II->getNumArgOperands() == 2 &&
                "Expect two args for recognised intrinsics.");
-        return createBinaryExpression(
-            Opcode, EI->getType(), II->getArgOperand(0), II->getArgOperand(1));
+        return createBinaryExpression(Opcode, EI->getType(),
+                                      II->getArgOperand(0),
+                                      II->getArgOperand(1), I);
       }
     }
   }
@@ -1933,6 +1934,7 @@ void NewGVN::touchAndErase(Map &M, const KeyType &Key)
 }
 
 void NewGVN::addAdditionalUsers(Value *To, Value *User) const {
+  assert(User && To != User);
   if (isa<Instruction>(To))
     AdditionalUsers[To].insert(User);
 }

Modified: head/contrib/llvm/tools/clang/lib/Basic/Version.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/Basic/Version.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/clang/lib/Basic/Version.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -36,7 +36,7 @@ std::string getClangRepositoryPath() {
 
   // If the SVN_REPOSITORY is empty, try to use the SVN keyword. This helps us
   // pick up a tag in an SVN export, for example.
-  StringRef SVNRepository("$URL: https://llvm.org/svn/llvm-project/cfe/branches/release_50/lib/Basic/Version.cpp $");
+  StringRef SVNRepository("$URL: https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_501/final/lib/Basic/Version.cpp $");
   if (URL.empty()) {
     URL = SVNRepository.slice(SVNRepository.find(':'),
                               SVNRepository.find("/lib/Basic"));

Modified: head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/clang/lib/Sema/SemaDecl.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -1603,7 +1603,24 @@ static bool ShouldDiagnoseUnusedDecl(const NamedDecl *
   if (D->isInvalidDecl())
     return false;
 
-  if (D->isReferenced() || D->isUsed() || D->hasAttr<UnusedAttr>() ||
+  bool Referenced = false;
+  if (auto *DD = dyn_cast<DecompositionDecl>(D)) {
+    // For a decomposition declaration, warn if none of the bindings are
+    // referenced, instead of if the variable itself is referenced (which
+    // it is, by the bindings' expressions).
+    for (auto *BD : DD->bindings()) {
+      if (BD->isReferenced()) {
+        Referenced = true;
+        break;
+      }
+    }
+  } else if (!D->getDeclName()) {
+    return false;
+  } else if (D->isReferenced() || D->isUsed()) {
+    Referenced = true;
+  }
+
+  if (Referenced || D->hasAttr<UnusedAttr>() ||
       D->hasAttr<ObjCPreciseLifetimeAttr>())
     return false;
 
@@ -1726,7 +1743,7 @@ void Sema::DiagnoseUnusedDecl(const NamedDecl *D) {
   else
     DiagID = diag::warn_unused_variable;
 
-  Diag(D->getLocation(), DiagID) << D->getDeclName() << Hint;
+  Diag(D->getLocation(), DiagID) << D << Hint;
 }
 
 static void CheckPoppedLabel(LabelDecl *L, Sema &S) {
@@ -1756,8 +1773,6 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S)
     assert(isa<NamedDecl>(TmpD) && "Decl isn't NamedDecl?");
     NamedDecl *D = cast<NamedDecl>(TmpD);
 
-    if (!D->getDeclName()) continue;
-
     // Diagnose unused variables in this scope.
     if (!S->hasUnrecoverableErrorOccurred()) {
       DiagnoseUnusedDecl(D);
@@ -1765,6 +1780,8 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S)
         DiagnoseUnusedNestedTypedefs(RD);
     }
 
+    if (!D->getDeclName()) continue;
+
     // If this was a forward reference to a label, verify it was defined.
     if (LabelDecl *LD = dyn_cast<LabelDecl>(D))
       CheckPoppedLabel(LD, *this);
@@ -6155,7 +6172,6 @@ NamedDecl *Sema::ActOnVariableDeclarator(
   IdentifierInfo *II = Name.getAsIdentifierInfo();
 
   if (D.isDecompositionDeclarator()) {
-    AddToScope = false;
     // Take the name of the first declarator as our name for diagnostic
     // purposes.
     auto &Decomp = D.getDecompositionDeclarator();

Modified: head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/clang/lib/Sema/SemaDeclCXX.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -826,7 +826,10 @@ Sema::ActOnDecompositionDeclarator(Scope *S, Declarato
   NamedDecl *New =
       ActOnVariableDeclarator(S, D, DC, TInfo, Previous,
                               MultiTemplateParamsArg(), AddToScope, Bindings);
-  CurContext->addHiddenDecl(New);
+  if (AddToScope) {
+    S->AddDecl(New);
+    CurContext->addHiddenDecl(New);
+  }
 
   if (isInOpenMPDeclareTargetContext())
     checkDeclIsAllowedInOpenMPTarget(nullptr, New);

Modified: head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
==============================================================================
--- head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -677,6 +677,7 @@ TemplateDeclInstantiator::VisitTypeAliasTemplateDecl(T
 Decl *TemplateDeclInstantiator::VisitBindingDecl(BindingDecl *D) {
   auto *NewBD = BindingDecl::Create(SemaRef.Context, Owner, D->getLocation(),
                                     D->getIdentifier());
+  NewBD->setReferenced(D->isReferenced());
   SemaRef.CurrentInstantiationScope->InstantiatedLocal(D, NewBD);
   return NewBD;
 }

Modified: head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h
==============================================================================
--- head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler.h	Sat Dec 16 18:06:30 2017	(r326909)
@@ -112,6 +112,10 @@ class ArchHandler { (public)
   /// info in final executables.
   virtual bool isLazyPointer(const Reference &);
 
+  /// Reference from an __stub_helper entry to the required offset of the
+  /// lazy bind commands.
+  virtual Reference::KindValue lazyImmediateLocationKind() = 0;
+
   /// Returns true if the specified relocation is paired to the next relocation.
   virtual bool isPairedReloc(const normalized::Relocation &) = 0;
 

Modified: head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -67,6 +67,10 @@ class ArchHandler_arm : public ArchHandler { (public)
     return invalid;
   }
 
+  Reference::KindValue lazyImmediateLocationKind() override {
+    return lazyImmediateLocation;
+  }
+
   Reference::KindValue pointerKind() override {
     return invalid;
   }

Modified: head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_arm64.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -127,6 +127,10 @@ class ArchHandler_arm64 : public ArchHandler { (public
     return pointer64;
   }
 
+  Reference::KindValue lazyImmediateLocationKind() override {
+    return lazyImmediateLocation;
+  }
+
   uint32_t dwarfCompactUnwindType() override {
     return 0x03000000;
   }

Modified: head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -70,6 +70,10 @@ class ArchHandler_x86 : public ArchHandler { (public)
     return delta32;
   }
 
+  Reference::KindValue lazyImmediateLocationKind() override {
+    return lazyImmediateLocation;
+  }
+
   Reference::KindValue unwindRefToEhFrameKind() override {
     return invalid;
   }

Modified: head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -116,6 +116,10 @@ class ArchHandler_x86_64 : public ArchHandler { (publi
     return unwindFDEToFunction;
   }
 
+  Reference::KindValue lazyImmediateLocationKind() override {
+    return lazyImmediateLocation;
+  }
+
   Reference::KindValue unwindRefToEhFrameKind() override {
     return unwindInfoToEhFrame;
   }

Modified: head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
==============================================================================
--- head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/contrib/llvm/tools/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp	Sat Dec 16 18:06:30 2017	(r326909)
@@ -172,6 +172,8 @@ class Util { (private)
                                    SymbolScope &symbolScope);
   void         appendSection(SectionInfo *si, NormalizedFile &file);
   uint32_t     sectionIndexForAtom(const Atom *atom);
+  void fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
+                           NormalizedFile &file);
 
   typedef llvm::DenseMap<const Atom*, uint32_t> AtomToIndex;
   struct AtomAndIndex { const Atom *atom; uint32_t index; SymbolScope scope; };
@@ -1423,6 +1425,8 @@ void Util::addRebaseAndBindingInfo(const lld::File &at
 
   uint8_t segmentIndex;
   uint64_t segmentStartAddr;
+  uint32_t offsetInBindInfo = 0;
+
   for (SectionInfo *sect : _sectionInfos) {
     segIndexForSection(sect, segmentIndex, segmentStartAddr);
     for (const AtomInfo &info : sect->atomsAndOffsets) {
@@ -1467,6 +1471,59 @@ void Util::addRebaseAndBindingInfo(const lld::File &at
           bind.symbolName = targ->name();
           bind.addend = ref->addend();
           nFile.lazyBindingInfo.push_back(bind);
+
+          // Now that we know the segmentOffset and the ordinal attribute,
+          // we can fix the helper's code
+
+          fixLazyReferenceImm(atom, offsetInBindInfo, nFile);
+
+          // 5 bytes for opcodes + variable sizes (target name + \0 and offset
+          // encode's size)
+          offsetInBindInfo +=
+              6 + targ->name().size() + llvm::getULEB128Size(bind.segOffset);
+          if (bind.ordinal > BIND_IMMEDIATE_MASK)
+            offsetInBindInfo += llvm::getULEB128Size(bind.ordinal);
+        }
+      }
+    }
+  }
+}
+
+void Util::fixLazyReferenceImm(const DefinedAtom *atom, uint32_t offset,
+                               NormalizedFile &file) {
+  for (const auto &ref : *atom) {
+    const DefinedAtom *da = dyn_cast<DefinedAtom>(ref->target());
+    if (da == nullptr)
+      return;
+
+    const Reference *helperRef = nullptr;
+    for (const Reference *hr : *da) {
+      if (hr->kindValue() == _archHandler.lazyImmediateLocationKind()) {
+        helperRef = hr;
+        break;
+      }
+    }
+    if (helperRef == nullptr)
+      continue;
+
+    // TODO: maybe get the fixed atom content from _archHandler ?
+    for (SectionInfo *sectInfo : _sectionInfos) {
+      for (const AtomInfo &atomInfo : sectInfo->atomsAndOffsets) {
+        if (atomInfo.atom == helperRef->target()) {
+          auto sectionContent =
+              file.sections[sectInfo->normalizedSectionIndex].content;
+          uint8_t *rawb =
+              file.ownedAllocations.Allocate<uint8_t>(sectionContent.size());
+          llvm::MutableArrayRef<uint8_t> newContent{rawb,
+                                                    sectionContent.size()};
+          std::copy(sectionContent.begin(), sectionContent.end(),
+                    newContent.begin());
+          llvm::support::ulittle32_t *loc =
+              reinterpret_cast<llvm::support::ulittle32_t *>(
+                  &newContent[atomInfo.offsetInSection +
+                              helperRef->offsetInAtom()]);
+          *loc = offset;
+          file.sections[sectInfo->normalizedSectionIndex].content = newContent;
         }
       }
     }

Modified: head/lib/clang/include/clang/Basic/Version.inc
==============================================================================
--- head/lib/clang/include/clang/Basic/Version.inc	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/lib/clang/include/clang/Basic/Version.inc	Sat Dec 16 18:06:30 2017	(r326909)
@@ -8,4 +8,4 @@
 
 #define	CLANG_VENDOR			"FreeBSD "
 
-#define	SVN_REVISION			"319231"
+#define	SVN_REVISION			"320880"

Modified: head/lib/clang/include/lld/Config/Version.inc
==============================================================================
--- head/lib/clang/include/lld/Config/Version.inc	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/lib/clang/include/lld/Config/Version.inc	Sat Dec 16 18:06:30 2017	(r326909)
@@ -4,5 +4,5 @@
 #define LLD_VERSION_STRING "5.0.1"
 #define LLD_VERSION_MAJOR 5
 #define LLD_VERSION_MINOR 0
-#define LLD_REVISION_STRING "319231"
+#define LLD_REVISION_STRING "320880"
 #define LLD_REPOSITORY_STRING "FreeBSD"

Modified: head/lib/clang/include/llvm/Support/VCSRevision.h
==============================================================================
--- head/lib/clang/include/llvm/Support/VCSRevision.h	Sat Dec 16 15:17:54 2017	(r326908)
+++ head/lib/clang/include/llvm/Support/VCSRevision.h	Sat Dec 16 18:06:30 2017	(r326909)
@@ -1,2 +1,2 @@
 /* $FreeBSD$ */
-#define LLVM_REVISION "svn-r319231"
+#define LLVM_REVISION "svn-r320880"



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