Author: dim Date: Tue Mar 18 22:07:45 2014 New Revision: 263320 URL: http://svnweb.freebsd.org/changeset/base/263320
Log: Add separate patch files for all the customizations we have currently applied to our copy of llvm/clang. These can be applied in alphabetical order to a pristine llvm/clang 3.4 release source tree, to result in the same version used in FreeBSD. This is intended to clearly document all the changes until now, which mostly consist of cherry pickings from the respective upstream trunks, plus a number of hand-written FreeBSD-specific ones. Hopefully those can eventually be cleaned up and sent upstream too. MFC after: 1 week X-MFC-With: r263313 Added: head/contrib/llvm/patches/ head/contrib/llvm/patches/README.TXT (contents, props changed) head/contrib/llvm/patches/patch-r208961-clang-version-include.diff (contents, props changed) head/contrib/llvm/patches/patch-r208987-format-extensions.diff (contents, props changed) head/contrib/llvm/patches/patch-r209107-clang-vendor-suffix.diff (contents, props changed) head/contrib/llvm/patches/patch-r213492-amd64-multi-os-dot.diff (contents, props changed) head/contrib/llvm/patches/patch-r221503-default-target-triple.diff (contents, props changed) head/contrib/llvm/patches/patch-r243830-arm-disable-clear-cache.diff (contents, props changed) head/contrib/llvm/patches/patch-r252503-arm-transient-stack-alignment.diff (contents, props changed) head/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff (contents, props changed) head/contrib/llvm/patches/patch-r259053-gcc-installation-detector.diff (contents, props changed) head/contrib/llvm/patches/patch-r259498-add-fxsave.diff (contents, props changed) head/contrib/llvm/patches/patch-r261680-clang-r200899-fix-security-quantis.diff (contents, props changed) head/contrib/llvm/patches/patch-r261991-llvm-r195391-fix-dwarf2.diff (contents, props changed) head/contrib/llvm/patches/patch-r261991-llvm-r198385-fix-dwarf2.diff (contents, props changed) head/contrib/llvm/patches/patch-r261991-llvm-r198389-fix-dwarf2.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198028-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198029-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198030-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198145-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198149-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198157-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198280-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198281-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198286-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198480-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198484-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198533-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198565-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198567-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198580-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198591-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198592-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198658-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198681-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198738-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198739-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198740-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198893-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198909-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r198910-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199014-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199024-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199028-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199031-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199033-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199061-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199186-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199187-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199775-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199781-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199786-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199940-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199974-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199975-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r199977-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200103-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200104-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200112-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200130-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200131-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200141-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200282-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200368-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200373-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200376-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200509-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200617-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200960-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200961-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200962-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200963-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262261-llvm-r200965-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r198311-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r198312-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r198911-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r198912-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r198918-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r198923-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r199012-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r199034-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r199037-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r199188-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r199399-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262262-clang-r200452-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262264-llvm-r200453-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262265-llvm-r201718-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262303-enable-ppc-integrated-as.diff (contents, props changed) head/contrib/llvm/patches/patch-r262415-llvm-r201994-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262460-llvm-r202059-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262535-clang-r202177-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262536-clang-r202179-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262582-llvm-r202422-sparc.diff (contents, props changed) head/contrib/llvm/patches/patch-r262611-llvm-r196874-fix-invalid-pwd-crash.diff (contents, props changed) head/contrib/llvm/patches/patch-r262809-clang-r203007-destructor-calling-conv.diff (contents, props changed) head/contrib/llvm/patches/patch-r263048-clang-r203624-fix-CC-aliases.diff (contents, props changed) head/contrib/llvm/patches/patch-r263312-llvm-r169939-inline-asm-with-realign.diff (contents, props changed) head/contrib/llvm/patches/patch-r263312-llvm-r196940-update-inline-asm-test.diff (contents, props changed) head/contrib/llvm/patches/patch-r263312-llvm-r196986-allow-realign-alloca.diff (contents, props changed) head/contrib/llvm/patches/patch-r263312-llvm-r202930-fix-alloca-esi-clobber.diff (contents, props changed) head/contrib/llvm/patches/patch-r263313-llvm-r203311-fix-sse1-oom.diff (contents, props changed) Added: head/contrib/llvm/patches/README.TXT ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/README.TXT Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,16 @@ +This is a set of individual patches, which contain all the customizations to +llvm/clang currently in the FreeBSD base system. These can be applied in +alphabetical order to a pristine llvm/clang 3.4 release source tree, for example +by doing: + +svn co https://llvm.org/svn/llvm-project/llvm/tags/RELEASE_34/final llvm-3.4-final +svn co https://llvm.org/svn/llvm-project/cfe/tags/RELEASE_34/final llvm-3.4-final/tools/clang +cd llvm-3.4-final +for p in /usr/src/contrib/llvm/patches/patch-*.diff; do + patch -p0 -f -F0 -E -i $p -s || break +done + +A number of these consist of hand-written modifications, specifically for +FreeBSD, while most others are cherry pickings off the llvm and clang trunks. +When a new version of llvm/clang is eventually imported, those latter ones will +largely disappear. Added: head/contrib/llvm/patches/patch-r208961-clang-version-include.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r208961-clang-version-include.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,39 @@ +This patch adjusts clang's default include paths to add FreeBSD-specific +directories. + +Introduced here: http://svn.freebsd.org/changeset/base/208961 + +Index: tools/clang/lib/Frontend/InitHeaderSearch.cpp +=================================================================== +--- tools/clang/lib/Frontend/InitHeaderSearch.cpp ++++ tools/clang/lib/Frontend/InitHeaderSearch.cpp +@@ -14,6 +14,7 @@ + #include "clang/Frontend/Utils.h" + #include "clang/Basic/FileManager.h" + #include "clang/Basic/LangOptions.h" ++#include "clang/Basic/Version.h" + #include "clang/Config/config.h" // C_INCLUDE_DIRS + #include "clang/Lex/HeaderSearch.h" + #include "clang/Lex/HeaderSearchOptions.h" +@@ -333,6 +334,9 @@ void InitHeaderSearch::AddDefaultCIncludePaths(con + #endif + } + break; ++ case llvm::Triple::FreeBSD: ++ AddPath("/usr/include/clang/" CLANG_VERSION_STRING, System, false); ++ break; + + default: + break; +@@ -423,11 +427,6 @@ AddDefaultCPlusPlusIncludePaths(const llvm::Triple + else + AddPath("/usr/include/c++/4.4", CXXSystem, false); + break; +- case llvm::Triple::FreeBSD: +- // FreeBSD 8.0 +- // FreeBSD 7.3 +- AddGnuCPlusPlusIncludePaths("/usr/include/c++/4.2", "", "", "", triple); +- break; + case llvm::Triple::OpenBSD: { + std::string t = triple.getTriple(); + if (t.substr(0, 6) == "x86_64") Added: head/contrib/llvm/patches/patch-r208987-format-extensions.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r208987-format-extensions.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,214 @@ +This patch adds support for the FreeBSD-specific -fformat-extension option, +which enables additional printf modifiers for the kernel. + +Introduced here: http://svn.freebsd.org/changeset/base/208987 + +Index: tools/clang/lib/Frontend/CompilerInvocation.cpp +=================================================================== +--- tools/clang/lib/Frontend/CompilerInvocation.cpp ++++ tools/clang/lib/Frontend/CompilerInvocation.cpp +@@ -1319,6 +1319,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgLi + Opts.ShortWChar = Args.hasArg(OPT_fshort_wchar); + 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); +Index: tools/clang/lib/Analysis/FormatString.cpp +=================================================================== +--- tools/clang/lib/Analysis/FormatString.cpp ++++ tools/clang/lib/Analysis/FormatString.cpp +@@ -548,6 +548,11 @@ const char *ConversionSpecifier::toString() const + // Objective-C specific specifiers. + case ObjCObjArg: return "@"; + ++ // FreeBSD specific specifiers. ++ case FreeBSDbArg: return "b"; ++ case FreeBSDDArg: return "D"; ++ case FreeBSDrArg: return "r"; ++ + // GlibC specific specifiers. + case PrintErrno: return "m"; + } +@@ -626,6 +631,7 @@ bool FormatSpecifier::hasValidLengthModifier(const + case ConversionSpecifier::xArg: + case ConversionSpecifier::XArg: + case ConversionSpecifier::nArg: ++ case ConversionSpecifier::FreeBSDrArg: + return true; + default: + return false; +@@ -654,6 +660,7 @@ bool FormatSpecifier::hasValidLengthModifier(const + case ConversionSpecifier::nArg: + case ConversionSpecifier::cArg: + case ConversionSpecifier::sArg: ++ case ConversionSpecifier::FreeBSDrArg: + case ConversionSpecifier::ScanListArg: + return true; + default: +@@ -774,6 +781,9 @@ bool FormatSpecifier::hasStandardConversionSpecifi + case ConversionSpecifier::SArg: + return LangOpt.ObjC1 || LangOpt.ObjC2; + case ConversionSpecifier::InvalidSpecifier: ++ case ConversionSpecifier::FreeBSDbArg: ++ case ConversionSpecifier::FreeBSDDArg: ++ case ConversionSpecifier::FreeBSDrArg: + case ConversionSpecifier::PrintErrno: + case ConversionSpecifier::DArg: + case ConversionSpecifier::OArg: +Index: tools/clang/lib/Analysis/PrintfFormatString.cpp +=================================================================== +--- tools/clang/lib/Analysis/PrintfFormatString.cpp ++++ tools/clang/lib/Analysis/PrintfFormatString.cpp +@@ -198,10 +198,25 @@ static PrintfSpecifierResult ParsePrintfSpecifier( + case '@': k = ConversionSpecifier::ObjCObjArg; break; + // Glibc specific. + case 'm': k = ConversionSpecifier::PrintErrno; break; ++ // FreeBSD format extensions ++ case 'b': ++ if (LO.FormatExtensions) ++ k = ConversionSpecifier::FreeBSDbArg; // int followed by char * ++ break; ++ case 'r': ++ if (LO.FormatExtensions) ++ k = ConversionSpecifier::FreeBSDrArg; ++ break; ++ case 'y': ++ if (LO.FormatExtensions) ++ k = ConversionSpecifier::iArg; ++ break; + // Apple-specific + case 'D': + if (Target.getTriple().isOSDarwin()) + k = ConversionSpecifier::DArg; ++ else if (LO.FormatExtensions) ++ k = ConversionSpecifier::FreeBSDDArg; // u_char * followed by char * + break; + case 'O': + if (Target.getTriple().isOSDarwin()) +@@ -216,6 +231,10 @@ static PrintfSpecifierResult ParsePrintfSpecifier( + FS.setConversionSpecifier(CS); + if (CS.consumesDataArgument() && !FS.usesPositionalArg()) + FS.setArgIndex(argIndex++); ++ // FreeBSD extension ++ if (k == ConversionSpecifier::FreeBSDbArg || ++ k == ConversionSpecifier::FreeBSDDArg) ++ argIndex++; + + if (k == ConversionSpecifier::InvalidSpecifier) { + // Assume the conversion takes one argument. +@@ -618,6 +637,7 @@ bool PrintfSpecifier::hasValidPlusPrefix() const { + case ConversionSpecifier::GArg: + case ConversionSpecifier::aArg: + case ConversionSpecifier::AArg: ++ case ConversionSpecifier::FreeBSDrArg: + return true; + + default: +@@ -643,6 +663,7 @@ bool PrintfSpecifier::hasValidAlternativeForm() co + case ConversionSpecifier::FArg: + case ConversionSpecifier::gArg: + case ConversionSpecifier::GArg: ++ case ConversionSpecifier::FreeBSDrArg: + return true; + + default: +Index: tools/clang/lib/Sema/SemaChecking.cpp +=================================================================== +--- tools/clang/lib/Sema/SemaChecking.cpp ++++ tools/clang/lib/Sema/SemaChecking.cpp +@@ -2980,6 +2980,40 @@ CheckPrintfHandler::HandlePrintfSpecifier(const an + CoveredArgs.set(argIndex); + } + ++ // FreeBSD extensions ++ if (CS.getKind() == ConversionSpecifier::FreeBSDbArg || ++ CS.getKind() == ConversionSpecifier::FreeBSDDArg) { ++ // claim the second argument ++ CoveredArgs.set(argIndex + 1); ++ ++ // Now type check the data expression that matches the ++ // format specifier. ++ const Expr *Ex = getDataArg(argIndex); ++ const analyze_printf::ArgType &AT = ++ (CS.getKind() == ConversionSpecifier::FreeBSDbArg) ? ++ ArgType(S.Context.IntTy) : ArgType::CStrTy; ++ if (AT.isValid() && !AT.matchesType(S.Context, Ex->getType())) ++ S.Diag(getLocationOfByte(CS.getStart()), ++ diag::warn_printf_conversion_argument_type_mismatch) ++ << AT.getRepresentativeType(S.Context) << Ex->getType() ++ << getSpecifierRange(startSpecifier, specifierLen) ++ << Ex->getSourceRange(); ++ ++ // Now type check the data expression that matches the ++ // format specifier. ++ Ex = getDataArg(argIndex + 1); ++ const analyze_printf::ArgType &AT2 = ArgType::CStrTy; ++ if (AT2.isValid() && !AT2.matchesType(S.Context, Ex->getType())) ++ S.Diag(getLocationOfByte(CS.getStart()), ++ diag::warn_printf_conversion_argument_type_mismatch) ++ << AT2.getRepresentativeType(S.Context) << Ex->getType() ++ << getSpecifierRange(startSpecifier, specifierLen) ++ << Ex->getSourceRange(); ++ ++ return true; ++ } ++ // END OF FREEBSD EXTENSIONS ++ + // Check for using an Objective-C specific conversion specifier + // in a non-ObjC literal. + if (!ObjCContext && CS.isObjCArg()) { +Index: tools/clang/lib/Driver/Tools.cpp +=================================================================== +--- tools/clang/lib/Driver/Tools.cpp ++++ tools/clang/lib/Driver/Tools.cpp +@@ -2991,6 +2991,7 @@ void Clang::ConstructJob(Compilation &C, const Job + + // 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_flimit_debug_info); + Args.AddLastArg(CmdArgs, options::OPT_fno_limit_debug_info); +Index: tools/clang/include/clang/Basic/LangOptions.def +=================================================================== +--- tools/clang/include/clang/Basic/LangOptions.def ++++ tools/clang/include/clang/Basic/LangOptions.def +@@ -84,6 +84,7 @@ LANGOPT(TraditionalCPP , 1, 0, "traditional CPP + LANGOPT(RTTI , 1, 1, "run-time type information") + 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") + +Index: tools/clang/include/clang/Analysis/Analyses/FormatString.h +=================================================================== +--- tools/clang/include/clang/Analysis/Analyses/FormatString.h ++++ tools/clang/include/clang/Analysis/Analyses/FormatString.h +@@ -158,6 +158,11 @@ class ConversionSpecifier { + ObjCObjArg, // '@' + ObjCBeg = ObjCObjArg, ObjCEnd = ObjCObjArg, + ++ // FreeBSD specific specifiers ++ FreeBSDbArg, ++ FreeBSDDArg, ++ FreeBSDrArg, ++ + // GlibC specific specifiers. + PrintErrno, // 'm' + +Index: tools/clang/include/clang/Driver/Options.td +=================================================================== +--- tools/clang/include/clang/Driver/Options.td ++++ tools/clang/include/clang/Driver/Options.td +@@ -530,6 +530,8 @@ def fno_rewrite_includes : Flag<["-"], "fno-rewrit + + 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]>, Added: head/contrib/llvm/patches/patch-r209107-clang-vendor-suffix.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r209107-clang-vendor-suffix.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,22 @@ +This patch adds a FreeBSD-specific suffix to clang's version string. This is +usually of the form "(yyyyddmm)", representing the date when the compiler was +last updated. + +Introduced here: http://svn.freebsd.org/changeset/base/209107 + +Index: tools/clang/lib/Basic/Version.cpp +=================================================================== +--- tools/clang/lib/Basic/Version.cpp ++++ tools/clang/lib/Basic/Version.cpp +@@ -124,8 +124,10 @@ std::string getClangFullVersion() { + OS << "clang version " CLANG_VERSION_STRING " " + << getClangFullRepositoryVersion(); + ++#ifdef CLANG_VENDOR_SUFFIX ++ OS << CLANG_VENDOR_SUFFIX; ++#elif defined(CLANG_VENDOR) + // If vendor supplied, include the base LLVM version as well. +-#ifdef CLANG_VENDOR + OS << " (based on LLVM " << PACKAGE_VERSION << ")"; + #endif + Added: head/contrib/llvm/patches/patch-r213492-amd64-multi-os-dot.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r213492-amd64-multi-os-dot.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,18 @@ +This patch makes "clang -print-multi-os-directory" print "." on amd64, which is +required by certain ports. + +Introduced here: http://svn.freebsd.org/changeset/base/213492 + +Index: tools/clang/lib/Driver/Driver.cpp +=================================================================== +--- tools/clang/lib/Driver/Driver.cpp ++++ tools/clang/lib/Driver/Driver.cpp +@@ -780,7 +780,7 @@ bool Driver::HandleImmediateArgs(const Compilation + break; + + case llvm::Triple::x86_64: +- llvm::outs() << "x86_64" << "\n"; ++ llvm::outs() << "." << "\n"; + break; + + case llvm::Triple::ppc64: Added: head/contrib/llvm/patches/patch-r221503-default-target-triple.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r221503-default-target-triple.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,26 @@ +This patch ensures the target triple that is passed during the compiler build is +respected, instead of mangling it. + +Introduced here: http://svn.freebsd.org/changeset/base/221503 + +Index: lib/Support/Unix/Host.inc +=================================================================== +--- lib/Support/Unix/Host.inc ++++ lib/Support/Unix/Host.inc +@@ -26,6 +26,11 @@ + + using namespace llvm; + ++#ifdef __FreeBSD__ ++std::string sys::getDefaultTargetTriple() { ++ return LLVM_DEFAULT_TARGET_TRIPLE; ++} ++#else // __FreeBSD__ + static std::string getOSVersion() { + struct utsname info; + +@@ -61,3 +66,4 @@ std::string sys::getDefaultTargetTriple() { + + return Triple; + } ++#endif // __FreeBSD__ Added: head/contrib/llvm/patches/patch-r243830-arm-disable-clear-cache.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r243830-arm-disable-clear-cache.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,19 @@ +This patch ensures __clear_cache is not called on arm. In earlier versions of +clang, this special builtin was emitted as a function call, leading to link +errors. + +Introduced here: http://svn.freebsd.org/changeset/base/243830 + +Index: lib/Support/Unix/Memory.inc +=================================================================== +--- lib/Support/Unix/Memory.inc ++++ lib/Support/Unix/Memory.inc +@@ -332,7 +332,7 @@ void Memory::InvalidateInstructionCache(const void + for (intptr_t Line = StartLine; Line < EndLine; Line += LineSize) + asm volatile("icbi 0, %0" : : "r"(Line)); + asm volatile("isync"); +-# elif (defined(__arm__) || defined(__aarch64__)) && defined(__GNUC__) ++# elif (defined(__arm__) || defined(__aarch64__)) && defined(__GNUC__) && !defined(__FreeBSD__) + // FIXME: Can we safely always call this for __GNUC__ everywhere? + const char *Start = static_cast<const char *>(Addr); + const char *End = Start + Len; Added: head/contrib/llvm/patches/patch-r252503-arm-transient-stack-alignment.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r252503-arm-transient-stack-alignment.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,79 @@ +This patch applies a workaround for an ARM EABI issue, where clang would +sometimes incorrectly align the stack in a leaf function that uses TLS. + +Introduced here: http://svn.freebsd.org/changeset/base/252503 + +Index: test/CodeGen/Thumb2/large-stack.ll +=================================================================== +--- test/CodeGen/Thumb2/large-stack.ll ++++ test/CodeGen/Thumb2/large-stack.ll +@@ -13,7 +13,7 @@ define void @test1() { + define void @test2() { + ; DARWIN-LABEL: test2: + ; DARWIN: sub.w sp, sp, #4160 +-; DARWIN: sub sp, #8 ++; DARWIN: sub sp, #12 + ; LINUX-LABEL: test2: + ; LINUX: sub.w sp, sp, #4160 + ; LINUX: sub sp, #8 +Index: test/CodeGen/ARM/2009-10-30.ll +=================================================================== +--- test/CodeGen/ARM/2009-10-30.ll ++++ test/CodeGen/ARM/2009-10-30.ll +@@ -4,9 +4,10 @@ + + define void @f(i32 %a1, i32 %a2, i32 %a3, i32 %a4, i32 %a5, ...) { + entry: +-;CHECK: sub sp, sp, #4 +-;CHECK: add r{{[0-9]+}}, sp, #8 +-;CHECK: str r{{[0-9]+}}, [sp], #4 ++;CHECK: sub sp, sp, #8 ++;CHECK: add r{{[0-9]+}}, sp, #12 ++;CHECK: str r{{[0-9]+}}, [sp, #4] ++;CHECK: add sp, sp, #8 + ;CHECK: bx lr + %ap = alloca i8*, align 4 + %ap1 = bitcast i8** %ap to i8* +Index: test/CodeGen/ARM/vargs_align.ll +=================================================================== +--- test/CodeGen/ARM/vargs_align.ll ++++ test/CodeGen/ARM/vargs_align.ll +@@ -15,8 +15,8 @@ entry: + return: ; preds = %entry + %retval2 = load i32* %retval ; <i32> [#uses=1] + ret i32 %retval2 +-; EABI: add sp, sp, #12 + ; EABI: add sp, sp, #16 ++; EABI: add sp, sp, #16 ++; OABI: add sp, sp, #16 + ; OABI: add sp, sp, #12 +-; OABI: add sp, sp, #12 + } +Index: test/CodeGen/ARM/prefetch-thumb.ll +=================================================================== +--- test/CodeGen/ARM/prefetch-thumb.ll ++++ test/CodeGen/ARM/prefetch-thumb.ll +@@ -10,8 +10,8 @@ entry: + ;ARM: pld [sp, #50] + + ;THUMB2: t6: +-;THUMB2: pld [sp] +-;THUMB2: pld [sp, #50] ++;THUMB2: pld [sp, #4] ++;THUMB2: pld [sp, #54] + + %red = alloca [100 x i8], align 1 + %0 = getelementptr inbounds [100 x i8]* %red, i32 0, i32 0 +Index: lib/Target/ARM/ARMFrameLowering.h +=================================================================== +--- lib/Target/ARM/ARMFrameLowering.h ++++ lib/Target/ARM/ARMFrameLowering.h +@@ -27,7 +27,7 @@ class ARMFrameLowering : public TargetFrameLowerin + + public: + explicit ARMFrameLowering(const ARMSubtarget &sti) +- : TargetFrameLowering(StackGrowsDown, sti.getStackAlignment(), 0, 4), ++ : TargetFrameLowering(StackGrowsDown, sti.getStackAlignment(), 0, 8), + STI(sti) { + } + Added: head/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r257109-add-CC-aliases.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,25 @@ +This patch adds "CC" and "clang-CC" to the list of program name aliases which +invoke the C++ compiler. + +Introduced here: http://svn.freebsd.org/changeset/base/257109 + +Index: tools/clang/tools/driver/driver.cpp +=================================================================== +--- tools/clang/tools/driver/driver.cpp ++++ tools/clang/tools/driver/driver.cpp +@@ -215,6 +215,7 @@ static void ParseProgName(SmallVectorImpl<const ch + } suffixes [] = { + { "clang", 0 }, + { "clang++", "--driver-mode=g++" }, ++ { "clang-CC", "--driver-mode=g++" }, + { "clang-c++", "--driver-mode=g++" }, + { "clang-cc", 0 }, + { "clang-cpp", "--driver-mode=cpp" }, +@@ -221,6 +222,7 @@ static void ParseProgName(SmallVectorImpl<const ch + { "clang-g++", "--driver-mode=g++" }, + { "clang-gcc", 0 }, + { "clang-cl", "--driver-mode=cl" }, ++ { "CC", "--driver-mode=g++" }, + { "cc", 0 }, + { "cpp", "--driver-mode=cpp" }, + { "cl" , "--driver-mode=cl" }, Added: head/contrib/llvm/patches/patch-r259053-gcc-installation-detector.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r259053-gcc-installation-detector.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,63 @@ +This patch eliminates the unnecessary search for various gcc installation +directories during each startup of clang. + +Introduced here: http://svn.freebsd.org/changeset/base/259053 + +Index: tools/clang/lib/Driver/ToolChains.cpp +=================================================================== +--- tools/clang/lib/Driver/ToolChains.cpp ++++ tools/clang/lib/Driver/ToolChains.cpp +@@ -1014,7 +1014,7 @@ static StringRef getGCCToolchainDir(const ArgList + return GCC_INSTALL_PREFIX; + } + +-/// \brief Construct a GCCInstallationDetector from the driver. ++/// \brief Initialize a GCCInstallationDetector from the driver. + /// + /// This performs all of the autodetection and sets up the various paths. + /// Once constructed, a GCCInstallationDetector is essentially immutable. +@@ -1023,9 +1023,9 @@ static StringRef getGCCToolchainDir(const ArgList + /// should instead pull the target out of the driver. This is currently + /// necessary because the driver doesn't store the final version of the target + /// triple. +-Generic_GCC::GCCInstallationDetector::GCCInstallationDetector( +- const Driver &D, const llvm::Triple &TargetTriple, const ArgList &Args) +- : IsValid(false), D(D) { ++void ++Generic_GCC::GCCInstallationDetector::init( ++ const llvm::Triple &TargetTriple, const ArgList &Args) { + llvm::Triple BiarchVariantTriple = + TargetTriple.isArch32Bit() ? TargetTriple.get64BitArchVariant() + : TargetTriple.get32BitArchVariant(); +@@ -1565,7 +1565,7 @@ void Generic_GCC::GCCInstallationDetector::ScanLib + + Generic_GCC::Generic_GCC(const Driver &D, const llvm::Triple& Triple, + const ArgList &Args) +- : ToolChain(D, Triple, Args), GCCInstallation(getDriver(), Triple, Args) { ++ : ToolChain(D, Triple, Args), GCCInstallation(getDriver()) { + getProgramPaths().push_back(getDriver().getInstalledDir()); + if (getDriver().getInstalledDir() != getDriver().Dir) + getProgramPaths().push_back(getDriver().Dir); +@@ -2361,6 +2361,7 @@ static StringRef getMultilibDir(const llvm::Triple + + Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) + : Generic_ELF(D, Triple, Args) { ++ GCCInstallation.init(Triple, Args); + llvm::Triple::ArchType Arch = Triple.getArch(); + std::string SysRoot = computeSysRoot(); + +Index: tools/clang/lib/Driver/ToolChains.h +=================================================================== +--- tools/clang/lib/Driver/ToolChains.h ++++ tools/clang/lib/Driver/ToolChains.h +@@ -92,8 +92,8 @@ class LLVM_LIBRARY_VISIBILITY Generic_GCC : public + std::set<std::string> CandidateGCCInstallPaths; + + public: +- GCCInstallationDetector(const Driver &D, const llvm::Triple &TargetTriple, +- const llvm::opt::ArgList &Args); ++ GCCInstallationDetector(const Driver &D) : IsValid(false), D(D) {} ++ void init(const llvm::Triple &TargetTriple, const llvm::opt::ArgList &Args); + + /// \brief Check whether we detected a valid GCC install. + bool isValid() const { return IsValid; } Added: head/contrib/llvm/patches/patch-r259498-add-fxsave.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r259498-add-fxsave.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,16 @@ +This patch adds the alias bit_FXSAVE for bit_FXSR to cpuid.h. + +Introduced here: http://svn.freebsd.org/changeset/base/259498 + +Index: tools/clang/lib/Headers/cpuid.h +=================================================================== +--- tools/clang/lib/Headers/cpuid.h ++++ tools/clang/lib/Headers/cpuid.h +@@ -79,6 +79,7 @@ + #define bit_ACPI 0x00400000 + #define bit_MMX 0x00800000 + #define bit_FXSR 0x01000000 ++#define bit_FXSAVE bit_FXSR /* for gcc compat */ + #define bit_SSE 0x02000000 + #define bit_SSE2 0x04000000 + #define bit_SS 0x08000000 Added: head/contrib/llvm/patches/patch-r261680-clang-r200899-fix-security-quantis.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r261680-clang-r200899-fix-security-quantis.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,63 @@ +Pull in r200899 from upstream clang trunk (by Serge Pavlov): + + Allow transformation of VariableArray to ConstantArray. + + In the following code: + + struct A { static const int sz; }; + template<class T> void f() { T arr[A::sz]; } + + the array 'arr' is represented as a variable size array in the template. + If 'A::sz' gets value below in the translation unit, the array in + instantiation can turn into constant size array. + + This change fixes PR18633. + + Differential Revision: http://llvm-reviews.chandlerc.com/D2688 + +Introduced here: http://svn.freebsd.org/changeset/base/261680 + +Index: tools/clang/test/SemaCXX/c99-variable-length-array.cpp +=================================================================== +--- tools/clang/test/SemaCXX/c99-variable-length-array.cpp ++++ tools/clang/test/SemaCXX/c99-variable-length-array.cpp +@@ -140,3 +140,24 @@ namespace PR11744 { + } + int test = f<int>(0); // expected-note {{instantiation of}} + } ++ ++namespace pr18633 { ++ struct A1 { ++ static const int sz; ++ static const int sz2; ++ }; ++ const int A1::sz2 = 11; ++ template<typename T> ++ void func () { ++ int arr[A1::sz]; // expected-warning{{variable length arrays are a C99 feature}} ++ } ++ template<typename T> ++ void func2 () { ++ int arr[A1::sz2]; ++ } ++ const int A1::sz = 12; ++ void func2() { ++ func<int>(); ++ func2<int>(); ++ } ++} +Index: tools/clang/lib/Sema/TreeTransform.h +=================================================================== +--- tools/clang/lib/Sema/TreeTransform.h ++++ tools/clang/lib/Sema/TreeTransform.h +@@ -3966,7 +3966,9 @@ TreeTransform<Derived>::TransformVariableArrayType + return QualType(); + } + +- VariableArrayTypeLoc NewTL = TLB.push<VariableArrayTypeLoc>(Result); ++ // We might have constant size array now, but fortunately it has the same ++ // location layout. ++ ArrayTypeLoc NewTL = TLB.push<ArrayTypeLoc>(Result); + NewTL.setLBracketLoc(TL.getLBracketLoc()); + NewTL.setRBracketLoc(TL.getRBracketLoc()); + NewTL.setSizeExpr(Size); Added: head/contrib/llvm/patches/patch-r261991-llvm-r195391-fix-dwarf2.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/contrib/llvm/patches/patch-r261991-llvm-r195391-fix-dwarf2.diff Tue Mar 18 22:07:45 2014 (r263320) @@ -0,0 +1,540 @@ +Pull in r195391 from upstream llvm trunk (by Eric Christopher): + + In Dwarf 3 (and Dwarf 2) attributes whose value are offsets into a + section use the form DW_FORM_data4 whilst in Dwarf 4 and later they + use the form DW_FORM_sec_offset. + + This patch updates the places where such attributes are generated to + use the appropriate form depending on the Dwarf version. The DIE entries + affected have the following tags: + DW_AT_stmt_list, DW_AT_ranges, DW_AT_location, DW_AT_GNU_pubnames, + DW_AT_GNU_pubtypes, DW_AT_GNU_addr_base, DW_AT_GNU_ranges_base + + It also adds a hidden command line option "--dwarf-version=<uint>" + to llc which allows the version of Dwarf to be generated to override + what is specified in the metadata; this makes it possible to update + existing tests to check the debugging information generated for both + Dwarf 4 (the default) and Dwarf 3 using the same metadata. + + Patch (slightly modified) by Keith Walker! + +Introduced here: http://svn.freebsd.org/changeset/base/261991 + +Index: lib/CodeGen/AsmPrinter/DIE.cpp +=================================================================== +--- lib/CodeGen/AsmPrinter/DIE.cpp ++++ lib/CodeGen/AsmPrinter/DIE.cpp +@@ -338,6 +338,7 @@ void DIEDelta::EmitValue(AsmPrinter *AP, dwarf::Fo + /// + unsigned DIEDelta::SizeOf(AsmPrinter *AP, dwarf::Form Form) const { + if (Form == dwarf::DW_FORM_data4) return 4; ++ if (Form == dwarf::DW_FORM_sec_offset) return 4; + if (Form == dwarf::DW_FORM_strp) return 4; + return AP->getDataLayout().getPointerSize(); + } +Index: lib/CodeGen/AsmPrinter/DwarfDebug.cpp +=================================================================== +--- lib/CodeGen/AsmPrinter/DwarfDebug.cpp ++++ lib/CodeGen/AsmPrinter/DwarfDebug.cpp +@@ -105,6 +105,11 @@ DwarfPubSections("generate-dwarf-pub-sections", cl + clEnumVal(Disable, "Disabled"), clEnumValEnd), + cl::init(Default)); + ++static cl::opt<unsigned> ++DwarfVersionNumber("dwarf-version", cl::Hidden, ++ cl::desc("Generate DWARF for dwarf version."), ++ cl::init(0)); ++ + static const char *const DWARFGroupName = "DWARF Emission"; + static const char *const DbgTimerName = "DWARF Debug Writer"; + +@@ -215,7 +220,9 @@ DwarfDebug::DwarfDebug(AsmPrinter *A, Module *M) + else + HasDwarfPubSections = DwarfPubSections == Enable; + +- DwarfVersion = getDwarfVersionFromModule(MMI->getModule()); ++ DwarfVersion = DwarfVersionNumber ++ ? DwarfVersionNumber ++ : getDwarfVersionFromModule(MMI->getModule()); + + { + NamedRegionTimer T(DbgTimerName, DWARFGroupName, TimePassesIsEnabled); +@@ -470,9 +477,9 @@ DIE *DwarfDebug::constructLexicalScopeDIE(CompileU + // .debug_range section has not been laid out yet. Emit offset in + // .debug_range as a uint, size 4, for now. emitDIE will handle + // DW_AT_ranges appropriately. +- TheCU->addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4, +- DebugRangeSymbols.size() +- * Asm->getDataLayout().getPointerSize()); ++ TheCU->addSectionOffset(ScopeDIE, dwarf::DW_AT_ranges, ++ DebugRangeSymbols.size() * ++ Asm->getDataLayout().getPointerSize()); + for (SmallVectorImpl<InsnRange>::const_iterator RI = Ranges.begin(), + RE = Ranges.end(); RI != RE; ++RI) { + DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first)); +@@ -525,9 +532,9 @@ DIE *DwarfDebug::constructInlinedScopeDIE(CompileU + // .debug_range section has not been laid out yet. Emit offset in + // .debug_range as a uint, size 4, for now. emitDIE will handle + // DW_AT_ranges appropriately. +- TheCU->addUInt(ScopeDIE, dwarf::DW_AT_ranges, dwarf::DW_FORM_data4, +- DebugRangeSymbols.size() +- * Asm->getDataLayout().getPointerSize()); ++ TheCU->addSectionOffset(ScopeDIE, dwarf::DW_AT_ranges, ++ DebugRangeSymbols.size() * ++ Asm->getDataLayout().getPointerSize()); + for (SmallVectorImpl<InsnRange>::const_iterator RI = Ranges.begin(), + RE = Ranges.end(); RI != RE; ++RI) { + DebugRangeSymbols.push_back(getLabelBeforeInsn(RI->first)); +@@ -758,14 +765,15 @@ CompileUnit *DwarfDebug::constructCompileUnit(DICo + // The line table entries are not always emitted in assembly, so it + // is not okay to use line_table_start here. + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +- NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, +- UseTheFirstCU ? Asm->GetTempSymbol("section_line") +- : LineTableStartSym); ++ NewCU->addSectionLabel( ++ Die, dwarf::DW_AT_stmt_list, ++ UseTheFirstCU ? Asm->GetTempSymbol("section_line") ++ : LineTableStartSym); + else if (UseTheFirstCU) +- NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0); ++ NewCU->addSectionOffset(Die, dwarf::DW_AT_stmt_list, 0); + else +- NewCU->addDelta(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, +- LineTableStartSym, DwarfLineSectionSym); ++ NewCU->addSectionDelta(Die, dwarf::DW_AT_stmt_list, ++ LineTableStartSym, DwarfLineSectionSym); + + // If we're using split dwarf the compilation dir is going to be in the + // skeleton CU and so we don't need to duplicate it here. +@@ -776,26 +784,24 @@ CompileUnit *DwarfDebug::constructCompileUnit(DICo + // emit it here if we don't have a skeleton CU for split dwarf. + if (GenerateGnuPubSections) { + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +- NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubnames, +- dwarf::DW_FORM_sec_offset, +- Asm->GetTempSymbol("gnu_pubnames", +- NewCU->getUniqueID())); ++ NewCU->addSectionLabel( ++ Die, dwarf::DW_AT_GNU_pubnames, ++ Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID())); + else +- NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_data4, +- Asm->GetTempSymbol("gnu_pubnames", +- NewCU->getUniqueID()), +- DwarfGnuPubNamesSectionSym); ++ NewCU->addSectionDelta( ++ Die, dwarf::DW_AT_GNU_pubnames, ++ Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()), ++ DwarfGnuPubNamesSectionSym); + + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +- NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubtypes, +- dwarf::DW_FORM_sec_offset, +- Asm->GetTempSymbol("gnu_pubtypes", +- NewCU->getUniqueID())); ++ NewCU->addSectionLabel( ++ Die, dwarf::DW_AT_GNU_pubtypes, ++ Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID())); + else +- NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_data4, +- Asm->GetTempSymbol("gnu_pubtypes", +- NewCU->getUniqueID()), +- DwarfGnuPubTypesSectionSym); ++ NewCU->addSectionDelta( ++ Die, dwarf::DW_AT_GNU_pubtypes, ++ Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()), ++ DwarfGnuPubTypesSectionSym); + } + } + +@@ -2956,11 +2962,10 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const + // Relocate to the beginning of the addr_base section, else 0 for the + // beginning of the one for this compile unit. + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +- NewCU->addLabel(Die, dwarf::DW_AT_GNU_addr_base, dwarf::DW_FORM_sec_offset, +- DwarfAddrSectionSym); ++ NewCU->addSectionLabel(Die, dwarf::DW_AT_GNU_addr_base, ++ DwarfAddrSectionSym); + else +- NewCU->addUInt(Die, dwarf::DW_AT_GNU_addr_base, +- dwarf::DW_FORM_sec_offset, 0); ++ NewCU->addSectionOffset(Die, dwarf::DW_AT_GNU_addr_base, 0); + + // 2.17.1 requires that we use DW_AT_low_pc for a single entry point + // into an entity. We're using 0, or a NULL label for this. +@@ -2970,10 +2975,10 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const + // compile unit in debug_line section. + // FIXME: Should handle multiple compile units. + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +- NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, +- DwarfLineSectionSym); ++ NewCU->addSectionLabel(Die, dwarf::DW_AT_stmt_list, ++ DwarfLineSectionSym); + else +- NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_sec_offset, 0); ++ NewCU->addSectionOffset(Die, dwarf::DW_AT_stmt_list, 0); + + if (!CompilationDir.empty()) + NewCU->addLocalString(Die, dwarf::DW_AT_comp_dir, CompilationDir); +@@ -2981,27 +2986,31 @@ CompileUnit *DwarfDebug::constructSkeletonCU(const + // Flags to let the linker know we have emitted new style pubnames. + if (GenerateGnuPubSections) { + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +- NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_sec_offset, +- Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID())); ++ NewCU->addSectionLabel( ++ Die, dwarf::DW_AT_GNU_pubnames, ++ Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID())); + else +- NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubnames, dwarf::DW_FORM_data4, +- Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()), +- DwarfGnuPubNamesSectionSym); ++ NewCU->addSectionDelta( ++ Die, dwarf::DW_AT_GNU_pubnames, ++ Asm->GetTempSymbol("gnu_pubnames", NewCU->getUniqueID()), ++ DwarfGnuPubNamesSectionSym); + + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +- NewCU->addLabel(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_sec_offset, +- Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID())); ++ NewCU->addSectionLabel( ++ Die, dwarf::DW_AT_GNU_pubtypes, ++ Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID())); + else +- NewCU->addDelta(Die, dwarf::DW_AT_GNU_pubtypes, dwarf::DW_FORM_data4, +- Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()), +- DwarfGnuPubTypesSectionSym); ++ NewCU->addSectionDelta( ++ Die, dwarf::DW_AT_GNU_pubtypes, ++ Asm->GetTempSymbol("gnu_pubtypes", NewCU->getUniqueID()), ++ DwarfGnuPubTypesSectionSym); + } + + // Flag if we've emitted any ranges and their location for the compile unit. + if (DebugRangeSymbols.size()) { + if (Asm->MAI->doesDwarfUseRelocationsAcrossSections()) +- NewCU->addLabel(Die, dwarf::DW_AT_GNU_ranges_base, +- dwarf::DW_FORM_sec_offset, DwarfDebugRangeSectionSym); ++ NewCU->addSectionLabel(Die, dwarf::DW_AT_GNU_ranges_base, ++ DwarfDebugRangeSectionSym); + else + NewCU->addUInt(Die, dwarf::DW_AT_GNU_ranges_base, dwarf::DW_FORM_data4, + 0); +Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +=================================================================== +--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp ++++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +@@ -227,6 +227,26 @@ void CompileUnit::addLabel(DIEBlock *Die, dwarf::F + addLabel(Die, (dwarf::Attribute)0, Form, Label); + } + ++/// addSectionLabel - Add a Dwarf section label attribute data and value. ++/// ++void CompileUnit::addSectionLabel(DIE *Die, dwarf::Attribute Attribute, ++ const MCSymbol *Label) { ++ if (DD->getDwarfVersion() >= 4) ++ addLabel(Die, Attribute, dwarf::DW_FORM_sec_offset, Label); ++ else ++ addLabel(Die, Attribute, dwarf::DW_FORM_data4, Label); ++} ++ ++/// addSectionOffset - Add an offset into a section attribute data and value. ++/// ++void CompileUnit::addSectionOffset(DIE *Die, dwarf::Attribute Attribute, ++ uint64_t Integer) { ++ if (DD->getDwarfVersion() >= 4) ++ addUInt(Die, Attribute, dwarf::DW_FORM_sec_offset, Integer); ++ else ++ addUInt(Die, Attribute, dwarf::DW_FORM_data4, Integer); ++} ++ + /// addLabelAddress - Add a dwarf label attribute data and value using + /// DW_FORM_addr or DW_FORM_GNU_addr_index. + /// +@@ -264,13 +284,15 @@ void CompileUnit::addOpAddress(DIEBlock *Die, cons + } + } + +-/// addDelta - Add a label delta attribute data and value. ++/// addSectionDelta - Add a section label delta attribute data and value. + /// +-void CompileUnit::addDelta(DIE *Die, dwarf::Attribute Attribute, +- dwarf::Form Form, const MCSymbol *Hi, +- const MCSymbol *Lo) { ++void CompileUnit::addSectionDelta(DIE *Die, dwarf::Attribute Attribute, ++ const MCSymbol *Hi, const MCSymbol *Lo) { + DIEValue *Value = new (DIEValueAllocator) DIEDelta(Hi, Lo); +- Die->addValue(Attribute, Form, Value); ++ if (DD->getDwarfVersion() >= 4) ++ Die->addValue(Attribute, dwarf::DW_FORM_sec_offset, Value); ++ else ++ Die->addValue(Attribute, dwarf::DW_FORM_data4, Value); + } + + /// addDIEEntry - Add a DIE attribute data and value. +@@ -1768,10 +1790,8 @@ DIE *CompileUnit::constructVariableDIE(DbgVariable + + unsigned Offset = DV.getDotDebugLocOffset(); + if (Offset != ~0U) { +- addLabel(VariableDie, dwarf::DW_AT_location, +- DD->getDwarfVersion() >= 4 ? dwarf::DW_FORM_sec_offset +- : dwarf::DW_FORM_data4, +- Asm->GetTempSymbol("debug_loc", Offset)); ++ addSectionLabel(VariableDie, dwarf::DW_AT_location, ++ Asm->GetTempSymbol("debug_loc", Offset)); + DV.setDIE(VariableDie); + return VariableDie; + } +Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +=================================================================== +--- lib/CodeGen/AsmPrinter/DwarfCompileUnit.h ++++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.h +@@ -209,6 +209,14 @@ class CompileUnit { + + void addLabel(DIEBlock *Die, dwarf::Form Form, const MCSymbol *Label); + ++ /// addSectionLabel - Add a Dwarf section label attribute data and value. ++ /// ++ void addSectionLabel(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Label); ++ ++ /// addSectionOffset - Add an offset into a section attribute data and value. ++ /// ++ void addSectionOffset(DIE *Die, dwarf::Attribute Attribute, uint64_t Integer); ++ + /// addLabelAddress - Add a dwarf label attribute data and value using + /// either DW_FORM_addr or DW_FORM_GNU_addr_index. + /// +@@ -219,10 +227,9 @@ class CompileUnit { + /// + void addOpAddress(DIEBlock *Die, const MCSymbol *Label); + +- /// addDelta - Add a label delta attribute data and value. +- /// +- void addDelta(DIE *Die, dwarf::Attribute Attribute, dwarf::Form Form, const MCSymbol *Hi, +- const MCSymbol *Lo); ++ /// addSectionDelta - Add a label delta attribute data and value. ++ void addSectionDelta(DIE *Die, dwarf::Attribute Attribute, const MCSymbol *Hi, ++ const MCSymbol *Lo); + + /// addDIEEntry - Add a DIE attribute data and value. + /// +Index: test/DebugInfo/X86/gnu-public-names.ll +=================================================================== +--- test/DebugInfo/X86/gnu-public-names.ll ++++ test/DebugInfo/X86/gnu-public-names.ll +@@ -1,5 +1,6 @@ + ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections < %s | FileCheck -check-prefix=ASM %s + ; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj < %s | llvm-dwarfdump - | FileCheck %s ++; RUN: llc -mtriple=x86_64-pc-linux-gnu -generate-gnu-dwarf-pub-sections -filetype=obj -dwarf-version=3 < %s | llvm-dwarfdump - | FileCheck %s -check-prefix=DWARF3 + ; ModuleID = 'dwarf-public-names.cpp' + ; + ; Generated from: +@@ -123,6 +124,85 @@ + ; CHECK-DAG: [[D]] EXTERNAL TYPE "ns::D" + ; CHECK-DAG: [[INT]] STATIC TYPE "int" + ++; DWARF3: .debug_info contents: ++; DWARF3: DW_AT_GNU_pubnames [DW_FORM_data4] (0x00000000) ++; DWARF3: DW_AT_GNU_pubtypes [DW_FORM_data4] (0x00000000) ++ ++; DWARF3: [[C:[0-9a-f]+]]: DW_TAG_structure_type ++; DWARF3-NEXT: DW_AT_name {{.*}} "C" ++ ++; DWARF3: [[STATIC_MEM_DECL:[0-9a-f]+]]: DW_TAG_member ++; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_variable" ++ ++; DWARF3: [[MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram ++; DWARF3-NEXT: DW_AT_MIPS_linkage_name ++; DWARF3-NEXT: DW_AT_name {{.*}} "member_function" ++ ++; DWARF3: [[STATIC_MEM_FUNC_DECL:[0-9a-f]+]]: DW_TAG_subprogram ++; DWARF3-NEXT: DW_AT_MIPS_linkage_name ++; DWARF3-NEXT: DW_AT_name {{.*}} "static_member_function" ++ ++; DWARF3: [[INT:[0-9a-f]+]]: DW_TAG_base_type ++; DWARF3-NEXT: DW_AT_name {{.*}} "int" ++ ++; DWARF3: [[STATIC_MEM_VAR:[0-9a-f]+]]: DW_TAG_variable ++; DWARF3-NEXT: DW_AT_specification {{.*}}[[STATIC_MEM_DECL]] ++ ++; DWARF3: [[GLOB_VAR:[0-9a-f]+]]: DW_TAG_variable *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** _______________________________________________ svn-src-head@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-head To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"