Date: Mon, 28 Oct 2019 21:04:16 +0000 (UTC) From: Brooks Davis <brooks@FreeBSD.org> To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-branches@freebsd.org Subject: svn commit: r515935 - in branches/2019Q4/devel/llvm90: . files files/clang files/lld files/ppc64-elfv2 Message-ID: <201910282104.x9SL4Gpt090313@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: brooks Date: Mon Oct 28 21:04:16 2019 New Revision: 515935 URL: https://svnweb.freebsd.org/changeset/ports/515935 Log: MFH: r513490 r514194 r515213 Fix build with EXTRAS disabled. clangd is part of EXTRAS, not CLANG. PR: 240826 Reported by: rozhuk.im@gmail.com Rollup of fixes since the 9.0.0 release. - Change the default -march for i386 from i486 to i586. This avoids the need for libatomics and had been the defacto default for some time. [0] - Add -m(no)-spe to clang. (powerpc) - Deduce MIPS specific ELF header flags from `emulation`. (mips) - Fix a variety of assertions and compile/link errors including crashes with CPUTYPE=haswell. [1] - Switch back to https for downloads. [2] The new patches were initially committed to FreeBSD src by dim@. PR: 240918 [0], 240759 [1], 240870 [2] Reported by: jbeich [0,1], Miyashita Touka <imagin8r@protonmail.com> [2] Fix build without CLANG enabled. [0] Fix LLD build where PREFIX != LOCALBASE. [1] powerpc64: add configure option to select ELFv2 ABI [2] In preparation for compiler+ABI change in PowerPC64, this change adds a configure option to select ELFv2 as default powerpc64 ABI when compiling llvm90. The new option automatically set when ELFv2 environment is detected (when PPC_ABI=ELFv2) PR: 241400 [1], 241410 [0] Submitted by: Alfredo Dal'Ava JĂșnior [2] Differential Revision: https://reviews.freebsd.org/D22100 [2] Approved by: portmgr (blanket for build and reliability fixes) Added: branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352030 - copied unchanged from r514194, head/devel/llvm90/files/clang/patch-freebsd-r352030 branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352539 - copied unchanged from r514194, head/devel/llvm90/files/clang/patch-freebsd-r352539 branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352586 - copied unchanged from r514194, head/devel/llvm90/files/clang/patch-freebsd-r352586 branches/2019Q4/devel/llvm90/files/lld/ - copied from r514194, head/devel/llvm90/files/lld/ branches/2019Q4/devel/llvm90/files/patch-freebsd-r352318 - copied unchanged from r514194, head/devel/llvm90/files/patch-freebsd-r352318 branches/2019Q4/devel/llvm90/files/patch-freebsd-r352629 - copied unchanged from r514194, head/devel/llvm90/files/patch-freebsd-r352629 branches/2019Q4/devel/llvm90/files/ppc64-elfv2/ - copied from r515213, head/devel/llvm90/files/ppc64-elfv2/ Modified: branches/2019Q4/devel/llvm90/Makefile branches/2019Q4/devel/llvm90/Makefile.COMMANDS branches/2019Q4/devel/llvm90/pkg-plist Directory Properties: branches/2019Q4/ (props changed) Modified: branches/2019Q4/devel/llvm90/Makefile ============================================================================== --- branches/2019Q4/devel/llvm90/Makefile Mon Oct 28 20:53:58 2019 (r515934) +++ branches/2019Q4/devel/llvm90/Makefile Mon Oct 28 21:04:16 2019 (r515935) @@ -2,12 +2,12 @@ PORTNAME= llvm DISTVERSION= 9.0.0 -PORTREVISION= 0 +PORTREVISION= 2 CATEGORIES= devel lang .if ${DISTVERSION:M*rc*} -MASTER_SITES= http://prereleases.llvm.org/${LLVM_RELEASE}/${RCDIR} +MASTER_SITES= https://prereleases.llvm.org/${LLVM_RELEASE}/${RCDIR} .else -MASTER_SITES= http://releases.llvm.org/${LLVM_RELEASE}/ +MASTER_SITES= https://releases.llvm.org/${LLVM_RELEASE}/ .endif PKGNAMESUFFIX= ${LLVM_SUFFIX} DISTNAME= ${PORTNAME}-${DISTVERSION}.src @@ -66,7 +66,7 @@ CMAKE_ARGS+= -DPYTHON_EXECUTABLE=${PYTHON_CMD} \ CFLAGS+= -DNDEBUG CXXFLAGS+= -DNDEBUG -OPTIONS_DEFINE= BE_AMDGPU CLANG DOCS EXTRAS LIT LLD LLD_LINK LLDB PYCLANG +OPTIONS_DEFINE= BE_AMDGPU CLANG DOCS ELFV2 EXTRAS LIT LLD LLD_LINK LLDB PYCLANG OPTIONS_DEFINE_amd64= COMPILER_RT GOLD OPENMP OPTIONS_DEFINE_i386= COMPILER_RT OPENMP OPTIONS_DEFINE_powerpc64= OPENMP @@ -106,6 +106,9 @@ DOCS_CMAKE_ON= -DLLVM_ENABLE_SPHINX=ON \ -DSPHINX_WARNINGS_AS_ERRORS=OFF \ -DLLVM_BUILD_DOCS=ON DOCS_PLIST_FILES= ${MAN1SRCS:S|^|man/man1/|:S|.1$|${LLVM_SUFFIX}.1.gz|} +ELFV2_DESC= [PowerPC64] Use OpenPOWER ELF ABI v2 by default +ELFV2_EXTRA_PATCHES= ${PATCHDIR}/ppc64-elfv2 +ELFV2_IMPLIES= CLANG EXTRAS_DESC= Extra clang tools EXTRAS_EXTRA_PATCHES= ${PATCHDIR}/extras EXTRAS_IMPLIES= CLANG @@ -117,6 +120,7 @@ LIT_DESC= Install lit and FileCheck test tools LIT_VARS= _USES_PYTHON=python:3.6+ LLD_DESC= Install lld, the LLVM linker LLD_DISTFILES= lld-${DISTVERSION}.src${EXTRACT_SUFX} +LLD_EXTRA_PATCHES= ${PATCHDIR}/lld LLD_LINK_DESC= Link ld.lld as ld to clang uses it LLD_LINK_IMPLIES= LLD LLDB_BUILD_DEPENDS= swig3.0:devel/swig30 \ @@ -216,6 +220,11 @@ EXTRAS_PATTERN= ${EXTRAS_COMMANDS:tW:C/ */|/g}|${EXTR .include <bsd.port.options.mk> +# PPC_ABI variable is only defined after including bsd.port.options.mk +.if defined(PPC_ABI) && ${PPC_ABI} == ELFv2 +OPTIONS_DEFAULT_powerpc64= ELFV2 +.endif + # keep in sync with /usr/src/lib/clang/clang.build.mk # ----------- start of sync block ------------------ # Armv6 and armv7 uses hard float abi, unless the CPUTYPE has soft in it. @@ -237,7 +246,7 @@ COMMANDS+= ${CLANG_COMMANDS} MAN1SRCS+= clang.1 \ diagtool.1 \ scan-build.1 -CLANG_PATTERN= (c-index-test|clang|diagtool|hmaptool|scan-|Reporter.py|ScanView.py|scanview.css|sorttable.js|startfile.py|-analyzer) +CLANG_PATTERN= (c-index-test|clang|diagtool|hmaptool|scan-|Reporter.py|ScanView.py|scanview.css|sorttable.js|startfile.py|-analyzer|AnalyzerPlugin.so) SHEBANG_FILES+= tools/clang/tools/scan-view/bin/scan-view \ tools/clang/tools/clang-format/clang-format-diff.py \ tools/clang/tools/clang-format/git-clang-format \ @@ -535,7 +544,7 @@ post-install-LIT-on: ${STAGEDIR}${PREFIX}/bin/FileCheck${LLVM_SUFFIX} post-install-LLD_LINK-on: - ${LN} -s ld.lld ${STAGEDIR}${LOCALBASE}/llvm${LLVM_SUFFIX}/bin/ld + ${LN} -s ld.lld ${STAGEDIR}${LLVM_PREFIX}/bin/ld TEST_CMD= '(cd ${WRKSRC}/test; ${SETENV} ${MAKE_ENV} LD_LIBRARY_PATH=${WRKSRC}/Release/lib ${MAKE_CMD} check-local-lit)' do-test: Modified: branches/2019Q4/devel/llvm90/Makefile.COMMANDS ============================================================================== --- branches/2019Q4/devel/llvm90/Makefile.COMMANDS Mon Oct 28 20:53:58 2019 (r515934) +++ branches/2019Q4/devel/llvm90/Makefile.COMMANDS Mon Oct 28 21:04:16 2019 (r515935) @@ -63,13 +63,13 @@ CLANG_COMMANDS= \ clang-import-test \ clang-offload-bundler \ clang-scan-deps \ - clangd \ diagtool \ hmaptool \ scan-build \ scan-view EXTRAS_COMMANDS= \ + clangd \ clang-apply-replacements \ clang-change-namespace \ clang-doc \ Copied: branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352030 (from r514194, head/devel/llvm90/files/clang/patch-freebsd-r352030) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352030 Mon Oct 28 21:04:16 2019 (r515935, copy of r514194, head/devel/llvm90/files/clang/patch-freebsd-r352030) @@ -0,0 +1,36 @@ +commit 5f6a983e7fba98335e2863fe31305e895545ebb2 +Author: dim <dim@FreeBSD.org> +Date: Sun Sep 8 10:31:34 2019 +0000 + + Target i586 by default on the i386 architecture, since after upstream's + change https://reviews.llvm.org/rL356631 ("[X86] Add CMPXCHG8B feature + flag. Set it for all CPUs except i386/i486 including 'generic'. Disable + use of CMPXCHG8B when this flag isn't set"), clang now correctly emits + calls to __atomic_load_8, __atomic_store_8, etc. when targeting i486, + and this means we can no longer link most modern programs, because we do + not have a libatomic, nor support for atomic functions in libc. See + also PR 230888, 220822, 233725, 234976, and more probably duplicates. + + Note that in practice, clang has been incorrectly generating cmpxchg8b + instructions for years now, when targeting i486. So de facto nothing + really changes by doing this. + +Notes: + svn path=/projects/clang900-import/; revision=352030 + +diff --git tools/clang/lib/Driver/ToolChains/Arch/X86.cpp tools/clang/lib/Driver/ToolChains/Arch/X86.cpp +index 34be226b69e9..9a5c0aa28c7f 100644 +--- tools/clang/lib/Driver/ToolChains/Arch/X86.cpp ++++ tools/clang/lib/Driver/ToolChains/Arch/X86.cpp +@@ -93,10 +93,10 @@ const char *x86::getX86TargetCPU(const ArgList &Args, + return "x86-64"; + + switch (Triple.getOS()) { +- case llvm::Triple::FreeBSD: + case llvm::Triple::NetBSD: + case llvm::Triple::OpenBSD: + return "i486"; ++ case llvm::Triple::FreeBSD: + case llvm::Triple::Haiku: + return "i586"; + default: Copied: branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352539 (from r514194, head/devel/llvm90/files/clang/patch-freebsd-r352539) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352539 Mon Oct 28 21:04:16 2019 (r515935, copy of r514194, head/devel/llvm90/files/clang/patch-freebsd-r352539) @@ -0,0 +1,102 @@ +commit 053368e30489fc77ab06ee7954df3719af2548c2 +Author: dim <dim@FreeBSD.org> +Date: Thu Sep 19 19:42:59 2019 +0000 + + Pull in r371066 from upstream clang trunk (by Justin Hibbits): + + Add -m(no)-spe to clang + + Summary: + r337347 added support for the Signal Processing Engine (SPE) to LLVM. + This follows that up with the clang side. + + This adds -mspe and -mno-spe, to match GCC. + + Subscribers: nemanjai, kbarton, cfe-commits + + Differential Revision: https://reviews.llvm.org/D49754 + +Notes: + svn path=/projects/clang900-import/; revision=352539 + +diff --git tools/clang/include/clang/Driver/Options.td tools/clang/include/clang/Driver/Options.td +index 4ea8bfff0973..508d046dbb91 100644 +--- tools/clang/include/clang/Driver/Options.td ++++ tools/clang/include/clang/Driver/Options.td +@@ -2241,6 +2241,8 @@ def faltivec : Flag<["-"], "faltivec">, Group<f_Group>, Flags<[DriverOption]>; + def fno_altivec : Flag<["-"], "fno-altivec">, Group<f_Group>, Flags<[DriverOption]>; + def maltivec : Flag<["-"], "maltivec">, Group<m_ppc_Features_Group>; + def mno_altivec : Flag<["-"], "mno-altivec">, Group<m_ppc_Features_Group>; ++def mspe : Flag<["-"], "mspe">, Group<m_ppc_Features_Group>; ++def mno_spe : Flag<["-"], "mno-spe">, Group<m_ppc_Features_Group>; + def mvsx : Flag<["-"], "mvsx">, Group<m_ppc_Features_Group>; + def mno_vsx : Flag<["-"], "mno-vsx">, Group<m_ppc_Features_Group>; + def msecure_plt : Flag<["-"], "msecure-plt">, Group<m_ppc_Features_Group>; +diff --git tools/clang/lib/Basic/Targets/PPC.cpp tools/clang/lib/Basic/Targets/PPC.cpp +index 2a773d999286..a40991048873 100644 +--- tools/clang/lib/Basic/Targets/PPC.cpp ++++ tools/clang/lib/Basic/Targets/PPC.cpp +@@ -54,6 +54,10 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features, + HasFloat128 = true; + } else if (Feature == "+power9-vector") { + HasP9Vector = true; ++ } else if (Feature == "+spe") { ++ HasSPE = true; ++ LongDoubleWidth = LongDoubleAlign = 64; ++ LongDoubleFormat = &llvm::APFloat::IEEEdouble(); + } else if (Feature == "-hard-float") { + FloatABI = SoftFloat; + } +@@ -165,6 +169,10 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, + Builder.defineMacro("__VEC__", "10206"); + Builder.defineMacro("__ALTIVEC__"); + } ++ if (HasSPE) { ++ Builder.defineMacro("__SPE__"); ++ Builder.defineMacro("__NO_FPRS__"); ++ } + if (HasVSX) + Builder.defineMacro("__VSX__"); + if (HasP8Vector) +@@ -203,7 +211,6 @@ void PPCTargetInfo::getTargetDefines(const LangOptions &Opts, + // __CMODEL_LARGE__ + // _CALL_SYSV + // _CALL_DARWIN +- // __NO_FPRS__ + } + + // Handle explicit options being passed to the compiler here: if we've +@@ -332,6 +339,7 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const { + .Case("extdiv", HasExtDiv) + .Case("float128", HasFloat128) + .Case("power9-vector", HasP9Vector) ++ .Case("spe", HasSPE) + .Default(false); + } + +diff --git tools/clang/lib/Basic/Targets/PPC.h tools/clang/lib/Basic/Targets/PPC.h +index 6e5df097921b..6c6421c28e23 100644 +--- tools/clang/lib/Basic/Targets/PPC.h ++++ tools/clang/lib/Basic/Targets/PPC.h +@@ -66,6 +66,7 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo { + bool HasBPERMD = false; + bool HasExtDiv = false; + bool HasP9Vector = false; ++ bool HasSPE = false; + + protected: + std::string ABI; +diff --git tools/clang/lib/CodeGen/TargetInfo.cpp tools/clang/lib/CodeGen/TargetInfo.cpp +index 1e1038dbfe95..81f40011f11c 100644 +--- tools/clang/lib/CodeGen/TargetInfo.cpp ++++ tools/clang/lib/CodeGen/TargetInfo.cpp +@@ -9716,7 +9716,8 @@ const TargetCodeGenInfo &CodeGenModule::getTargetCodeGenInfo() { + + case llvm::Triple::ppc: + return SetCGInfo( +- new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft")); ++ new PPC32TargetCodeGenInfo(Types, CodeGenOpts.FloatABI == "soft" || ++ getTarget().hasFeature("spe"))); + case llvm::Triple::ppc64: + if (Triple.isOSBinFormatELF()) { + PPC64_SVR4_ABIInfo::ABIKind Kind = PPC64_SVR4_ABIInfo::ELFv1; Copied: branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352586 (from r514194, head/devel/llvm90/files/clang/patch-freebsd-r352586) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2019Q4/devel/llvm90/files/clang/patch-freebsd-r352586 Mon Oct 28 21:04:16 2019 (r515935, copy of r514194, head/devel/llvm90/files/clang/patch-freebsd-r352586) @@ -0,0 +1,300 @@ +commit 96f7d6cb2727d1d08e1e460f6606a2a11673b292 +Author: dim <dim@FreeBSD.org> +Date: Sat Sep 21 21:01:38 2019 +0000 + + Pull in r371557 from upstream clang trunk (by Richard Smith): + + When evaluating a __builtin_constant_p conditional, always enter + constant-folding mode regardless of the original evaluation mode. + + In order for this to be correct, we need to track whether we're + checking for a potential constant expression or checking for + undefined behavior separately from the evaluation mode enum, since we + don't want to clobber those states when entering constant-folding + mode. + + This should fix "ld: error: undefined symbol: ix86_isa_flags" (and many + other symbol names) during the initial stages of the lang/gcc* ports. + + The issue was that without optimization, the __builtin_constant_p() + expressions generated in gencondmd.c would emit references to global + variables that were undefined, such as ix86_isa_flags. + + PR: 240629 + +Notes: + svn path=/projects/clang900-import/; revision=352586 + +diff --git tools/clang/lib/AST/ExprConstant.cpp tools/clang/lib/AST/ExprConstant.cpp +index f01b42e7ff76..26163c6143e6 100644 +--- tools/clang/lib/AST/ExprConstant.cpp ++++ tools/clang/lib/AST/ExprConstant.cpp +@@ -794,58 +794,47 @@ namespace { + /// constant value. + bool InConstantContext; + ++ /// Whether we're checking that an expression is a potential constant ++ /// expression. If so, do not fail on constructs that could become constant ++ /// later on (such as a use of an undefined global). ++ bool CheckingPotentialConstantExpression = false; ++ ++ /// Whether we're checking for an expression that has undefined behavior. ++ /// If so, we will produce warnings if we encounter an operation that is ++ /// always undefined. ++ bool CheckingForUndefinedBehavior = false; ++ + enum EvaluationMode { + /// Evaluate as a constant expression. Stop if we find that the expression + /// is not a constant expression. + EM_ConstantExpression, + +- /// Evaluate as a potential constant expression. Keep going if we hit a +- /// construct that we can't evaluate yet (because we don't yet know the +- /// value of something) but stop if we hit something that could never be +- /// a constant expression. +- EM_PotentialConstantExpression, ++ /// Evaluate as a constant expression. Stop if we find that the expression ++ /// is not a constant expression. Some expressions can be retried in the ++ /// optimizer if we don't constant fold them here, but in an unevaluated ++ /// context we try to fold them immediately since the optimizer never ++ /// gets a chance to look at it. ++ EM_ConstantExpressionUnevaluated, + + /// Fold the expression to a constant. Stop if we hit a side-effect that + /// we can't model. + EM_ConstantFold, + +- /// Evaluate the expression looking for integer overflow and similar +- /// issues. Don't worry about side-effects, and try to visit all +- /// subexpressions. +- EM_EvaluateForOverflow, +- + /// Evaluate in any way we know how. Don't worry about side-effects that + /// can't be modeled. + EM_IgnoreSideEffects, +- +- /// Evaluate as a constant expression. Stop if we find that the expression +- /// is not a constant expression. Some expressions can be retried in the +- /// optimizer if we don't constant fold them here, but in an unevaluated +- /// context we try to fold them immediately since the optimizer never +- /// gets a chance to look at it. +- EM_ConstantExpressionUnevaluated, +- +- /// Evaluate as a potential constant expression. Keep going if we hit a +- /// construct that we can't evaluate yet (because we don't yet know the +- /// value of something) but stop if we hit something that could never be +- /// a constant expression. Some expressions can be retried in the +- /// optimizer if we don't constant fold them here, but in an unevaluated +- /// context we try to fold them immediately since the optimizer never +- /// gets a chance to look at it. +- EM_PotentialConstantExpressionUnevaluated, + } EvalMode; + + /// Are we checking whether the expression is a potential constant + /// expression? + bool checkingPotentialConstantExpression() const { +- return EvalMode == EM_PotentialConstantExpression || +- EvalMode == EM_PotentialConstantExpressionUnevaluated; ++ return CheckingPotentialConstantExpression; + } + + /// Are we checking an expression for overflow? + // FIXME: We should check for any kind of undefined or suspicious behavior + // in such constructs, not just overflow. +- bool checkingForOverflow() { return EvalMode == EM_EvaluateForOverflow; } ++ bool checkingForUndefinedBehavior() { return CheckingForUndefinedBehavior; } + + EvalInfo(const ASTContext &C, Expr::EvalStatus &S, EvaluationMode Mode) + : Ctx(const_cast<ASTContext &>(C)), EvalStatus(S), CurrentCall(nullptr), +@@ -932,15 +921,12 @@ namespace { + switch (EvalMode) { + case EM_ConstantFold: + case EM_IgnoreSideEffects: +- case EM_EvaluateForOverflow: + if (!HasFoldFailureDiagnostic) + break; + // We've already failed to fold something. Keep that diagnostic. + LLVM_FALLTHROUGH; + case EM_ConstantExpression: +- case EM_PotentialConstantExpression: + case EM_ConstantExpressionUnevaluated: +- case EM_PotentialConstantExpressionUnevaluated: + HasActiveDiagnostic = false; + return OptionalDiagnostic(); + } +@@ -986,8 +972,8 @@ namespace { + /// Diagnose that the evaluation does not produce a C++11 core constant + /// expression. + /// +- /// FIXME: Stop evaluating if we're in EM_ConstantExpression or +- /// EM_PotentialConstantExpression mode and we produce one of these. ++ /// FIXME: Stop evaluating if we're in EM_ConstantExpression mode ++ /// and we produce one of these. + OptionalDiagnostic CCEDiag(SourceLocation Loc, diag::kind DiagId + = diag::note_invalid_subexpr_in_const_expr, + unsigned ExtraNotes = 0) { +@@ -1023,16 +1009,16 @@ namespace { + /// couldn't model? + bool keepEvaluatingAfterSideEffect() { + switch (EvalMode) { +- case EM_PotentialConstantExpression: +- case EM_PotentialConstantExpressionUnevaluated: +- case EM_EvaluateForOverflow: + case EM_IgnoreSideEffects: + return true; + + case EM_ConstantExpression: + case EM_ConstantExpressionUnevaluated: + case EM_ConstantFold: +- return false; ++ // By default, assume any side effect might be valid in some other ++ // evaluation of this expression from a different context. ++ return checkingPotentialConstantExpression() || ++ checkingForUndefinedBehavior(); + } + llvm_unreachable("Missed EvalMode case"); + } +@@ -1047,16 +1033,13 @@ namespace { + /// Should we continue evaluation after encountering undefined behavior? + bool keepEvaluatingAfterUndefinedBehavior() { + switch (EvalMode) { +- case EM_EvaluateForOverflow: + case EM_IgnoreSideEffects: + case EM_ConstantFold: + return true; + +- case EM_PotentialConstantExpression: +- case EM_PotentialConstantExpressionUnevaluated: + case EM_ConstantExpression: + case EM_ConstantExpressionUnevaluated: +- return false; ++ return checkingForUndefinedBehavior(); + } + llvm_unreachable("Missed EvalMode case"); + } +@@ -1076,16 +1059,12 @@ namespace { + return false; + + switch (EvalMode) { +- case EM_PotentialConstantExpression: +- case EM_PotentialConstantExpressionUnevaluated: +- case EM_EvaluateForOverflow: +- return true; +- + case EM_ConstantExpression: + case EM_ConstantExpressionUnevaluated: + case EM_ConstantFold: + case EM_IgnoreSideEffects: +- return false; ++ return checkingPotentialConstantExpression() || ++ checkingForUndefinedBehavior(); + } + llvm_unreachable("Missed EvalMode case"); + } +@@ -1142,9 +1121,7 @@ namespace { + Info.EvalStatus.Diag->empty() && + !Info.EvalStatus.HasSideEffects), + OldMode(Info.EvalMode) { +- if (Enabled && +- (Info.EvalMode == EvalInfo::EM_ConstantExpression || +- Info.EvalMode == EvalInfo::EM_ConstantExpressionUnevaluated)) ++ if (Enabled) + Info.EvalMode = EvalInfo::EM_ConstantFold; + } + void keepDiagnostics() { Enabled = false; } +@@ -1163,8 +1140,7 @@ namespace { + EvalInfo::EvaluationMode OldMode; + explicit IgnoreSideEffectsRAII(EvalInfo &Info) + : Info(Info), OldMode(Info.EvalMode) { +- if (!Info.checkingPotentialConstantExpression()) +- Info.EvalMode = EvalInfo::EM_IgnoreSideEffects; ++ Info.EvalMode = EvalInfo::EM_IgnoreSideEffects; + } + + ~IgnoreSideEffectsRAII() { Info.EvalMode = OldMode; } +@@ -2323,7 +2299,7 @@ static bool CheckedIntArithmetic(EvalInfo &Info, const Expr *E, + APSInt Value(Op(LHS.extend(BitWidth), RHS.extend(BitWidth)), false); + Result = Value.trunc(LHS.getBitWidth()); + if (Result.extend(BitWidth) != Value) { +- if (Info.checkingForOverflow()) ++ if (Info.checkingForUndefinedBehavior()) + Info.Ctx.getDiagnostics().Report(E->getExprLoc(), + diag::warn_integer_constant_overflow) + << Result.toString(10) << E->getType(); +@@ -6047,6 +6023,8 @@ class ExprEvaluatorBase + + // Always assume __builtin_constant_p(...) ? ... : ... is a potential + // constant expression; we can't check whether it's potentially foldable. ++ // FIXME: We should instead treat __builtin_constant_p as non-constant if ++ // it would return 'false' in this mode. + if (Info.checkingPotentialConstantExpression() && IsBcpCall) + return false; + +@@ -6329,7 +6307,7 @@ class ExprEvaluatorBase + bool VisitStmtExpr(const StmtExpr *E) { + // We will have checked the full-expressions inside the statement expression + // when they were completed, and don't need to check them again now. +- if (Info.checkingForOverflow()) ++ if (Info.checkingForUndefinedBehavior()) + return Error(E); + + BlockScopeRAII Scope(Info); +@@ -9499,14 +9477,11 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const CallExpr *E, + // size of the referenced object. + switch (Info.EvalMode) { + case EvalInfo::EM_ConstantExpression: +- case EvalInfo::EM_PotentialConstantExpression: + case EvalInfo::EM_ConstantFold: +- case EvalInfo::EM_EvaluateForOverflow: + case EvalInfo::EM_IgnoreSideEffects: + // Leave it to IR generation. + return Error(E); + case EvalInfo::EM_ConstantExpressionUnevaluated: +- case EvalInfo::EM_PotentialConstantExpressionUnevaluated: + // Reduce it to a constant now. + return Success((Type & 2) ? 0 : -1, E); + } +@@ -12546,8 +12521,9 @@ APSInt Expr::EvaluateKnownConstIntCheckOverflow( + + EvalResult EVResult; + EVResult.Diag = Diag; +- EvalInfo Info(Ctx, EVResult, EvalInfo::EM_EvaluateForOverflow); ++ EvalInfo Info(Ctx, EVResult, EvalInfo::EM_IgnoreSideEffects); + Info.InConstantContext = true; ++ Info.CheckingForUndefinedBehavior = true; + + bool Result = ::EvaluateAsRValue(Info, this, EVResult.Val); + (void)Result; +@@ -12564,7 +12540,8 @@ void Expr::EvaluateForOverflow(const ASTContext &Ctx) const { + bool IsConst; + EvalResult EVResult; + if (!FastEvaluateAsRValue(this, EVResult, Ctx, IsConst)) { +- EvalInfo Info(Ctx, EVResult, EvalInfo::EM_EvaluateForOverflow); ++ EvalInfo Info(Ctx, EVResult, EvalInfo::EM_IgnoreSideEffects); ++ Info.CheckingForUndefinedBehavior = true; + (void)::EvaluateAsRValue(Info, this, EVResult.Val); + } + } +@@ -13178,9 +13155,9 @@ bool Expr::isPotentialConstantExpr(const FunctionDecl *FD, + Expr::EvalStatus Status; + Status.Diag = &Diags; + +- EvalInfo Info(FD->getASTContext(), Status, +- EvalInfo::EM_PotentialConstantExpression); ++ EvalInfo Info(FD->getASTContext(), Status, EvalInfo::EM_ConstantExpression); + Info.InConstantContext = true; ++ Info.CheckingPotentialConstantExpression = true; + + const CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(FD); + const CXXRecordDecl *RD = MD ? MD->getParent()->getCanonicalDecl() : nullptr; +@@ -13219,8 +13196,9 @@ bool Expr::isPotentialConstantExprUnevaluated(Expr *E, + Status.Diag = &Diags; + + EvalInfo Info(FD->getASTContext(), Status, +- EvalInfo::EM_PotentialConstantExpressionUnevaluated); ++ EvalInfo::EM_ConstantExpressionUnevaluated); + Info.InConstantContext = true; ++ Info.CheckingPotentialConstantExpression = true; + + // Fabricate a call stack frame to give the arguments a plausible cover story. + ArrayRef<const Expr*> Args; Copied: branches/2019Q4/devel/llvm90/files/patch-freebsd-r352318 (from r514194, head/devel/llvm90/files/patch-freebsd-r352318) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2019Q4/devel/llvm90/files/patch-freebsd-r352318 Mon Oct 28 21:04:16 2019 (r515935, copy of r514194, head/devel/llvm90/files/patch-freebsd-r352318) @@ -0,0 +1,93 @@ +commit 24b1a5b926832f68fa0a008b2484d4b44f58ee8e +Author: dim <dim@FreeBSD.org> +Date: Sat Sep 14 10:55:33 2019 +0000 + + Revert commit from upstream llvm trunk (by Hans Wennborg): + + Re-commit r357452 (take 3): "SimplifyCFG + SinkCommonCodeFromPredecessors: Also sink function calls without used + results (PR41259)" + + Third time's the charm. + + This was reverted in r363220 due to being suspected of an internal + benchmark regression and a test failure, none of which turned out to + be caused by this. + + As reported in https://bugs.llvm.org/show_bug.cgi?id=43269, this causes + UNREACHABLE errors when compiling if_malo_pci.c for arm and aarch64. + +Notes: + svn path=/projects/clang900-import/; revision=352318 + +diff --git lib/Transforms/Utils/SimplifyCFG.cpp lib/Transforms/Utils/SimplifyCFG.cpp +index 11651d040dc0..6e2ef67408d9 100644 +--- lib/Transforms/Utils/SimplifyCFG.cpp ++++ lib/Transforms/Utils/SimplifyCFG.cpp +@@ -1428,10 +1428,9 @@ static bool HoistThenElseCodeToIf(BranchInst *BI, + static bool canSinkInstructions( + ArrayRef<Instruction *> Insts, + DenseMap<Instruction *, SmallVector<Value *, 4>> &PHIOperands) { +- // Prune out obviously bad instructions to move. Each instruction must have +- // exactly zero or one use, and we check later that use is by a single, common +- // PHI instruction in the successor. +- bool HasUse = !Insts.front()->user_empty(); ++ // Prune out obviously bad instructions to move. Any non-store instruction ++ // must have exactly one use, and we check later that use is by a single, ++ // common PHI instruction in the successor. + for (auto *I : Insts) { + // These instructions may change or break semantics if moved. + if (isa<PHINode>(I) || I->isEHPad() || isa<AllocaInst>(I) || +@@ -1445,10 +1444,9 @@ static bool canSinkInstructions( + if (C->isInlineAsm()) + return false; + +- // Each instruction must have zero or one use. +- if (HasUse && !I->hasOneUse()) +- return false; +- if (!HasUse && !I->user_empty()) ++ // Everything must have only one use too, apart from stores which ++ // have no uses. ++ if (!isa<StoreInst>(I) && !I->hasOneUse()) + return false; + } + +@@ -1457,11 +1455,11 @@ static bool canSinkInstructions( + if (!I->isSameOperationAs(I0)) + return false; + +- // All instructions in Insts are known to be the same opcode. If they have a +- // use, check that the only user is a PHI or in the same block as the +- // instruction, because if a user is in the same block as an instruction we're +- // contemplating sinking, it must already be determined to be sinkable. +- if (HasUse) { ++ // All instructions in Insts are known to be the same opcode. If they aren't ++ // stores, check the only user of each is a PHI or in the same block as the ++ // instruction, because if a user is in the same block as an instruction ++ // we're contemplating sinking, it must already be determined to be sinkable. ++ if (!isa<StoreInst>(I0)) { + auto *PNUse = dyn_cast<PHINode>(*I0->user_begin()); + auto *Succ = I0->getParent()->getTerminator()->getSuccessor(0); + if (!all_of(Insts, [&PNUse,&Succ](const Instruction *I) -> bool { +@@ -1539,7 +1537,7 @@ static bool sinkLastInstruction(ArrayRef<BasicBlock*> Blocks) { + // it is slightly over-aggressive - it gets confused by commutative instructions + // so double-check it here. + Instruction *I0 = Insts.front(); +- if (!I0->user_empty()) { ++ if (!isa<StoreInst>(I0)) { + auto *PNUse = dyn_cast<PHINode>(*I0->user_begin()); + if (!all_of(Insts, [&PNUse](const Instruction *I) -> bool { + auto *U = cast<Instruction>(*I->user_begin()); +@@ -1597,10 +1595,11 @@ static bool sinkLastInstruction(ArrayRef<BasicBlock*> Blocks) { + I0->andIRFlags(I); + } + +- if (!I0->user_empty()) { ++ if (!isa<StoreInst>(I0)) { + // canSinkLastInstruction checked that all instructions were used by + // one and only one PHI node. Find that now, RAUW it to our common + // instruction and nuke it. ++ assert(I0->hasOneUse()); + auto *PN = cast<PHINode>(*I0->user_begin()); + PN->replaceAllUsesWith(I0); + PN->eraseFromParent(); Copied: branches/2019Q4/devel/llvm90/files/patch-freebsd-r352629 (from r514194, head/devel/llvm90/files/patch-freebsd-r352629) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ branches/2019Q4/devel/llvm90/files/patch-freebsd-r352629 Mon Oct 28 21:04:16 2019 (r515935, copy of r514194, head/devel/llvm90/files/patch-freebsd-r352629) @@ -0,0 +1,58 @@ +commit 3538987a800db5e174b3301b9bf70b955a349762 +Author: dim <dim@FreeBSD.org> +Date: Mon Sep 23 17:05:46 2019 +0000 + + Pull in r372606 from upstream llvm trunk (by Sanjay Patel): + + [x86] fix assert with horizontal math + broadcast of vector (PR43402) + + https://bugs.llvm.org/show_bug.cgi?id=43402 + + This should fix 'Assertion failed: ((HOp.getValueType() == MVT::v2f64 || + HOp.getValueType() == MVT::v4f64) && HOp.getValueType() == VT && + "Unexpected type for h-op"), function foldShuffleOfHorizOp, file + contrib/llvm/lib/Target/X86/X86ISelLowering.cpp, line 33661' when + building the devel/llvm90 port with CPUTYPE=haswell. + + PR: 240759 + +Notes: + svn path=/projects/clang900-import/; revision=352629 + +diff --git lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86ISelLowering.cpp +index 0c5b8a79dd62..1869cc9da017 100644 +--- lib/Target/X86/X86ISelLowering.cpp ++++ lib/Target/X86/X86ISelLowering.cpp +@@ -33651,14 +33651,14 @@ static SDValue foldShuffleOfHorizOp(SDNode *N, SelectionDAG &DAG) { + + // When the operands of a horizontal math op are identical, the low half of + // the result is the same as the high half. If a target shuffle is also +- // replicating low and high halves, we don't need the shuffle. ++ // replicating low and high halves (and without changing the type/length of ++ // the vector), we don't need the shuffle. + if (Opcode == X86ISD::MOVDDUP || Opcode == X86ISD::VBROADCAST) { +- if (HOp.getScalarValueSizeInBits() == 64) { ++ if (HOp.getScalarValueSizeInBits() == 64 && HOp.getValueType() == VT) { + // movddup (hadd X, X) --> hadd X, X + // broadcast (extract_vec_elt (hadd X, X), 0) --> hadd X, X + assert((HOp.getValueType() == MVT::v2f64 || +- HOp.getValueType() == MVT::v4f64) && HOp.getValueType() == VT && +- "Unexpected type for h-op"); ++ HOp.getValueType() == MVT::v4f64) && "Unexpected type for h-op"); + return updateHOp(HOp, DAG); + } + return SDValue(); +diff --git lib/Target/X86/X86ISelLowering.h lib/Target/X86/X86ISelLowering.h +index db36bcb929e3..d873edb857a8 100644 +--- lib/Target/X86/X86ISelLowering.h ++++ lib/Target/X86/X86ISelLowering.h +@@ -422,7 +422,8 @@ namespace llvm { + // Tests Types Of a FP Values for scalar types. + VFPCLASSS, + +- // Broadcast scalar to vector. ++ // Broadcast (splat) scalar or element 0 of a vector. If the operand is ++ // a vector, this node may change the vector length as part of the splat. + VBROADCAST, + // Broadcast mask to vector. + VBROADCASTM, Modified: branches/2019Q4/devel/llvm90/pkg-plist ============================================================================== --- branches/2019Q4/devel/llvm90/pkg-plist Mon Oct 28 20:53:58 2019 (r515934) +++ branches/2019Q4/devel/llvm90/pkg-plist Mon Oct 28 21:04:16 2019 (r515935) @@ -60,11 +60,11 @@ bin/sancov%%LLVM_SUFFIX%% %%CLANG%%bin/clang-import-test%%LLVM_SUFFIX%% %%CLANG%%bin/clang-offload-bundler%%LLVM_SUFFIX%% %%CLANG%%bin/clang-scan-deps%%LLVM_SUFFIX%% -%%CLANG%%bin/clangd%%LLVM_SUFFIX%% %%CLANG%%bin/diagtool%%LLVM_SUFFIX%% %%CLANG%%bin/hmaptool%%LLVM_SUFFIX%% %%CLANG%%bin/scan-build%%LLVM_SUFFIX%% %%CLANG%%bin/scan-view%%LLVM_SUFFIX%% +%%EXTRAS%%bin/clangd%%LLVM_SUFFIX%% %%EXTRAS%%bin/clang-apply-replacements%%LLVM_SUFFIX%% %%EXTRAS%%bin/clang-change-namespace%%LLVM_SUFFIX%% %%EXTRAS%%bin/clang-doc%%LLVM_SUFFIX%% @@ -135,7 +135,7 @@ llvm%%LLVM_SUFFIX%%/bin/bugpoint %%CLANG%%llvm%%LLVM_SUFFIX%%/bin/clang-scan-deps %%CLANG%%llvm%%LLVM_SUFFIX%%/bin/clang-tblgen %%EXTRAS%%llvm%%LLVM_SUFFIX%%/bin/clang-tidy -%%CLANG%%llvm%%LLVM_SUFFIX%%/bin/clangd +%%EXTRAS%%llvm%%LLVM_SUFFIX%%/bin/clangd %%CLANG%%llvm%%LLVM_SUFFIX%%/bin/diagtool llvm%%LLVM_SUFFIX%%/bin/dsymutil %%EXTRAS%%llvm%%LLVM_SUFFIX%%/bin/find-all-symbols @@ -2729,10 +2729,10 @@ llvm%%LLVM_SUFFIX%%/include/llvm/XRay/YAMLXRayRecord.h %%COMPILER_RT%%llvm%%LLVM_SUFFIX%%/include/xray/xray_interface.h %%COMPILER_RT%%llvm%%LLVM_SUFFIX%%/include/xray/xray_log_interface.h %%COMPILER_RT%%llvm%%LLVM_SUFFIX%%/include/xray/xray_records.h -llvm%%LLVM_SUFFIX%%/lib/CheckerDependencyHandlingAnalyzerPlugin.so -llvm%%LLVM_SUFFIX%%/lib/CheckerOptionHandlingAnalyzerPlugin.so +%%CLANG%%llvm%%LLVM_SUFFIX%%/lib/CheckerDependencyHandlingAnalyzerPlugin.so +%%CLANG%%llvm%%LLVM_SUFFIX%%/lib/CheckerOptionHandlingAnalyzerPlugin.so %%GOLD%%llvm%%LLVM_SUFFIX%%/lib/LLVMgold.so -llvm%%LLVM_SUFFIX%%/lib/SampleAnalyzerPlugin.so +%%CLANG%%llvm%%LLVM_SUFFIX%%/lib/SampleAnalyzerPlugin.so %%CLANG%%llvm%%LLVM_SUFFIX%%/lib/clang/%%LLVM_RELEASE%%/include/__clang_cuda_builtin_vars.h %%CLANG%%llvm%%LLVM_SUFFIX%%/lib/clang/%%LLVM_RELEASE%%/include/__clang_cuda_cmath.h %%CLANG%%%%OPENMP%%llvm%%LLVM_SUFFIX%%/lib/clang/%%LLVM_RELEASE%%/include/__clang_cuda_complex_builtins.h
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910282104.x9SL4Gpt090313>