Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 5 Feb 2017 19:57:42 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r313300 - in projects/clang400-import: contrib/libc++/include contrib/llvm/lib/CodeGen/SelectionDAG contrib/llvm/lib/Transforms/InstCombine contrib/llvm/lib/Transforms/Scalar contrib/ll...
Message-ID:  <201702051957.v15JvgSt047389@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sun Feb  5 19:57:41 2017
New Revision: 313300
URL: https://svnweb.freebsd.org/changeset/base/313300

Log:
  Merge llvm, clang, compiler-rt, libc++, lld and lldb release_40 branch
  r294123, and update build glue.

Modified:
  projects/clang400-import/contrib/libc++/include/__tree
  projects/clang400-import/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  projects/clang400-import/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
  projects/clang400-import/contrib/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
  projects/clang400-import/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp
  projects/clang400-import/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h
  projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
  projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
  projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
  projects/clang400-import/contrib/llvm/tools/lld/ELF/Config.h
  projects/clang400-import/contrib/llvm/tools/lld/ELF/Driver.cpp
  projects/clang400-import/contrib/llvm/tools/lld/ELF/Options.td
  projects/clang400-import/contrib/llvm/tools/lld/ELF/Symbols.cpp
  projects/clang400-import/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp
  projects/clang400-import/contrib/llvm/tools/lld/ELF/Writer.cpp
  projects/clang400-import/contrib/llvm/tools/llvm-objdump/ELFDump.cpp
  projects/clang400-import/lib/clang/include/clang/Basic/Version.inc
  projects/clang400-import/lib/clang/include/lld/Config/Version.inc
Directory Properties:
  projects/clang400-import/contrib/compiler-rt/   (props changed)
  projects/clang400-import/contrib/libc++/   (props changed)
  projects/clang400-import/contrib/llvm/   (props changed)
  projects/clang400-import/contrib/llvm/tools/clang/   (props changed)
  projects/clang400-import/contrib/llvm/tools/lld/   (props changed)
  projects/clang400-import/contrib/llvm/tools/lldb/   (props changed)

Modified: projects/clang400-import/contrib/libc++/include/__tree
==============================================================================
--- projects/clang400-import/contrib/libc++/include/__tree	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/libc++/include/__tree	Sun Feb  5 19:57:41 2017	(r313300)
@@ -17,6 +17,8 @@
 #include <stdexcept>
 #include <algorithm>
 
+#include <__undef_min_max>
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif

Modified: projects/clang400-import/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -8123,9 +8123,12 @@ SDValue DAGCombiner::visitFADDForFMAComb
   }
 
   // More folding opportunities when target permits.
-  if ((AllowFusion || HasFMAD)  && Aggressive) {
+  if (Aggressive) {
     // fold (fadd (fma x, y, (fmul u, v)), z) -> (fma x, y (fma u, v, z))
-    if (N0.getOpcode() == PreferredFusedOpcode &&
+    // FIXME: The UnsafeAlgebra flag should be propagated to FMA/FMAD, but FMF
+    // are currently only supported on binary nodes.
+    if (Options.UnsafeFPMath &&
+        N0.getOpcode() == PreferredFusedOpcode &&
         N0.getOperand(2).getOpcode() == ISD::FMUL &&
         N0->hasOneUse() && N0.getOperand(2)->hasOneUse()) {
       return DAG.getNode(PreferredFusedOpcode, SL, VT,
@@ -8137,7 +8140,10 @@ SDValue DAGCombiner::visitFADDForFMAComb
     }
 
     // fold (fadd x, (fma y, z, (fmul u, v)) -> (fma y, z (fma u, v, x))
-    if (N1->getOpcode() == PreferredFusedOpcode &&
+    // FIXME: The UnsafeAlgebra flag should be propagated to FMA/FMAD, but FMF
+    // are currently only supported on binary nodes.
+    if (Options.UnsafeFPMath &&
+        N1->getOpcode() == PreferredFusedOpcode &&
         N1.getOperand(2).getOpcode() == ISD::FMUL &&
         N1->hasOneUse() && N1.getOperand(2)->hasOneUse()) {
       return DAG.getNode(PreferredFusedOpcode, SL, VT,
@@ -8367,10 +8373,13 @@ SDValue DAGCombiner::visitFSUBForFMAComb
   }
 
   // More folding opportunities when target permits.
-  if ((AllowFusion || HasFMAD) && Aggressive) {
+  if (Aggressive) {
     // fold (fsub (fma x, y, (fmul u, v)), z)
     //   -> (fma x, y (fma u, v, (fneg z)))
-    if (N0.getOpcode() == PreferredFusedOpcode &&
+    // FIXME: The UnsafeAlgebra flag should be propagated to FMA/FMAD, but FMF
+    // are currently only supported on binary nodes.
+    if (Options.UnsafeFPMath &&
+        N0.getOpcode() == PreferredFusedOpcode &&
         N0.getOperand(2).getOpcode() == ISD::FMUL &&
         N0->hasOneUse() && N0.getOperand(2)->hasOneUse()) {
       return DAG.getNode(PreferredFusedOpcode, SL, VT,
@@ -8384,7 +8393,10 @@ SDValue DAGCombiner::visitFSUBForFMAComb
 
     // fold (fsub x, (fma y, z, (fmul u, v)))
     //   -> (fma (fneg y), z, (fma (fneg u), v, x))
-    if (N1.getOpcode() == PreferredFusedOpcode &&
+    // FIXME: The UnsafeAlgebra flag should be propagated to FMA/FMAD, but FMF
+    // are currently only supported on binary nodes.
+    if (Options.UnsafeFPMath &&
+        N1.getOpcode() == PreferredFusedOpcode &&
         N1.getOperand(2).getOpcode() == ISD::FMUL) {
       SDValue N20 = N1.getOperand(2).getOperand(0);
       SDValue N21 = N1.getOperand(2).getOperand(1);

Modified: projects/clang400-import/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -4039,11 +4039,6 @@ Instruction *InstCombiner::foldICmpUsing
         Constant *CMinus1 = ConstantInt::get(Op0->getType(), *CmpC - 1);
         return new ICmpInst(ICmpInst::ICMP_EQ, Op0, CMinus1);
       }
-      // (x <u 2147483648) -> (x >s -1)  -> true if sign bit clear
-      if (CmpC->isMinSignedValue()) {
-        Constant *AllOnes = Constant::getAllOnesValue(Op0->getType());
-        return new ICmpInst(ICmpInst::ICMP_SGT, Op0, AllOnes);
-      }
     }
     break;
   }
@@ -4063,11 +4058,6 @@ Instruction *InstCombiner::foldICmpUsing
       if (*CmpC == Op0Max - 1)
         return new ICmpInst(ICmpInst::ICMP_EQ, Op0,
                             ConstantInt::get(Op1->getType(), *CmpC + 1));
-
-      // (x >u 2147483647) -> (x <s 0)  -> true if sign bit set
-      if (CmpC->isMaxSignedValue())
-        return new ICmpInst(ICmpInst::ICMP_SLT, Op0,
-                            Constant::getNullValue(Op0->getType()));
     }
     break;
   }
@@ -4299,6 +4289,27 @@ Instruction *InstCombiner::visitICmpInst
           (SI->getOperand(2) == Op0 && SI->getOperand(1) == Op1))
         return nullptr;
 
+  // FIXME: We only do this after checking for min/max to prevent infinite
+  // looping caused by a reverse canonicalization of these patterns for min/max.
+  // FIXME: The organization of folds is a mess. These would naturally go into
+  // canonicalizeCmpWithConstant(), but we can't move all of the above folds
+  // down here after the min/max restriction.
+  ICmpInst::Predicate Pred = I.getPredicate();
+  const APInt *C;
+  if (match(Op1, m_APInt(C))) {
+    // For i32: x >u 2147483647 -> x <s 0  -> true if sign bit set
+    if (Pred == ICmpInst::ICMP_UGT && C->isMaxSignedValue()) {
+      Constant *Zero = Constant::getNullValue(Op0->getType());
+      return new ICmpInst(ICmpInst::ICMP_SLT, Op0, Zero);
+    }
+
+    // For i32: x <u 2147483648 -> x >s -1  -> true if sign bit clear
+    if (Pred == ICmpInst::ICMP_ULT && C->isMinSignedValue()) {
+      Constant *AllOnes = Constant::getAllOnesValue(Op0->getType());
+      return new ICmpInst(ICmpInst::ICMP_SGT, Op0, AllOnes);
+    }
+  }
+
   if (Instruction *Res = foldICmpInstWithConstant(I))
     return Res;
 

Modified: projects/clang400-import/contrib/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -158,8 +158,9 @@ struct MemAccessTy {
 
   bool operator!=(MemAccessTy Other) const { return !(*this == Other); }
 
-  static MemAccessTy getUnknown(LLVMContext &Ctx) {
-    return MemAccessTy(Type::getVoidTy(Ctx), UnknownAddressSpace);
+  static MemAccessTy getUnknown(LLVMContext &Ctx,
+                                unsigned AS = UnknownAddressSpace) {
+    return MemAccessTy(Type::getVoidTy(Ctx), AS);
   }
 };
 
@@ -2279,8 +2280,10 @@ bool LSRInstance::reconcileNewOffset(LSR
   // TODO: Be less conservative when the type is similar and can use the same
   // addressing modes.
   if (Kind == LSRUse::Address) {
-    if (AccessTy != LU.AccessTy)
-      NewAccessTy = MemAccessTy::getUnknown(AccessTy.MemTy->getContext());
+    if (AccessTy.MemTy != LU.AccessTy.MemTy) {
+      NewAccessTy = MemAccessTy::getUnknown(AccessTy.MemTy->getContext(),
+                                            AccessTy.AddrSpace);
+    }
   }
 
   // Conservatively assume HasBaseReg is true for now.

Modified: projects/clang400-import/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/clang/lib/Sema/SemaExprCXX.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -7190,14 +7190,6 @@ public:
 
   ExprResult TransformBlockExpr(BlockExpr *E) { return Owned(E); }
 
-  ExprResult TransformObjCPropertyRefExpr(ObjCPropertyRefExpr *E) {
-    return Owned(E);
-  }
-
-  ExprResult TransformObjCIvarRefExpr(ObjCIvarRefExpr *E) {
-    return Owned(E);
-  }
-
   ExprResult Transform(Expr *E) {
     ExprResult Res;
     while (true) {

Modified: projects/clang400-import/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/clang/lib/Sema/TreeTransform.h	Sun Feb  5 19:57:41 2017	(r313300)
@@ -2932,16 +2932,17 @@ public:
   ExprResult RebuildObjCIvarRefExpr(Expr *BaseArg, ObjCIvarDecl *Ivar,
                                           SourceLocation IvarLoc,
                                           bool IsArrow, bool IsFreeIvar) {
-    // FIXME: We lose track of the IsFreeIvar bit.
     CXXScopeSpec SS;
     DeclarationNameInfo NameInfo(Ivar->getDeclName(), IvarLoc);
-    return getSema().BuildMemberReferenceExpr(BaseArg, BaseArg->getType(),
-                                              /*FIXME:*/IvarLoc, IsArrow,
-                                              SS, SourceLocation(),
-                                              /*FirstQualifierInScope=*/nullptr,
-                                              NameInfo,
-                                              /*TemplateArgs=*/nullptr,
-                                              /*S=*/nullptr);
+    ExprResult Result = getSema().BuildMemberReferenceExpr(
+        BaseArg, BaseArg->getType(),
+        /*FIXME:*/ IvarLoc, IsArrow, SS, SourceLocation(),
+        /*FirstQualifierInScope=*/nullptr, NameInfo,
+        /*TemplateArgs=*/nullptr,
+        /*S=*/nullptr);
+    if (IsFreeIvar && Result.isUsable())
+      cast<ObjCIvarRefExpr>(Result.get())->setIsFreeIvar(IsFreeIvar);
+    return Result;
   }
 
   /// \brief Build a new Objective-C property reference expression.

Modified: projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Checkers/MacOSXAPIChecker.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -94,11 +94,18 @@ void MacOSXAPIChecker::CheckDispatchOnce
   bool SuggestStatic = false;
   os << "Call to '" << FName << "' uses";
   if (const VarRegion *VR = dyn_cast<VarRegion>(RB)) {
+    const VarDecl *VD = VR->getDecl();
+    // FIXME: These should have correct memory space and thus should be filtered
+    // out earlier. This branch only fires when we're looking from a block,
+    // which we analyze as a top-level declaration, onto a static local
+    // in a function that contains the block.
+    if (VD->isStaticLocal())
+      return;
     // We filtered out globals earlier, so it must be a local variable
     // or a block variable which is under UnknownSpaceRegion.
     if (VR != R)
       os << " memory within";
-    if (VR->getDecl()->hasAttr<BlocksAttr>())
+    if (VD->hasAttr<BlocksAttr>())
       os << " the block variable '";
     else
       os << " the local variable '";

Modified: projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/MemRegion.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -816,9 +816,11 @@ const VarRegion* MemRegionManager::getVa
 
     const StackFrameContext *STC = V.get<const StackFrameContext*>();
 
-    if (!STC)
+    if (!STC) {
+      // FIXME: Assign a more sensible memory space to static locals
+      // we see from within blocks that we analyze as top-level declarations.
       sReg = getUnknownRegion();
-    else {
+    } else {
       if (D->hasLocalStorage()) {
         sReg = isa<ParmVarDecl>(D) || isa<ImplicitParamDecl>(D)
                ? static_cast<const MemRegion*>(getStackArgumentsRegion(STC))

Modified: projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/clang/lib/StaticAnalyzer/Core/RegionStore.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -1849,6 +1849,8 @@ SVal RegionStoreManager::getBindingForVa
 
     // Function-scoped static variables are default-initialized to 0; if they
     // have an initializer, it would have been processed by now.
+    // FIXME: This is only true when we're starting analysis from main().
+    // We're losing a lot of coverage here.
     if (isa<StaticGlobalSpaceRegion>(MS))
       return svalBuilder.makeZeroVal(T);
 

Modified: projects/clang400-import/contrib/llvm/tools/lld/ELF/Config.h
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/lld/ELF/Config.h	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/lld/ELF/Config.h	Sun Feb  5 19:57:41 2017	(r313300)
@@ -98,6 +98,7 @@ struct Configuration {
   bool Bsymbolic;
   bool BsymbolicFunctions;
   bool ColorDiagnostics = false;
+  bool DefineCommon;
   bool Demangle = true;
   bool DisableVerify;
   bool EhFrameHdr;

Modified: projects/clang400-import/contrib/llvm/tools/lld/ELF/Driver.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/lld/ELF/Driver.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/lld/ELF/Driver.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -496,6 +496,8 @@ void LinkerDriver::readConfigs(opt::Inpu
   Config->Pie = getArg(Args, OPT_pie, OPT_nopie, false);
   Config->PrintGcSections = Args.hasArg(OPT_print_gc_sections);
   Config->Relocatable = Args.hasArg(OPT_relocatable);
+  Config->DefineCommon = getArg(Args, OPT_define_common, OPT_no_define_common,
+                                !Config->Relocatable);
   Config->Discard = getDiscardOption(Args);
   Config->SaveTemps = Args.hasArg(OPT_save_temps);
   Config->SingleRoRx = Args.hasArg(OPT_no_rosegment);

Modified: projects/clang400-import/contrib/llvm/tools/lld/ELF/Options.td
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/lld/ELF/Options.td	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/lld/ELF/Options.td	Sun Feb  5 19:57:41 2017	(r313300)
@@ -45,6 +45,9 @@ def color_diagnostics: F<"color-diagnost
 def color_diagnostics_eq: J<"color-diagnostics=">,
   HelpText<"Use colors in diagnostics">;
 
+def define_common: F<"define-common">,
+  HelpText<"Assign space to common symbols">;
+
 def disable_new_dtags: F<"disable-new-dtags">,
   HelpText<"Disable new dynamic tags">;
 
@@ -130,6 +133,9 @@ def no_as_needed: F<"no-as-needed">,
 def no_color_diagnostics: F<"no-color-diagnostics">,
   HelpText<"Do not use colors in diagnostics">;
 
+def no_define_common: F<"no-define-common">,
+  HelpText<"Do not assign space to common symbols">;
+
 def no_demangle: F<"no-demangle">,
   HelpText<"Do not demangle symbol names">;
 
@@ -255,6 +261,9 @@ def alias_Bstatic_dn: F<"dn">, Alias<Bst
 def alias_Bstatic_non_shared: F<"non_shared">, Alias<Bstatic>;
 def alias_Bstatic_static: F<"static">, Alias<Bstatic>;
 def alias_L__library_path: J<"library-path=">, Alias<L>;
+def alias_define_common_d: Flag<["-"], "d">, Alias<define_common>;
+def alias_define_common_dc: F<"dc">, Alias<define_common>;
+def alias_define_common_dp: F<"dp">, Alias<define_common>;
 def alias_discard_all_x: Flag<["-"], "x">, Alias<discard_all>;
 def alias_discard_locals_X: Flag<["-"], "X">, Alias<discard_locals>;
 def alias_dynamic_list: J<"dynamic-list=">, Alias<dynamic_list>;
@@ -320,7 +329,6 @@ def plugin_opt_eq: J<"plugin-opt=">;
 // Options listed below are silently ignored for now for compatibility.
 def allow_shlib_undefined: F<"allow-shlib-undefined">;
 def cref: Flag<["--"], "cref">;
-def define_common: F<"define-common">;
 def demangle: F<"demangle">;
 def detect_odr_violations: F<"detect-odr-violations">;
 def g: Flag<["-"], "g">;
@@ -347,9 +355,6 @@ def G: JoinedOrSeparate<["-"], "G">;
 def Qy : F<"Qy">;
 
 // Aliases for ignored options
-def alias_define_common_d: Flag<["-"], "d">, Alias<define_common>;
-def alias_define_common_dc: F<"dc">, Alias<define_common>;
-def alias_define_common_dp: F<"dp">, Alias<define_common>;
 def alias_Map_eq: J<"Map=">, Alias<Map>;
 def alias_version_script_version_script: J<"version-script=">,
   Alias<version_script>;

Modified: projects/clang400-import/contrib/llvm/tools/lld/ELF/Symbols.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/lld/ELF/Symbols.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/lld/ELF/Symbols.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -73,6 +73,8 @@ static typename ELFT::uint getSymVA(cons
     return VA;
   }
   case SymbolBody::DefinedCommonKind:
+    if (!Config->DefineCommon)
+      return 0;
     return In<ELFT>::Common->OutSec->Addr + In<ELFT>::Common->OutSecOff +
            cast<DefinedCommon>(Body).Offset;
   case SymbolBody::SharedKind: {

Modified: projects/clang400-import/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/lld/ELF/SyntheticSections.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -59,6 +59,9 @@ template <class ELFT> InputSection<ELFT>
                                        ArrayRef<uint8_t>(), "COMMON");
   Ret->Live = true;
 
+  if (!Config->DefineCommon)
+    return Ret;
+
   // Sort the common symbols by alignment as an heuristic to pack them better.
   std::vector<DefinedCommon *> Syms = getCommonSymbols<ELFT>();
   std::stable_sort(Syms.begin(), Syms.end(),
@@ -434,7 +437,7 @@ template <class ELFT> void GotSection<EL
 template <class ELFT>
 MipsGotSection<ELFT>::MipsGotSection()
     : SyntheticSection<ELFT>(SHF_ALLOC | SHF_WRITE | SHF_MIPS_GPREL,
-                             SHT_PROGBITS, Target->GotEntrySize, ".got") {}
+                             SHT_PROGBITS, 16, ".got") {}
 
 template <class ELFT>
 void MipsGotSection<ELFT>::addEntry(SymbolBody &Sym, uintX_t Addend,
@@ -1168,10 +1171,14 @@ void SymbolTableSection<ELFT>::writeGlob
     ESym->setVisibility(Body->symbol()->Visibility);
     ESym->st_value = Body->getVA<ELFT>();
 
-    if (const OutputSectionBase *OutSec = getOutputSection(Body))
+    if (const OutputSectionBase *OutSec = getOutputSection(Body)) {
       ESym->st_shndx = OutSec->SectionIndex;
-    else if (isa<DefinedRegular<ELFT>>(Body))
+    } else if (isa<DefinedRegular<ELFT>>(Body)) {
       ESym->st_shndx = SHN_ABS;
+    } else if (isa<DefinedCommon>(Body)) {
+      ESym->st_shndx = SHN_COMMON;
+      ESym->st_value = cast<DefinedCommon>(Body)->Alignment;
+    }
 
     if (Config->EMachine == EM_MIPS) {
       // On MIPS we need to mark symbol which has a PLT entry and requires
@@ -1203,6 +1210,8 @@ SymbolTableSection<ELFT>::getOutputSecti
     break;
   }
   case SymbolBody::DefinedCommonKind:
+    if (!Config->DefineCommon)
+      return nullptr;
     return In<ELFT>::Common->OutSec;
   case SymbolBody::SharedKind: {
     auto &SS = cast<SharedSymbol<ELFT>>(*Sym);

Modified: projects/clang400-import/contrib/llvm/tools/lld/ELF/Writer.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/lld/ELF/Writer.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/lld/ELF/Writer.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -476,6 +476,16 @@ static int getPPC64SectionRank(StringRef
       .Default(1);
 }
 
+// All sections with SHF_MIPS_GPREL flag should be grouped together
+// because data in these sections is addressable with a gp relative address.
+static int getMipsSectionRank(const OutputSectionBase *S) {
+  if ((S->Flags & SHF_MIPS_GPREL) == 0)
+    return 0;
+  if (S->getName() == ".got")
+    return 1;
+  return 2;
+}
+
 template <class ELFT> bool elf::isRelroSection(const OutputSectionBase *Sec) {
   if (!Config->ZRelro)
     return false;
@@ -494,8 +504,6 @@ template <class ELFT> bool elf::isRelroS
     return true;
   if (In<ELFT>::Got && Sec == In<ELFT>::Got->OutSec)
     return true;
-  if (In<ELFT>::MipsGot && Sec == In<ELFT>::MipsGot->OutSec)
-    return true;
   if (Sec == Out<ELFT>::BssRelRo)
     return true;
   StringRef S = Sec->getName();
@@ -595,6 +603,8 @@ static bool compareSectionsNonScript(con
   if (Config->EMachine == EM_PPC64)
     return getPPC64SectionRank(A->getName()) <
            getPPC64SectionRank(B->getName());
+  if (Config->EMachine == EM_MIPS)
+    return getMipsSectionRank(A) < getMipsSectionRank(B);
 
   return false;
 }

Modified: projects/clang400-import/contrib/llvm/tools/llvm-objdump/ELFDump.cpp
==============================================================================
--- projects/clang400-import/contrib/llvm/tools/llvm-objdump/ELFDump.cpp	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/contrib/llvm/tools/llvm-objdump/ELFDump.cpp	Sun Feb  5 19:57:41 2017	(r313300)
@@ -36,6 +36,9 @@ template <class ELFT> void printProgramH
     case ELF::PT_GNU_EH_FRAME:
       outs() << "EH_FRAME ";
       break;
+    case ELF::PT_GNU_RELRO:
+      outs() << "   RELRO ";
+      break;
     case ELF::PT_GNU_STACK:
       outs() << "   STACK ";
       break;
@@ -45,6 +48,18 @@ template <class ELFT> void printProgramH
     case ELF::PT_LOAD:
       outs() << "    LOAD ";
       break;
+    case ELF::PT_NOTE:
+      outs() << "    NOTE ";
+      break;
+    case ELF::PT_OPENBSD_BOOTDATA:
+      outs() << "    OPENBSD_BOOTDATA ";
+      break;
+    case ELF::PT_OPENBSD_RANDOMIZE:
+      outs() << "    OPENBSD_RANDOMIZE ";
+      break;
+    case ELF::PT_OPENBSD_WXNEEDED:
+      outs() << "    OPENBSD_WXNEEDED ";
+      break;
     case ELF::PT_PHDR:
       outs() << "    PHDR ";
       break;

Modified: projects/clang400-import/lib/clang/include/clang/Basic/Version.inc
==============================================================================
--- projects/clang400-import/lib/clang/include/clang/Basic/Version.inc	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/lib/clang/include/clang/Basic/Version.inc	Sun Feb  5 19:57:41 2017	(r313300)
@@ -8,4 +8,4 @@
 
 #define	CLANG_VENDOR			"FreeBSD "
 
-#define	SVN_REVISION			"293807"
+#define	SVN_REVISION			"294123"

Modified: projects/clang400-import/lib/clang/include/lld/Config/Version.inc
==============================================================================
--- projects/clang400-import/lib/clang/include/lld/Config/Version.inc	Sun Feb  5 19:38:10 2017	(r313299)
+++ projects/clang400-import/lib/clang/include/lld/Config/Version.inc	Sun Feb  5 19:57:41 2017	(r313300)
@@ -4,5 +4,5 @@
 #define LLD_VERSION_STRING "4.0.0"
 #define LLD_VERSION_MAJOR 4
 #define LLD_VERSION_MINOR 0
-#define LLD_REVISION_STRING "293807"
+#define LLD_REVISION_STRING "294123"
 #define LLD_REPOSITORY_STRING "FreeBSD"



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