Sync in bits from base.
Index: Makefile
===================================================================
RCS file: /home/cvs/ports/devel/llvm/Makefile,v
retrieving revision 1.204
diff -u -p -u -p -r1.204 Makefile
--- Makefile 5 Jan 2019 11:38:49 -0000 1.204
+++ Makefile 12 Jan 2019 00:30:58 -0000
@@ -20,9 +20,9 @@ PKGSPEC-main = llvm-=${LLVM_V}
PKGNAME-main = llvm-${LLVM_V}
PKGNAME-python = py-llvm-${LLVM_V}
PKGNAME-lldb = lldb-${LLVM_V}
-REVISION-main = 22
-REVISION-python = 4
-REVISION-lldb = 1
+REVISION-main = 23
+REVISION-python = 5
+REVISION-lldb = 2
CATEGORIES = devel
DISTFILES = llvm-${LLVM_V}.src${EXTRACT_SUFX} \
cfe-${LLVM_V}.src${EXTRACT_SUFX} \
@@ -87,6 +87,15 @@ CONFIGURE_ARGS = -DLLVM_ENABLE_FFI:Bool=
-DLLVM_BUILD_LLVM_DYLIB:Bool=True \
-DGO_EXECUTABLE=GO_EXECUTABLE-NOTFOUND \
-DBacktrace_LIBRARY=''
+
+# Disable some protections in the compiler to regain performance
+.if ${MACHINE_ARCH} == "aarch64" || ${MACHINE_ARCH} == "amd64" || \
+ ${MACHINE_ARCH} == "i386"
+CXXFLAGS += -fno-ret-protector
+.endif
+.if ${MACHINE_ARCH} == "amd64" || ${MACHINE_ARCH} == "i386"
+CXXFLAGS += -mno-retpoline
+.endif
# Workaround relocation overflow
.if ${MACHINE_ARCH} == "powerpc"
Index: patches/patch-lib_Target_X86_X86Subtarget_cpp
===================================================================
RCS file: patches/patch-lib_Target_X86_X86Subtarget_cpp
diff -N patches/patch-lib_Target_X86_X86Subtarget_cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_Target_X86_X86Subtarget_cpp 13 Jan 2019 19:37:30
-0000
@@ -0,0 +1,22 @@
+$OpenBSD$
+
+Turn on -mretpoline by default in clang on amd64.
+
+Index: lib/Target/X86/X86Subtarget.cpp
+--- lib/Target/X86/X86Subtarget.cpp.orig
++++ lib/Target/X86/X86Subtarget.cpp
+@@ -207,6 +207,14 @@ void X86Subtarget::initSubtargetFeatures(StringRef CPU
+ FullFS = "+sahf";
+ }
+
++ // OpenBSD/amd64 defaults to -mretpoline.
++ if (isTargetOpenBSD() && In64BitMode) {
++ if (!FullFS.empty())
++ FullFS = "+retpoline," + FullFS;
++ else
++ FullFS = "+retpoline";
++ }
++
+ // Parse features string and set the CPU.
+ ParseSubtargetFeatures(CPUName, FullFS);
+
Index: patches/patch-lib_Target_X86_X86Subtarget_h
===================================================================
RCS file: patches/patch-lib_Target_X86_X86Subtarget_h
diff -N patches/patch-lib_Target_X86_X86Subtarget_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_Target_X86_X86Subtarget_h 13 Jan 2019 19:37:40 -0000
@@ -0,0 +1,15 @@
+$OpenBSD$
+
+Turn on -mretpoline by default in clang on amd64.
+
+Index: lib/Target/X86/X86Subtarget.h
+--- lib/Target/X86/X86Subtarget.h.orig
++++ lib/Target/X86/X86Subtarget.h
+@@ -603,6 +603,7 @@ class X86Subtarget final : public X86GenSubtargetInfo
+
+ bool isTargetDarwin() const { return TargetTriple.isOSDarwin(); }
+ bool isTargetFreeBSD() const { return TargetTriple.isOSFreeBSD(); }
++ bool isTargetOpenBSD() const { return TargetTriple.isOSOpenBSD(); }
+ bool isTargetDragonFly() const { return TargetTriple.isOSDragonFly(); }
+ bool isTargetSolaris() const { return TargetTriple.isOSSolaris(); }
+ bool isTargetPS4() const { return TargetTriple.isPS4CPU(); }
Index: patches/patch-tools_clang_include_clang_Analysis_Analyses_FormatString_h
===================================================================
RCS file:
patches/patch-tools_clang_include_clang_Analysis_Analyses_FormatString_h
diff -N patches/patch-tools_clang_include_clang_Analysis_Analyses_FormatString_h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-tools_clang_include_clang_Analysis_Analyses_FormatString_h
12 Jan 2019 22:57:25 -0000
@@ -0,0 +1,22 @@
+$OpenBSD$
+
+The %b printf extension in the kernel is not fixed to a int type. On sparc64
+there are various %llb formats. Adjust the code to handle the length specifiers
+and type check like it is used by the regular case.
+
+Index: tools/clang/include/clang/Analysis/Analyses/FormatString.h
+--- tools/clang/include/clang/Analysis/Analyses/FormatString.h.orig
++++ tools/clang/include/clang/Analysis/Analyses/FormatString.h
+@@ -227,8 +227,10 @@ class ConversionSpecifier { (public)
+
+ bool isIntArg() const { return (kind >= IntArgBeg && kind <= IntArgEnd) ||
+ kind == FreeBSDrArg || kind == FreeBSDyArg; }
+- bool isUIntArg() const { return kind >= UIntArgBeg && kind <= UIntArgEnd; }
+- bool isAnyIntArg() const { return kind >= IntArgBeg && kind <= UIntArgEnd; }
++ bool isUIntArg() const { return (kind >= UIntArgBeg && kind <= UIntArgEnd)
||
++ kind == FreeBSDbArg; }
++ bool isAnyIntArg() const { return (kind >= IntArgBeg && kind <= UIntArgEnd)
||
++ kind == FreeBSDbArg; }
+ bool isDoubleArg() const {
+ return kind >= DoubleArgBeg && kind <= DoubleArgEnd;
+ }
Index: patches/patch-tools_clang_lib_Analysis_FormatString_cpp
===================================================================
RCS file: patches/patch-tools_clang_lib_Analysis_FormatString_cpp
diff -N patches/patch-tools_clang_lib_Analysis_FormatString_cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-tools_clang_lib_Analysis_FormatString_cpp 12 Jan 2019
22:57:50 -0000
@@ -0,0 +1,39 @@
+$OpenBSD$
+
+The %b printf extension in the kernel is not fixed to a int type. On sparc64
+there are various %llb formats. Adjust the code to handle the length specifiers
+and type check like it is used by the regular case.
+
+Index: tools/clang/lib/Analysis/FormatString.cpp
+--- tools/clang/lib/Analysis/FormatString.cpp.orig
++++ tools/clang/lib/Analysis/FormatString.cpp
+@@ -706,6 +706,10 @@ bool FormatSpecifier::hasValidLengthModifier(const Tar
+ case ConversionSpecifier::XArg:
+ case ConversionSpecifier::nArg:
+ return true;
++ case ConversionSpecifier::FreeBSDbArg:
++ return Target.getTriple().isOSFreeBSD() ||
++ Target.getTriple().isPS4() ||
++ Target.getTriple().isOSOpenBSD();
+ case ConversionSpecifier::FreeBSDrArg:
+ case ConversionSpecifier::FreeBSDyArg:
+ return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS4();
+@@ -739,6 +743,10 @@ bool FormatSpecifier::hasValidLengthModifier(const Tar
+ case ConversionSpecifier::ScanListArg:
+ case ConversionSpecifier::ZArg:
+ return true;
++ case ConversionSpecifier::FreeBSDbArg:
++ return Target.getTriple().isOSFreeBSD() ||
++ Target.getTriple().isPS4() ||
++ Target.getTriple().isOSOpenBSD();
+ case ConversionSpecifier::FreeBSDrArg:
+ case ConversionSpecifier::FreeBSDyArg:
+ return Target.getTriple().isOSFreeBSD() ||
Target.getTriple().isPS4();
+@@ -897,6 +905,7 @@ bool FormatSpecifier::hasStandardLengthConversionCombi
+ case ConversionSpecifier::uArg:
+ case ConversionSpecifier::xArg:
+ case ConversionSpecifier::XArg:
++ case ConversionSpecifier::FreeBSDbArg:
+ return false;
+ default:
+ return true;
Index: patches/patch-tools_clang_lib_Sema_SemaChecking_cpp
===================================================================
RCS file:
/home/cvs/ports/devel/llvm/patches/patch-tools_clang_lib_Sema_SemaChecking_cpp,v
retrieving revision 1.4
diff -u -p -u -p -r1.4 patch-tools_clang_lib_Sema_SemaChecking_cpp
--- patches/patch-tools_clang_lib_Sema_SemaChecking_cpp 7 Apr 2018 14:55:42
-0000 1.4
+++ patches/patch-tools_clang_lib_Sema_SemaChecking_cpp 12 Jan 2019 22:59:06
-0000
@@ -2,6 +2,9 @@ $OpenBSD: patch-tools_clang_lib_Sema_Sem
- Teach Clang about syslog format attribute
- Enable the kprintf format attribute
+- The %b printf extension in the kernel is not fixed to a int type. On sparc64
+ there are various %llb formats. Adjust the code to handle the length
+ specifiers and type check like it is used by the regular case.
Index: tools/clang/lib/Sema/SemaChecking.cpp
--- tools/clang/lib/Sema/SemaChecking.cpp.orig
@@ -23,7 +26,52 @@ Index: tools/clang/lib/Sema/SemaChecking
Diag(FormatLoc, diag::note_format_security_fixit)
<< FixItHint::CreateInsertion(FormatLoc, "\"%s\", ");
break;
-@@ -6777,8 +6778,9 @@ static void CheckFormatString(Sema &S, const FormatStr
+@@ -6053,19 +6054,33 @@ CheckPrintfHandler::HandlePrintfSpecifier(const analyz
+ // Claim the second argument.
+ CoveredArgs.set(argIndex + 1);
+
+- // Type check the first argument (int for %b, pointer for %D)
+ const Expr *Ex = getDataArg(argIndex);
+- const analyze_printf::ArgType &AT =
+- (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ?
+- ArgType(S.Context.IntTy) : ArgType::CPointerTy;
+- if (AT.isValid() && !AT.matchesType(S.Context, Ex->getType()))
+- EmitFormatDiagnostic(
+- S.PDiag(diag::warn_format_conversion_argument_type_mismatch)
+- << AT.getRepresentativeTypeName(S.Context) << Ex->getType()
+- << false << Ex->getSourceRange(),
+- Ex->getLocStart(), /*IsStringLocation*/false,
+- getSpecifierRange(startSpecifier, specifierLen));
++ if (CS.getKind() == ConversionSpecifier::FreeBSDDArg) {
++ // Type check the first argument (pointer for %D)
++ const analyze_printf::ArgType &AT = ArgType::CPointerTy;
++ if (AT.isValid() && !AT.matchesType(S.Context, Ex->getType()))
++ EmitFormatDiagnostic(
++ S.PDiag(diag::warn_format_conversion_argument_type_mismatch)
++ << AT.getRepresentativeTypeName(S.Context) << Ex->getType()
++ << false << Ex->getSourceRange(),
++ Ex->getLocStart(), /*IsStringLocation*/false,
++ getSpecifierRange(startSpecifier, specifierLen));
++ } else {
++ // Check the length modifier for %b
++ if (!FS.hasValidLengthModifier(S.getASTContext().getTargetInfo()))
++ HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
++ diag::warn_format_nonsensical_length);
++ else if (!FS.hasStandardLengthModifier())
++ HandleNonStandardLengthModifier(FS, startSpecifier, specifierLen);
++ else if (!FS.hasStandardLengthConversionCombination())
++ HandleInvalidLengthModifier(FS, CS, startSpecifier, specifierLen,
++
diag::warn_format_non_standard_conversion_spec);
+
++ // Type check the first argument of %b
++ if (!checkFormatExpr(FS, startSpecifier, specifierLen, Ex))
++ return false;
++ }
++
+ // Type check the second argument (char * for both %b and %D)
+ Ex = getDataArg(argIndex + 1);
+ const analyze_printf::ArgType &AT2 = ArgType::CStrTy;
+@@ -6777,8 +6792,9 @@ static void CheckFormatString(Sema &S, const FormatStr
}
if (Type == Sema::FST_Printf || Type == Sema::FST_NSString ||
@@ -35,7 +83,7 @@ Index: tools/clang/lib/Sema/SemaChecking
CheckPrintfHandler H(
S, FExpr, OrigFormatExpr, Type, firstDataArg, numDataArgs,
(Type == Sema::FST_NSString || Type == Sema::FST_OSTrace), Str,
-@@ -6788,7 +6790,7 @@ static void CheckFormatString(Sema &S, const FormatStr
+@@ -6788,7 +6804,7 @@ static void CheckFormatString(Sema &S, const FormatStr
if (!analyze_format_string::ParsePrintfString(H, Str, Str + StrLen,
S.getLangOpts(),
S.Context.getTargetInfo(),