add llvm90

This commit is contained in:
ziggi
2020-01-19 12:54:05 +00:00
parent 21a3948ca8
commit 21fd60ca70
12 changed files with 3024 additions and 0 deletions

60
devel/llvm90/Makefile Normal file
View File

@@ -0,0 +1,60 @@
# $FreeBSD: head/devel/llvm80/Makefile 499184 2019-04-17 16:20:06Z brooks $
PORTNAME= llvm
DISTVERSION= 9.0.0
CATEGORIES= devel lang
MASTER_SITES= http://${PRE_}releases.llvm.org/${LLVM_RELEASE}/${RCDIR}
#PKGNAMESUFFIX= ${LLVM_SUFFIX}
DISTNAME= ${PORTNAME}-${DISTVERSION}.src
DISTFILES= ${PORTNAME}-${DISTVERSION}.src${EXTRACT_SUFX}
MAINTAINER= brooks@FreeBSD.org
COMMENT= LLVM and Clang
LLVM_RELEASE= ${DISTVERSION:C/rc.*//}
RCDIR= ${DISTVERSION:S/${LLVM_RELEASE}//:C|(rc.*)|\1/|}
PRE_= ${DISTVERSION:C/.*rc.*/pre/:N*[0-9]*}
DOCSDIR= ${PREFIX}/share/doc/${PORTNAME}
DATADIR= ${PREFIX}/share/${PORTNAME}
USES= cmake compiler:c++11-lib perl5 tar:xz shebangfix python:2.7,build
SHEBANG_FILES= utils/lit/lit.py utils/llvm-lit/llvm-lit.in \
tools/opt-viewer/optrecord.py \
tools/opt-viewer/opt-diff.py \
tools/opt-viewer/opt-stats.py \
tools/opt-viewer/opt-viewer.py
CMAKE_ARGS= -DLLVM_BUILD_LLVM_DYLIB=ON
CMAKE_ARGS= -DLLVM_LINK_LLVM_DYLIB=ON
CMAKE_ARGS+= -DLLVM_ENABLE_RTTI=ON
CMAKE_ARGS+= -DLLVM_DEFAULT_TARGET_TRIPLE=${CONFIGURE_TARGET}
CMAKE_ARGS+= -DLLVM_HOST_TRIPLE=${CONFIGURE_TARGET}
CMAKE_ARGS+= -DCMAKE_INSTALL_MANDIR:PATH="man"
CMAKE_ARGS+= -DLLVM_PARALLEL_LINK_JOBS=1
CFLAGS+= -DNDEBUG
CXXFLAGS+= -DNDEBUG
.include <bsd.port.options.mk>
CONFIGURE_TARGET:=${ARCH:C/amd64/x86_64/:C/arm64/aarch64/}-pc-${OPSYS:tl}${OSREL}${TARGET_ABI}
DISTFILES+= cfe-${DISTVERSION}.src${EXTRACT_SUFX}
#DISTFILES+= clang-tools-extra-${DISTVERSION}.src${EXTRACT_SUFX}
DISTFILES+= lld-${DISTVERSION}.src${EXTRACT_SUFX}
WRKSRC_CLANG= ${WRKDIR}/cfe-${PORTVERSION}.src
#WRKSRC_EXTRA= ${WRKDIR}/clang-tools-extra-${PORTVERSION}.src
WRKSRC_LLD= ${WRKDIR}/lld-${PORTVERSION}.src
#NATIVE_BACKENDS=X86
#CMAKE_ARGS+= -DLLVM_TARGETS_TO_BUILD="${NATIVE_BACKENDS}"
post-extract:
${MV} ${WRKSRC_CLANG} ${PATCH_WRKSRC}/tools/clang
# ${MV} ${WRKSRC_EXTRA} ${PATCH_WRKSRC}/tools/clang/tools/extra
${MV} ${WRKSRC_LLD} ${PATCH_WRKSRC}/tools/lld
.include <bsd.port.mk>

9
devel/llvm90/distinfo Normal file
View File

@@ -0,0 +1,9 @@
TIMESTAMP = 1579159025
SHA256 (llvm-9.0.0.src.tar.xz) = d6a0565cf21f22e9b4353b2eb92622e8365000a9e90a16b09b56f8157eabfe84
SIZE (llvm-9.0.0.src.tar.xz) = 32994768
SHA256 (cfe-9.0.0.src.tar.xz) = 7ba81eef7c22ca5da688fdf9d88c20934d2d6b40bfe150ffd338900890aa4610
SIZE (cfe-9.0.0.src.tar.xz) = 13533024
SHA256 (clang-tools-extra-9.0.0.src.tar.xz) = ea1c86ce352992d7b6f6649bc622f6a2707b9f8b7153e9f9181a35c76aa3ac10
SIZE (clang-tools-extra-9.0.0.src.tar.xz) = 2183436
SHA256 (lld-9.0.0.src.tar.xz) = 31c6748b235d09723fb73fea0c816ed5a3fab0f96b66f8fbc546a0fcc8688f91
SIZE (lld-9.0.0.src.tar.xz) = 1100608

View File

@@ -0,0 +1,44 @@
diff -ruN tools/clang/include/clang/Basic/LangOptions.def tools/clang/include/clang/Basic/LangOptions.def
--- tools/clang/include/clang/Basic/LangOptions.def 2015-07-30 22:47:41 UTC
+++ tools/clang/include/clang/Basic/LangOptions.def
@@ -114,6 +114,7 @@
LANGOPT(RTTIData , 1, 1, "emit run-time type information data")
LANGOPT(MSBitfields , 1, 0, "Microsoft-compatible structure layout")
LANGOPT(Freestanding, 1, 0, "freestanding implementation")
+LANGOPT(FormatExtensions , 1, 0, "FreeBSD format extensions")
LANGOPT(NoBuiltin , 1, 0, "disable builtin functions")
LANGOPT(NoMathBuiltin , 1, 0, "disable math builtin functions")
LANGOPT(GNUAsm , 1, 1, "GNU-style inline assembly")
diff -ruN tools/clang/include/clang/Driver/Options.td tools/clang/include/clang/Driver/Options.td
--- tools/clang/include/clang/Driver/Options.td 2015-07-30 22:47:41 UTC
+++ tools/clang/include/clang/Driver/Options.td
@@ -644,6 +644,8 @@
def ffreestanding : Flag<["-"], "ffreestanding">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Assert that the compilation takes place in a freestanding environment">;
+def fformat_extensions: Flag<["-"], "fformat-extensions">, Group<f_Group>, Flags<[CC1Option]>,
+ HelpText<"Enable FreeBSD kernel specific format string extensions">;
def fgnu_keywords : Flag<["-"], "fgnu-keywords">, Group<f_Group>, Flags<[CC1Option]>,
HelpText<"Allow GNU-extension keywords regardless of language standard">;
def fgnu89_inline : Flag<["-"], "fgnu89-inline">, Group<f_Group>, Flags<[CC1Option]>,
--- tools/clang/lib/Driver/ToolChains/Clang.cpp.orig 2017-09-14 19:36:28.212240000 +0100
+++ tools/clang/lib/Driver/ToolChains/Clang.cpp 2017-09-14 19:35:59.296165000 +0100
@@ -3202,6 +3202,7 @@
// Forward -f (flag) options which we can pass directly.
Args.AddLastArg(CmdArgs, options::OPT_femit_all_decls);
+ Args.AddLastArg(CmdArgs, options::OPT_fformat_extensions);
Args.AddLastArg(CmdArgs, options::OPT_fheinous_gnu_extensions);
Args.AddLastArg(CmdArgs, options::OPT_fno_operator_names);
// Emulated TLS is enabled by default on Android and OpenBSD, and can be enabled
diff -ruN tools/clang/lib/Frontend/CompilerInvocation.cpp tools/clang/lib/Frontend/CompilerInvocation.cpp
--- tools/clang/lib/Frontend/CompilerInvocation.cpp 2015-07-30 22:47:41 UTC
+++ tools/clang/lib/Frontend/CompilerInvocation.cpp
@@ -1543,6 +1543,7 @@
Opts.ShortWChar = Args.hasFlag(OPT_fshort_wchar, OPT_fno_short_wchar, false);
Opts.ShortEnums = Args.hasArg(OPT_fshort_enums);
Opts.Freestanding = Args.hasArg(OPT_ffreestanding);
+ Opts.FormatExtensions = Args.hasArg(OPT_fformat_extensions);
Opts.NoBuiltin = Args.hasArg(OPT_fno_builtin) || Opts.Freestanding;
Opts.NoMathBuiltin = Args.hasArg(OPT_fno_math_builtin);
Opts.AssumeSaneOperatorNew = !Args.hasArg(OPT_fno_assume_sane_operator_new);

View File

@@ -0,0 +1,14 @@
--- tools/clang/lib/Driver/ToolChains/CommonArgs.cpp.orig 2017-05-10 17:18:56.000000000 +0000
+++ tools/clang/lib/Driver/ToolChains/CommonArgs.cpp 2017-05-10 23:01:17.087686000 +0000
@@ -441,7 +441,10 @@
switch (TC.getDriver().getOpenMPRuntime(Args)) {
case Driver::OMPRT_OMP:
- CmdArgs.push_back("-lomp");
+ if (TC.getTriple().getOS() != llvm::Triple::FreeBSD || TC.isCrossCompiling() || !llvm::sys::fs::exists("%%LLVM_PREFIX%%/lib/libomp.so"))
+ CmdArgs.push_back("-lomp");
+ else
+ CmdArgs.push_back("%%LLVM_PREFIX%%/lib/libomp.so");
break;
case Driver::OMPRT_GOMP:
CmdArgs.push_back("-lgomp");

View File

@@ -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:

View File

@@ -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();

View File

@@ -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;

View File

@@ -0,0 +1,12 @@
--- tools/clang/lib/Driver/ToolChains/Arch/PPC.cpp.orig
+++ tools/clang/lib/Driver/ToolChains/Arch/PPC.cpp
@@ -115,7 +115,8 @@
const ArgList &Args) {
if (Args.getLastArg(options::OPT_msecure_plt))
return ppc::ReadGOTPtrMode::SecurePlt;
- if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
+ if ((Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 13) ||
+ Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
return ppc::ReadGOTPtrMode::SecurePlt;
else
return ppc::ReadGOTPtrMode::Bss;

View File

@@ -0,0 +1,32 @@
--- tools/clang/lib/Headers/CMakeLists.txt.orig
+++ tools/clang/lib/Headers/CMakeLists.txt
@@ -56,7 +56,6 @@
intrin.h
inttypes.h
iso646.h
- limits.h
lwpintrin.h
lzcntintrin.h
mm3dnow.h
@@ -76,21 +75,13 @@
s390intrin.h
shaintrin.h
smmintrin.h
- stdalign.h
- stdarg.h
- stdatomic.h
- stdbool.h
- stddef.h
__stddef_max_align_t.h
- stdint.h
- stdnoreturn.h
tbmintrin.h
tgmath.h
tmmintrin.h
unwind.h
vadefs.h
vaesintrin.h
- varargs.h
vecintrin.h
vpclmulqdqintrin.h
wmmintrin.h

View File

@@ -0,0 +1,12 @@
--- tools/clang/tools/scan-build/libexec/ccc-analyzer.orig
+++ tools/clang/tools/scan-build/libexec/ccc-analyzer
@@ -81,6 +81,9 @@
if (-x "/usr/bin/xcrun") {
$UseXCRUN = 1;
}
+} elsif (`uname -s` eq "FreeBSD\n") {
+ $DefaultCCompiler = 'cc';
+ $DefaultCXXCompiler = 'c++';
} else {
$DefaultCCompiler = 'gcc';
$DefaultCXXCompiler = 'g++';

8
devel/llvm90/pkg-descr Normal file
View File

@@ -0,0 +1,8 @@
The LLVM Project is a collection of modular and reusable compiler and
toolchain technologies.
This port includes Clang (a C/C++/Objective-C compiler), LLD (a linker),
LLDB (a debugger), an OpenMP runtime library, and the LLVM infrastructure
these are built on.
WWW: http://llvm.org/

2602
devel/llvm90/pkg-plist Normal file

File diff suppressed because it is too large Load Diff