[clang] 120d44d - [clang] Fix a misadjusted path style comparison in a unittest
Author: Martin Storsjö Date: 2021-12-09T11:47:43+02:00 New Revision: 120d44d1a00b12b79057420eb1d89277522348b1 URL: https://github.com/llvm/llvm-project/commit/120d44d1a00b12b79057420eb1d89277522348b1 DIFF: https://github.com/llvm/llvm-project/commit/120d44d1a00b12b79057420eb1d89277522348b1.diff LOG: [clang] Fix a misadjusted path style comparison in a unittest This was changed incorrectly by accident in 99023627010bbfefb71e25a2b4d056de1cbd354e. Differential Revision: https://reviews.llvm.org/D113254 Added: Modified: clang/unittests/Driver/ToolChainTest.cpp Removed: diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp index 62ad6f7d53714..286ad84e92d67 100644 --- a/clang/unittests/Driver/ToolChainTest.cpp +++ b/clang/unittests/Driver/ToolChainTest.cpp @@ -151,7 +151,7 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) { llvm::raw_string_ostream OS(S); C->getDefaultToolChain().printVerboseInfo(OS); } - if (is_style_windows(llvm::sys::path::Style::windows)) + if (is_style_windows(llvm::sys::path::Style::native)) std::replace(S.begin(), S.end(), '\\', '/'); EXPECT_EQ("Found candidate GCC installation: " "/home/test/bin/../lib/gcc/arm-linux-gnueabi/4.6.1\n" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 98f0bf7 - [clang-move] Fix unit tests with forward slash as separator on windows
Author: Martin Storsjö Date: 2021-11-08T22:21:31+02:00 New Revision: 98f0bf74ca6d7aa9b3c2b240693824f085aa6675 URL: https://github.com/llvm/llvm-project/commit/98f0bf74ca6d7aa9b3c2b240693824f085aa6675 DIFF: https://github.com/llvm/llvm-project/commit/98f0bf74ca6d7aa9b3c2b240693824f085aa6675.diff LOG: [clang-move] Fix unit tests with forward slash as separator on windows Also remove a comment that seems to be left behind. Differential Revision: https://reviews.llvm.org/D113269 Added: Modified: clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp Removed: diff --git a/clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp b/clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp index b9553e111a578..082779358fbfb 100644 --- a/clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp +++ b/clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp @@ -208,7 +208,9 @@ runClangMoveOnCode(const move::MoveDefinitionSpec &Spec, DeclarationReporter *const Reporter = nullptr) { clang::RewriterTestContext Context; - Context.InMemoryFileSystem->setCurrentWorkingDirectory(WorkingDir); + llvm::SmallString<16> Dir(WorkingDir); + llvm::sys::path::native(Dir); + Context.InMemoryFileSystem->setCurrentWorkingDirectory(Dir); std::map FileToFileID; @@ -224,13 +226,12 @@ runClangMoveOnCode(const move::MoveDefinitionSpec &Spec, CreateFiles(TestCCName, CC); std::map FileToReplacements; - ClangMoveContext MoveContext = {Spec, FileToReplacements, WorkingDir, "LLVM", + ClangMoveContext MoveContext = {Spec, FileToReplacements, Dir.c_str(), "LLVM", Reporter != nullptr}; auto Factory = std::make_unique( &MoveContext, Reporter); - // std::string IncludeArg = Twine("-I" + WorkingDir; tooling::runToolOnCodeWithArgs( Factory->create(), CC, Context.InMemoryFileSystem, {"-std=c++11", "-fparse-all-comments", "-I."}, TestCCName, "clang-move", ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 2ca6fc3 - [clang] [DirectoryWatcher] Remove leading \\?\ from GetFinalPathNameByHandleW
Author: Martin Storsjö Date: 2021-11-08T22:21:30+02:00 New Revision: 2ca6fc34fc08eaadb0f287a7f1b33bc1de4d1bd6 URL: https://github.com/llvm/llvm-project/commit/2ca6fc34fc08eaadb0f287a7f1b33bc1de4d1bd6 DIFF: https://github.com/llvm/llvm-project/commit/2ca6fc34fc08eaadb0f287a7f1b33bc1de4d1bd6.diff LOG: [clang] [DirectoryWatcher] Remove leading \\?\ from GetFinalPathNameByHandleW This is needed for the paths to work when using forward slashes; this fixes the DirectoryWatcherTests unit tests. Also allocate missing space for the null terminator, which seems to have been missing all along (writing the terminator out of bounds). Differential Revision: https://reviews.llvm.org/D113264 Added: Modified: clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp Removed: diff --git a/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp b/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp index 1f040f60ff19d..110d402436ee9 100644 --- a/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp +++ b/clang/lib/DirectoryWatcher/windows/DirectoryWatcher-windows.cpp @@ -88,10 +88,15 @@ DirectoryWatcherWindows::DirectoryWatcherWindows( // handle to the watcher and performing synchronous operations. { DWORD Size = GetFinalPathNameByHandleW(DirectoryHandle, NULL, 0, 0); -std::unique_ptr Buffer{new WCHAR[Size]}; +std::unique_ptr Buffer{new WCHAR[Size + 1]}; Size = GetFinalPathNameByHandleW(DirectoryHandle, Buffer.get(), Size, 0); Buffer[Size] = L'\0'; -llvm::sys::windows::UTF16ToUTF8(Buffer.get(), Size, Path); +WCHAR *Data = Buffer.get(); +if (Size >= 4 && ::memcmp(Data, L"?\\", 8) == 0) { + Data += 4; + Size -= 4; +} +llvm::sys::windows::UTF16ToUTF8(Data, Size, Path); } size_t EntrySize = sizeof(FILE_NOTIFY_INFORMATION) + MAX_PATH * sizeof(WCHAR); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] f95bd18 - Revert "[Attr] support btf_type_tag attribute"
Author: Martin Storsjö Date: 2021-11-05T10:36:40+02:00 New Revision: f95bd18b5faa6a5af4b5786312c373c5b2dce687 URL: https://github.com/llvm/llvm-project/commit/f95bd18b5faa6a5af4b5786312c373c5b2dce687 DIFF: https://github.com/llvm/llvm-project/commit/f95bd18b5faa6a5af4b5786312c373c5b2dce687.diff LOG: Revert "[Attr] support btf_type_tag attribute" This reverts commits 737e4216c537c33aab8ec51880f06b8a54325b94 and ce7ac9e66aba2b937b3d3b5505ce6cc75dcc56ac. After those commits, the compiler can crash with a reduced testcase like this: $ cat reduced.c void a(*); void a() {} $ clang -c reduced.c -O2 -g Added: Modified: clang/lib/CodeGen/CGDebugInfo.cpp clang/lib/CodeGen/CGDebugInfo.h llvm/include/llvm/IR/DIBuilder.h llvm/lib/IR/DIBuilder.cpp Removed: clang/test/CodeGen/attr-btf_type_tag-func.c clang/test/CodeGen/attr-btf_type_tag-typedef-field.c clang/test/CodeGen/attr-btf_type_tag-var.c llvm/test/Bitcode/attr-btf_type_tag.ll llvm/test/DebugInfo/attr-btf_type_tag.ll diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 9813c01beef3e..64dd70f837f7b 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -929,28 +929,8 @@ static llvm::dwarf::Tag getNextQualifier(Qualifiers &Q) { return (llvm::dwarf::Tag)0; } -// Strip MacroQualifiedTypeLoc and AttributedTypeLoc -// as their corresponding types will be ignored -// during code generation. Stripping them allows -// to maintain proper TypeLoc for a given type -// during code generation. -static TypeLoc StripMacroAttributed(TypeLoc TL) { - if (!TL) -return TL; - - while (true) { -if (auto MTL = TL.getAs()) - TL = MTL.getInnerLoc(); -else if (auto ATL = TL.getAs()) - TL = ATL.getModifiedLoc(); -else - break; - } - return TL; -} - -llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DIFile *Unit, - TypeLoc TL) { +llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty, + llvm::DIFile *Unit) { QualifierCollector Qc; const Type *T = Qc.strip(Ty); @@ -964,15 +944,7 @@ llvm::DIType *CGDebugInfo::CreateQualifiedType(QualType Ty, llvm::DIFile *Unit, return getOrCreateType(QualType(T, 0), Unit); } - QualType NextTy = Qc.apply(CGM.getContext(), T); - TypeLoc NextTL; - if (NextTy.hasQualifiers()) -NextTL = TL; - else if (TL) { -if (auto QTL = TL.getAs()) - NextTL = StripMacroAttributed(QTL.getNextTypeLoc()); - } - auto *FromTy = getOrCreateType(NextTy, Unit, NextTL); + auto *FromTy = getOrCreateType(Qc.apply(CGM.getContext(), T), Unit); // No need to fill in the Name, Line, Size, Alignment, Offset in case of // CVR derived types. @@ -1016,10 +988,10 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty, Ty->getPointeeType(), Unit); } -llvm::DIType *CGDebugInfo::CreateType(const PointerType *Ty, llvm::DIFile *Unit, - TypeLoc TL) { +llvm::DIType *CGDebugInfo::CreateType(const PointerType *Ty, + llvm::DIFile *Unit) { return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty, - Ty->getPointeeType(), Unit, TL); + Ty->getPointeeType(), Unit); } /// \return whether a C++ mangling exists for the type defined by TD. @@ -1160,8 +1132,7 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType *Ty, llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag, const Type *Ty, QualType PointeeTy, - llvm::DIFile *Unit, - TypeLoc TL) { + llvm::DIFile *Unit) { // Bit size, align and offset of the type. // Size is always the size of a pointer. We can't use getTypeSize here // because that does not return the correct value for references. @@ -1171,52 +1142,13 @@ llvm::DIType *CGDebugInfo::CreatePointerLikeType(llvm::dwarf::Tag Tag, Optional DWARFAddressSpace = CGM.getTarget().getDWARFAddressSpace(AddressSpace); - llvm::DINodeArray Annotations = nullptr; - TypeLoc NextTL; - if (TL) { -SmallVector Annots; -NextTL = TL.getNextTypeLoc(); -if (NextTL) { - // Traverse all MacroQualifiedTypeLoc, QualifiedTypeLoc and - // AttributedTypeLoc type locations so we can collect - // BTFTypeTag attributes for this pointer. - while (true) { -if (auto MTL = NextTL.getAs()) { - NextTL = MTL.getInnerLoc(); -} else if (auto QTL = NextTL.getAs()) { - NextTL = QTL.getNextTypeLoc();
[clang] d758069 - [clang] [MinGW] Guess the right ix86 arch name spelling as sysroot
Author: Martin Storsjö Date: 2021-10-29T09:32:36+03:00 New Revision: d758069f5e0d483f85ed1ee2c84b3955238eedce URL: https://github.com/llvm/llvm-project/commit/d758069f5e0d483f85ed1ee2c84b3955238eedce DIFF: https://github.com/llvm/llvm-project/commit/d758069f5e0d483f85ed1ee2c84b3955238eedce.diff LOG: [clang] [MinGW] Guess the right ix86 arch name spelling as sysroot For x86, most contempory mingw toolchains use i686 as 32 bit x86 arch target. As long as the target triple is set to the right form, this works fine, either as the compiler's default target, or via e.g. a triple prefix like i686-w64-mingw32-clang. However, if the unprefixed toolchain targets x86_64, but the user tries to switch it to target 32 bit by adding the -m32 option, the computeTargetTriple function in Clang, together with Triple::get32BitArchVariant, sets the arch to i386. This causes the right sysroot to not be found. When targeting an arch where there are potential spelling ambiguities with respect to the sysroots (i386 and arm), check if the driver can find a sysroot with the arch name - if not, try a couple other candidates. Differential Revision: https://reviews.llvm.org/D111952 Added: Modified: clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/MinGW.cpp clang/lib/Driver/ToolChains/MinGW.h clang/test/Driver/mingw-sysroot.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 2e69e6c50f4af..cd13a6d8b8303 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -525,8 +525,11 @@ static llvm::Triple computeTargetTriple(const Driver &D, Target.setEnvironment(llvm::Triple::CODE16); } -if (AT != llvm::Triple::UnknownArch && AT != Target.getArch()) +if (AT != llvm::Triple::UnknownArch && AT != Target.getArch()) { Target.setArch(AT); + if (Target.isWindowsGNUEnvironment()) +toolchains::MinGW::fixTripleArch(D, Target, Args); +} } // Handle -miamcu flag. diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index 0bdeff38f52ec..b2a5b3782957d 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -369,9 +369,9 @@ void toolchains::MinGW::findGccLibDir() { } } -llvm::ErrorOr toolchains::MinGW::findGcc() { +static llvm::ErrorOr findGcc(const llvm::Triple &T) { llvm::SmallVector, 2> Gccs; - Gccs.emplace_back(getTriple().getArchName()); + Gccs.emplace_back(T.getArchName()); Gccs[0] += "-w64-mingw32-gcc"; Gccs.emplace_back("mingw32-gcc"); // Please do not add "gcc" here @@ -381,13 +381,14 @@ llvm::ErrorOr toolchains::MinGW::findGcc() { return make_error_code(std::errc::no_such_file_or_directory); } -llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() { +static llvm::ErrorOr +findClangRelativeSysroot(const Driver &D, const llvm::Triple &T, + std::string &SubdirName) { llvm::SmallVector, 2> Subdirs; - Subdirs.emplace_back(getTriple().str()); - Subdirs.emplace_back(getTriple().getArchName()); + Subdirs.emplace_back(T.str()); + Subdirs.emplace_back(T.getArchName()); Subdirs[1] += "-w64-mingw32"; - StringRef ClangRoot = - llvm::sys::path::parent_path(getDriver().getInstalledDir()); + StringRef ClangRoot = llvm::sys::path::parent_path(D.getInstalledDir()); StringRef Sep = llvm::sys::path::get_separator(); for (StringRef CandidateSubdir : Subdirs) { if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) { @@ -404,13 +405,16 @@ toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, RocmInstallation(D, Triple, Args) { getProgramPaths().push_back(getDriver().getInstalledDir()); + // The sequence for detecting a sysroot here should be kept in sync with + // the testTriple function below. if (getDriver().SysRoot.size()) Base = getDriver().SysRoot; // Look for /../; if found, use /.. as the // base as it could still be a base for a gcc setup with libgcc. - else if (llvm::ErrorOr TargetSubdir = findClangRelativeSysroot()) + else if (llvm::ErrorOr TargetSubdir = + findClangRelativeSysroot(getDriver(), getTriple(), SubdirName)) Base = std::string(llvm::sys::path::parent_path(TargetSubdir.get())); - else if (llvm::ErrorOr GPPName = findGcc()) + else if (llvm::ErrorOr GPPName = findGcc(getTriple())) Base = std::string(llvm::sys::path::parent_path( llvm::sys::path::parent_path(GPPName.get(; else @@ -625,3 +629,55 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs( break; } } + +static bool testTriple(const Driver &D, const llvm::Triple &Triple, + const ArgList &Args) { + // If an explicit sysroot is set, that will be used and we shouldn't try to + // detect anything else. + std::string SubdirName; + if (D.SysRoot.size()) +
[clang] 897c86d - [clang] [MinGW] Rename the 'Arch' member to 'SubdirName'. NFC.
Author: Martin Storsjö Date: 2021-10-28T10:26:54+03:00 New Revision: 897c86dec5af2780d443edd852aa5911e2650ec6 URL: https://github.com/llvm/llvm-project/commit/897c86dec5af2780d443edd852aa5911e2650ec6 DIFF: https://github.com/llvm/llvm-project/commit/897c86dec5af2780d443edd852aa5911e2650ec6.diff LOG: [clang] [MinGW] Rename the 'Arch' member to 'SubdirName'. NFC. This string isn't a plain architecture name, but contains the whole subdir name used for the sysroot, which often is equal to the target triple. Differential Revision: https://reviews.llvm.org/D112387 Added: Modified: clang/lib/Driver/ToolChains/MinGW.cpp clang/lib/Driver/ToolChains/MinGW.h Removed: diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index 6f1b7dd330fd..0bdeff38f52e 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -349,20 +349,20 @@ static bool findGccVersion(StringRef LibDir, std::string &GccLibDir, } void toolchains::MinGW::findGccLibDir() { - llvm::SmallVector, 2> Archs; - Archs.emplace_back(getTriple().getArchName()); - Archs[0] += "-w64-mingw32"; - Archs.emplace_back("mingw32"); - if (Arch.empty()) -Arch = std::string(Archs[0].str()); + llvm::SmallVector, 2> SubdirNames; + SubdirNames.emplace_back(getTriple().getArchName()); + SubdirNames[0] += "-w64-mingw32"; + SubdirNames.emplace_back("mingw32"); + if (SubdirName.empty()) +SubdirName = std::string(SubdirNames[0].str()); // lib: Arch Linux, Ubuntu, Windows // lib64: openSUSE Linux for (StringRef CandidateLib : {"lib", "lib64"}) { -for (StringRef CandidateArch : Archs) { +for (StringRef CandidateSysroot : SubdirNames) { llvm::SmallString<1024> LibDir(Base); - llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateArch); + llvm::sys::path::append(LibDir, CandidateLib, "gcc", CandidateSysroot); if (findGccVersion(LibDir, GccLibDir, Ver)) { -Arch = std::string(CandidateArch); +SubdirName = std::string(CandidateSysroot); return; } } @@ -391,7 +391,7 @@ llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() { StringRef Sep = llvm::sys::path::get_separator(); for (StringRef CandidateSubdir : Subdirs) { if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) { - Arch = std::string(CandidateSubdir); + SubdirName = std::string(CandidateSubdir); return (ClangRoot + Sep + CandidateSubdir).str(); } } @@ -423,10 +423,10 @@ toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, // correct crtbegin.o ,cetend.o would be found. getFilePaths().push_back(GccLibDir); getFilePaths().push_back( - (Base + Arch + llvm::sys::path::get_separator() + "lib").str()); + (Base + SubdirName + llvm::sys::path::get_separator() + "lib").str()); getFilePaths().push_back(Base + "lib"); // openSUSE - getFilePaths().push_back(Base + Arch + "/sys-root/mingw/lib"); + getFilePaths().push_back(Base + SubdirName + "/sys-root/mingw/lib"); NativeLLVMSupport = Args.getLastArgValue(options::OPT_fuse_ld_EQ, CLANG_DEFAULT_LINKER) @@ -573,11 +573,12 @@ void toolchains::MinGW::AddClangSystemIncludeArgs(const ArgList &DriverArgs, if (GetRuntimeLibType(DriverArgs) == ToolChain::RLT_Libgcc) { // openSUSE addSystemInclude(DriverArgs, CC1Args, - Base + Arch + "/sys-root/mingw/include"); + Base + SubdirName + "/sys-root/mingw/include"); } addSystemInclude(DriverArgs, CC1Args, - Base + Arch + llvm::sys::path::get_separator() + "include"); + Base + SubdirName + llvm::sys::path::get_separator() + + "include"); addSystemInclude(DriverArgs, CC1Args, Base + "include"); } @@ -596,8 +597,9 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs( .str(); if (getDriver().getVFS().exists(TargetDir)) addSystemInclude(DriverArgs, CC1Args, TargetDir); -addSystemInclude(DriverArgs, CC1Args, Base + Arch + Slash + "include" + - Slash + "c++" + Slash + "v1"); +addSystemInclude(DriverArgs, CC1Args, + Base + SubdirName + Slash + "include" + Slash + "c++" + + Slash + "v1"); addSystemInclude(DriverArgs, CC1Args, Base + "include" + Slash + "c++" + Slash + "v1"); break; @@ -606,9 +608,10 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs( case ToolChain::CST_Libstdcxx: llvm::SmallVector, 4> CppIncludeBases; CppIncludeBases.emplace_back(Base); -llvm::sys::path::append(CppIncludeBases[0], Arch, "include", "c++"); +llvm::sys::path::append(CppIncludeBases[0], SubdirName, "include", "c++"); CppIncludeBases.emplace_back(Base);
[clang] d9b9a7f - [clang][Tooling] Use Windows command lines on all Windows, except Cygwin
Author: Jeremy Drake Date: 2021-10-13T22:55:14+03:00 New Revision: d9b9a7f4287019ad7fb5ae35523e81dee36c1b40 URL: https://github.com/llvm/llvm-project/commit/d9b9a7f4287019ad7fb5ae35523e81dee36c1b40 DIFF: https://github.com/llvm/llvm-project/commit/d9b9a7f4287019ad7fb5ae35523e81dee36c1b40.diff LOG: [clang][Tooling] Use Windows command lines on all Windows, except Cygwin Previously it only used Windows command lines for MSVC triples, but this was causing issues for windows-gnu. In fact, everything 'native' Windows (ie, not Cygwin) should use Windows command line parsing. Reviewed By: mstorsjo Differential Revision: https://reviews.llvm.org/D95 Added: Modified: clang/lib/Tooling/JSONCompilationDatabase.cpp Removed: diff --git a/clang/lib/Tooling/JSONCompilationDatabase.cpp b/clang/lib/Tooling/JSONCompilationDatabase.cpp index 97ba7e411fbb..5e18d7a576c0 100644 --- a/clang/lib/Tooling/JSONCompilationDatabase.cpp +++ b/clang/lib/Tooling/JSONCompilationDatabase.cpp @@ -135,15 +135,12 @@ class CommandLineArgumentParser { std::vector unescapeCommandLine(JSONCommandLineSyntax Syntax, StringRef EscapedCommandLine) { if (Syntax == JSONCommandLineSyntax::AutoDetect) { +#ifdef _WIN32 +// Assume Windows command line parsing on Win32 +Syntax = JSONCommandLineSyntax::Windows; +#else Syntax = JSONCommandLineSyntax::Gnu; -llvm::Triple Triple(llvm::sys::getProcessTriple()); -if (Triple.getOS() == llvm::Triple::OSType::Win32) { - // Assume Windows command line parsing on Win32 unless the triple - // explicitly tells us otherwise. - if (!Triple.hasEnvironment() || - Triple.getEnvironment() == llvm::Triple::EnvironmentType::MSVC) -Syntax = JSONCommandLineSyntax::Windows; -} +#endif } if (Syntax == JSONCommandLineSyntax::Windows) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] b541845 - [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64
Author: Martin Storsjö Date: 2021-10-13T22:55:00+03:00 New Revision: b541845ea082d1dfca53074b4353e1ee0c22dd76 URL: https://github.com/llvm/llvm-project/commit/b541845ea082d1dfca53074b4353e1ee0c22dd76 DIFF: https://github.com/llvm/llvm-project/commit/b541845ea082d1dfca53074b4353e1ee0c22dd76.diff LOG: [clang] [Windows] Mark PIC as implicitly enabled for aarch64, just like for x86_64 This doesn't practically affect the code generation. Differential Revision: https://reviews.llvm.org/D111707 Added: Modified: clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/MinGW.cpp clang/test/Driver/pic.c Removed: diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index 046ef8024c6e4..5b7600493893e 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -795,7 +795,8 @@ bool MSVCToolChain::IsUnwindTablesDefault(const ArgList &Args) const { } bool MSVCToolChain::isPICDefault() const { - return getArch() == llvm::Triple::x86_64; + return getArch() == llvm::Triple::x86_64 || + getArch() == llvm::Triple::aarch64; } bool MSVCToolChain::isPIEDefault() const { @@ -803,7 +804,8 @@ bool MSVCToolChain::isPIEDefault() const { } bool MSVCToolChain::isPICDefaultForced() const { - return getArch() == llvm::Triple::x86_64; + return getArch() == llvm::Triple::x86_64 || + getArch() == llvm::Triple::aarch64; } void MSVCToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs, diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index 1aaa941498322..6f1b7dd330fd0 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -474,13 +474,15 @@ bool toolchains::MinGW::IsUnwindTablesDefault(const ArgList &Args) const { } bool toolchains::MinGW::isPICDefault() const { - return getArch() == llvm::Triple::x86_64; + return getArch() == llvm::Triple::x86_64 || + getArch() == llvm::Triple::aarch64; } bool toolchains::MinGW::isPIEDefault() const { return false; } bool toolchains::MinGW::isPICDefaultForced() const { - return getArch() == llvm::Triple::x86_64; + return getArch() == llvm::Triple::x86_64 || + getArch() == llvm::Triple::aarch64; } llvm::ExceptionHandling diff --git a/clang/test/Driver/pic.c b/clang/test/Driver/pic.c index 57924cd1bbb43..6f8d6cc75c006 100644 --- a/clang/test/Driver/pic.c +++ b/clang/test/Driver/pic.c @@ -314,8 +314,12 @@ // RUN: %clang -c %s -target aarch64-linux-android24 -fno-PIE -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-NO-PIC // -// On Windows-X64 PIC is enabled by default +// On Windows x86_64 and aarch64 PIC is enabled by default // RUN: %clang -c %s -target x86_64-pc-windows-msvc18.0.0 -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PIC2 // RUN: %clang -c %s -target x86_64-pc-windows-gnu -### 2>&1 \ // RUN: | FileCheck %s --check-prefix=CHECK-PIC2 +// RUN: %clang -c %s -target aarch64-windows-msvc -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIC2 +// RUN: %clang -c %s -target aarch64-windows-gnu -### 2>&1 \ +// RUN: | FileCheck %s --check-prefix=CHECK-PIC2 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d13d9da - [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows
Author: Martin Storsjö Date: 2021-09-17T21:39:25+03:00 New Revision: d13d9da1fbe1a750f9c4fc3f4da31c9d16a530d3 URL: https://github.com/llvm/llvm-project/commit/d13d9da1fbe1a750f9c4fc3f4da31c9d16a530d3 DIFF: https://github.com/llvm/llvm-project/commit/d13d9da1fbe1a750f9c4fc3f4da31c9d16a530d3.diff LOG: [clang] [ARM] Don't set the strict alignment flag for armv7 on Windows Windows on armv7 is as alignment tolerant as Linux. The alignment considerations in the Windows on ARM ABI are documented at https://docs.microsoft.com/en-us/cpp/build/overview-of-arm-abi-conventions?view=msvc-160#alignment. The document doesn't explicitly say in which state the OS configures the SCTLR.A register (and it's not accessible from user space to inspect), but in practice, unaligned loads/stores do work and seem to be as fast as aligned loads and stores. (Unaligned strd also does seem to work, contrary to Linux, but significantly slower, as they're handled by the kernel - exactly as the document describes.) Differential Revision: https://reviews.llvm.org/D109960 Added: Modified: clang/lib/Driver/ToolChains/Arch/ARM.cpp clang/test/Driver/arm-alignment.c Removed: diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp index a64fc30858748..05d83c91ba0ef 100644 --- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp +++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp @@ -779,7 +779,8 @@ void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple, // which raises an alignment fault on unaligned accesses. Linux // defaults this bit to 0 and handles it as a system-wide (not // per-process) setting. It is therefore safe to assume that ARMv7+ -// Linux targets support unaligned accesses. The same goes for NaCl. +// Linux targets support unaligned accesses. The same goes for NaCl +// and Windows. // // The above behavior is consistent with GCC. int VersionNum = getARMSubArchVersionNumber(Triple); @@ -787,7 +788,8 @@ void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple, if (VersionNum < 6 || Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m) Features.push_back("+strict-align"); -} else if (Triple.isOSLinux() || Triple.isOSNaCl()) { +} else if (Triple.isOSLinux() || Triple.isOSNaCl() || + Triple.isOSWindows()) { if (VersionNum < 7) Features.push_back("+strict-align"); } else diff --git a/clang/test/Driver/arm-alignment.c b/clang/test/Driver/arm-alignment.c index b2bc8a35dfc6f..41dbb35b1c2c2 100644 --- a/clang/test/Driver/arm-alignment.c +++ b/clang/test/Driver/arm-alignment.c @@ -19,6 +19,9 @@ // RUN: %clang -target armv7-unknown-nacl-gnueabihf -### %s 2> %t // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s +// RUN: %clang -target armv7-windows -### %s 2> %t +// RUN: FileCheck --check-prefix=CHECK-UNALIGNED-ARM < %t %s + // RUN: %clang -target aarch64-none-gnueabi -munaligned-access -### %s 2> %t // RUN: FileCheck --check-prefix=CHECK-UNALIGNED-AARCH64 < %t %s ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cc3affd - [clang] [MSVC] Implement __mulh and __umulh builtins for aarch64
Author: Martin Storsjö Date: 2021-08-19T11:29:55+03:00 New Revision: cc3affd8b02091bf475f9dd083802e1b6a232be1 URL: https://github.com/llvm/llvm-project/commit/cc3affd8b02091bf475f9dd083802e1b6a232be1 DIFF: https://github.com/llvm/llvm-project/commit/cc3affd8b02091bf475f9dd083802e1b6a232be1.diff LOG: [clang] [MSVC] Implement __mulh and __umulh builtins for aarch64 The code is based on the same __mulh and __umulh intrinsics for x86. This should fix PR51128. Differential Revision: https://reviews.llvm.org/D106721 Added: Modified: clang/include/clang/Basic/BuiltinsAArch64.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Headers/intrin.h clang/test/CodeGen/arm64-microsoft-intrinsics.c Removed: diff --git a/clang/include/clang/Basic/BuiltinsAArch64.def b/clang/include/clang/Basic/BuiltinsAArch64.def index 1dac5d2371d4..634bcaed20a6 100644 --- a/clang/include/clang/Basic/BuiltinsAArch64.def +++ b/clang/include/clang/Basic/BuiltinsAArch64.def @@ -243,6 +243,9 @@ TARGET_HEADER_BUILTIN(_ReadStatusReg, "LLii", "nh", "intrin.h", ALL_MS_LANGUAG TARGET_HEADER_BUILTIN(_WriteStatusReg, "viLLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") TARGET_HEADER_BUILTIN(_AddressOfReturnAddress, "v*", "nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(__mulh, "SLLiSLLiSLLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") +TARGET_HEADER_BUILTIN(__umulh, "ULLiULLiULLi", "nh", "intrin.h", ALL_MS_LANGUAGES, "") + #undef BUILTIN #undef LANGBUILTIN #undef TARGET_HEADER_BUILTIN diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index e172fc493a25..d74209ae27a4 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -9712,6 +9712,29 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID, return Builder.CreateCall(F); } + if (BuiltinID == AArch64::BI__mulh || BuiltinID == AArch64::BI__umulh) { +llvm::Type *ResType = ConvertType(E->getType()); +llvm::Type *Int128Ty = llvm::IntegerType::get(getLLVMContext(), 128); + +bool IsSigned = BuiltinID == AArch64::BI__mulh; +Value *LHS = +Builder.CreateIntCast(EmitScalarExpr(E->getArg(0)), Int128Ty, IsSigned); +Value *RHS = +Builder.CreateIntCast(EmitScalarExpr(E->getArg(1)), Int128Ty, IsSigned); + +Value *MulResult, *HigherBits; +if (IsSigned) { + MulResult = Builder.CreateNSWMul(LHS, RHS); + HigherBits = Builder.CreateAShr(MulResult, 64); +} else { + MulResult = Builder.CreateNUWMul(LHS, RHS); + HigherBits = Builder.CreateLShr(MulResult, 64); +} +HigherBits = Builder.CreateIntCast(HigherBits, ResType, IsSigned); + +return HigherBits; + } + // Handle MSVC intrinsics before argument evaluation to prevent double // evaluation. if (Optional MsvcIntId = translateAarch64ToMsvcIntrin(BuiltinID)) diff --git a/clang/lib/Headers/intrin.h b/clang/lib/Headers/intrin.h index ff8eb8fca268..34ec79d6acbc 100644 --- a/clang/lib/Headers/intrin.h +++ b/clang/lib/Headers/intrin.h @@ -574,6 +574,9 @@ void _WriteStatusReg(int, __int64); unsigned short __cdecl _byteswap_ushort(unsigned short val); unsigned long __cdecl _byteswap_ulong (unsigned long val); unsigned __int64 __cdecl _byteswap_uint64(unsigned __int64 val); + +__int64 __mulh(__int64 __a, __int64 __b); +unsigned __int64 __umulh(unsigned __int64 __a, unsigned __int64 __b); #endif /**\ diff --git a/clang/test/CodeGen/arm64-microsoft-intrinsics.c b/clang/test/CodeGen/arm64-microsoft-intrinsics.c index ca8f270bd4f3..36f182433edd 100644 --- a/clang/test/CodeGen/arm64-microsoft-intrinsics.c +++ b/clang/test/CodeGen/arm64-microsoft-intrinsics.c @@ -81,6 +81,28 @@ void check_ReadWriteBarrier() { // CHECK-MSVC: fence syncscope("singlethread") // CHECK-LINUX: error: implicit declaration of function '_ReadWriteBarrier' +long long check_mulh(long long a, long long b) { + return __mulh(a, b); +} + +// CHECK-MSVC: %[[ARG1:.*]] = sext i64 {{.*}} to i128 +// CHECK-MSVC: %[[ARG2:.*]] = sext i64 {{.*}} to i128 +// CHECK-MSVC: %[[PROD:.*]] = mul nsw i128 %[[ARG1]], %[[ARG2]] +// CHECK-MSVC: %[[HIGH:.*]] = ashr i128 %[[PROD]], 64 +// CHECK-MSVC: %[[RES:.*]] = trunc i128 %[[HIGH]] to i64 +// CHECK-LINUX: error: implicit declaration of function '__mulh' + +unsigned long long check_umulh(unsigned long long a, unsigned long long b) { + return __umulh(a, b); +} + +// CHECK-MSVC: %[[ARG1:.*]] = zext i64 {{.*}} to i128 +// CHECK-MSVC: %[[ARG2:.*]] = zext i64 {{.*}} to i128 +// CHECK-MSVC: %[[PROD:.*]] = mul nuw i128 %[[ARG1]], %[[ARG2]] +// CHECK-MSVC: %[[HIGH:.*]] = lshr i128 %[[PROD]], 64 +// CHECK-MSVC: %[[RES:.*]] = trunc i128 %[[HIGH]] to i64 +// CHECK-LINUX: error: implicit declaration of function '__umulh' + unsigned __int64 check__getReg() { unsigned volatile __int64 reg;
[clang] 5ed9e5c - [clang] [MinGW] Consider the per-target libc++ include directory too
Author: Martin Storsjö Date: 2021-08-12T13:27:09+03:00 New Revision: 5ed9e5c2c0ee9a77ed4a2a5bd817b03acf78fbac URL: https://github.com/llvm/llvm-project/commit/5ed9e5c2c0ee9a77ed4a2a5bd817b03acf78fbac DIFF: https://github.com/llvm/llvm-project/commit/5ed9e5c2c0ee9a77ed4a2a5bd817b03acf78fbac.diff LOG: [clang] [MinGW] Consider the per-target libc++ include directory too The existing logic for per-target libc++ include directories only seem to exist for the Gnu and Fuchsia drivers, added in ea12d779bc238c387511fe7462020f4ecf4a8246 / D89013. This is less generic than the corresponding case in the Gnu driver, but matches the existing level of genericity in the MinGW driver (and others too). Differential Revision: https://reviews.llvm.org/D107893 Added: clang/test/Driver/Inputs/mingw_clang_tree/mingw32/include/i686-unknown-windows-gnu/c++/v1/.keep Modified: clang/lib/Driver/ToolChains/MinGW.cpp clang/test/Driver/mingw.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index 7ba729f36bd87..1aaa941498322 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -588,12 +588,18 @@ void toolchains::MinGW::AddClangCXXStdlibIncludeArgs( StringRef Slash = llvm::sys::path::get_separator(); switch (GetCXXStdlibType(DriverArgs)) { - case ToolChain::CST_Libcxx: + case ToolChain::CST_Libcxx: { +std::string TargetDir = (Base + "include" + Slash + getTripleString() + + Slash + "c++" + Slash + "v1") +.str(); +if (getDriver().getVFS().exists(TargetDir)) + addSystemInclude(DriverArgs, CC1Args, TargetDir); addSystemInclude(DriverArgs, CC1Args, Base + Arch + Slash + "include" + Slash + "c++" + Slash + "v1"); addSystemInclude(DriverArgs, CC1Args, Base + "include" + Slash + "c++" + Slash + "v1"); break; + } case ToolChain::CST_Libstdcxx: llvm::SmallVector, 4> CppIncludeBases; diff --git a/clang/test/Driver/Inputs/mingw_clang_tree/mingw32/include/i686-unknown-windows-gnu/c++/v1/.keep b/clang/test/Driver/Inputs/mingw_clang_tree/mingw32/include/i686-unknown-windows-gnu/c++/v1/.keep new file mode 100644 index 0..e69de29bb2d1d diff --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp index 83b61ba7d33f0..4d573f0f2125c 100644 --- a/clang/test/Driver/mingw.cpp +++ b/clang/test/Driver/mingw.cpp @@ -4,6 +4,7 @@ // RUN: %clang -target i686-windows-gnu -rtlib=platform -stdlib=libc++ -c -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s 2>&1 | FileCheck -check-prefix=CHECK_MINGW_CLANG_TREE_LIBCXX %s +// CHECK_MINGW_CLANG_TREE_LIBCXX: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|}}include{{/|}}i686-unknown-windows-gnu{{/|}}c++{{/|}}v1" // CHECK_MINGW_CLANG_TREE_LIBCXX: "[[BASE:[^"]+]]/Inputs/mingw_clang_tree/mingw32{{/|}}i686-w64-mingw32{{/|}}include{{/|}}c++{{/|}}v1" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ce49fd0 - [clang] [MinGW] Let the last of -mconsole/-mwindows have effect
Author: Martin Storsjö Date: 2021-08-03T10:55:44+03:00 New Revision: ce49fd024b43bd76b149f984b8f0d16e92b9bb06 URL: https://github.com/llvm/llvm-project/commit/ce49fd024b43bd76b149f984b8f0d16e92b9bb06 DIFF: https://github.com/llvm/llvm-project/commit/ce49fd024b43bd76b149f984b8f0d16e92b9bb06.diff LOG: [clang] [MinGW] Let the last of -mconsole/-mwindows have effect Don't just check for the existence of one, but check which one was specified last, if any. This fixes https://llvm.org/PR51296. Differential Revision: https://reviews.llvm.org/D107261 Added: Modified: clang/lib/Driver/ToolChains/MinGW.cpp clang/test/Driver/mingw.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index 20efbdc237a8..7ba729f36bd8 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -136,10 +136,13 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, llvm_unreachable("Unsupported target architecture."); } - if (Args.hasArg(options::OPT_mwindows)) { + Arg *SubsysArg = + Args.getLastArg(options::OPT_mwindows, options::OPT_mconsole); + if (SubsysArg && SubsysArg->getOption().matches(options::OPT_mwindows)) { CmdArgs.push_back("--subsystem"); CmdArgs.push_back("windows"); - } else if (Args.hasArg(options::OPT_mconsole)) { + } else if (SubsysArg && + SubsysArg->getOption().matches(options::OPT_mconsole)) { CmdArgs.push_back("--subsystem"); CmdArgs.push_back("console"); } diff --git a/clang/test/Driver/mingw.cpp b/clang/test/Driver/mingw.cpp index 796bde8eebe4..83b61ba7d33f 100644 --- a/clang/test/Driver/mingw.cpp +++ b/clang/test/Driver/mingw.cpp @@ -61,3 +61,10 @@ // RUN: %clang -target i686-windows-gnu -E -### %s -municode 2>&1 | FileCheck -check-prefix=CHECK_MINGW_UNICODE %s // CHECK_MINGW_NO_UNICODE-NOT: "-DUNICODE" // CHECK_MINGW_UNICODE: "-DUNICODE" + +// RUN: %clang -target i686-windows-gnu -### %s 2>&1 | FileCheck -check-prefix=CHECK_NO_SUBSYS %s +// RUN: %clang -target i686-windows-gnu -### %s -mwindows -mconsole 2>&1 | FileCheck -check-prefix=CHECK_SUBSYS_CONSOLE %s +// RUN: %clang -target i686-windows-gnu -### %s -mconsole -mwindows 2>&1 | FileCheck -check-prefix=CHECK_SUBSYS_WINDOWS %s +// CHECK_NO_SUBSYS-NOT: "--subsystem" +// CHECK_SUBSYS_CONSOLE: "--subsystem" "console" +// CHECK_SUBSYS_WINDOWS: "--subsystem" "windows" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 25a288b - [clang-repl] Fix building with win32 dylibs
Author: Martin Storsjö Date: 2021-08-01T23:01:00+03:00 New Revision: 25a288b009f7d30b5392ea36c29570cbdcf238c3 URL: https://github.com/llvm/llvm-project/commit/25a288b009f7d30b5392ea36c29570cbdcf238c3 DIFF: https://github.com/llvm/llvm-project/commit/25a288b009f7d30b5392ea36c29570cbdcf238c3.diff LOG: [clang-repl] Fix building with win32 dylibs Use `clang_target_link_libraries` to avoid duplicate libraries when the same symbol is provided both by a static library and a larger dylib, fixing linking with win32 dylibs. This fixes errors like these: ld.lld: error: duplicate symbol: llvm::createStringError(std::__1::error_code, char const*) >>> defined at libLLVMSupport.a(Error.cpp.obj) >>> defined at libLLVM-14git.dll This matches how other clang tools declare their dependencies. Differential Revision: https://reviews.llvm.org/D107231 Added: Modified: clang/tools/clang-repl/CMakeLists.txt Removed: diff --git a/clang/tools/clang-repl/CMakeLists.txt b/clang/tools/clang-repl/CMakeLists.txt index a9dcd1f6a66bb..ae0e4f39be70f 100644 --- a/clang/tools/clang-repl/CMakeLists.txt +++ b/clang/tools/clang-repl/CMakeLists.txt @@ -10,7 +10,7 @@ add_clang_executable(clang-repl ClangRepl.cpp ) -target_link_libraries(clang-repl PUBLIC +clang_target_link_libraries(clang-repl PUBLIC clangBasic clangInterpreter clangTooling ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bf6770f - [CMake] Don't use -Bsymbolic-functions for MinGW targets
Author: Martin Storsjö Date: 2021-06-30T22:54:26+03:00 New Revision: bf6770f9bd606643c8ea8a7ab03da5da5960e98e URL: https://github.com/llvm/llvm-project/commit/bf6770f9bd606643c8ea8a7ab03da5da5960e98e DIFF: https://github.com/llvm/llvm-project/commit/bf6770f9bd606643c8ea8a7ab03da5da5960e98e.diff LOG: [CMake] Don't use -Bsymbolic-functions for MinGW targets This is an ELF specific option which isn't supported for Windows/MinGW targets, even if the MinGW linker otherwise uses an ld.bfd like linker interface. Differential Revision: https://reviews.llvm.org/D105148 Added: Modified: clang/tools/clang-shlib/CMakeLists.txt llvm/tools/llvm-shlib/CMakeLists.txt Removed: diff --git a/clang/tools/clang-shlib/CMakeLists.txt b/clang/tools/clang-shlib/CMakeLists.txt index d08cf89383282..9c1f8ea452b36 100644 --- a/clang/tools/clang-shlib/CMakeLists.txt +++ b/clang/tools/clang-shlib/CMakeLists.txt @@ -50,6 +50,6 @@ add_clang_library(clang-cpp ${_DEPS}) # Optimize function calls for default visibility definitions to avoid PLT and # reduce dynamic relocations. -if (NOT APPLE) +if (NOT APPLE AND NOT MINGW) target_link_options(clang-cpp PRIVATE LINKER:-Bsymbolic-functions) endif() diff --git a/llvm/tools/llvm-shlib/CMakeLists.txt b/llvm/tools/llvm-shlib/CMakeLists.txt index 03e1383ec8b4f..76b9a25cbbcdc 100644 --- a/llvm/tools/llvm-shlib/CMakeLists.txt +++ b/llvm/tools/llvm-shlib/CMakeLists.txt @@ -50,11 +50,13 @@ if(LLVM_BUILD_LLVM_DYLIB) # Solaris ld does not accept global: *; so there is no way to version *all* global symbols set(LIB_NAMES -Wl,--version-script,${LLVM_LIBRARY_DIR}/tools/llvm-shlib/simple_version_script.map ${LIB_NAMES}) endif() -# Optimize function calls for default visibility definitions to avoid PLT and -# reduce dynamic relocations. -# Note: for -fno-pic default, the address of a function may be diff erent from -# inside and outside libLLVM.so. -target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions) +if (NOT MINGW) + # Optimize function calls for default visibility definitions to avoid PLT and + # reduce dynamic relocations. + # Note: for -fno-pic default, the address of a function may be diff erent from + # inside and outside libLLVM.so. + target_link_options(LLVM PRIVATE LINKER:-Bsymbolic-functions) +endif() elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin") set(LIB_NAMES -Wl,-all_load ${LIB_NAMES}) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] 86029e4 - [clang-tools-extra] Rename StringRef _lower() method calls to _insensitive()
Author: Martin Storsjö Date: 2021-06-25T00:22:01+03:00 New Revision: 86029e4c220b91be728f6ff6a17cad098821e657 URL: https://github.com/llvm/llvm-project/commit/86029e4c220b91be728f6ff6a17cad098821e657 DIFF: https://github.com/llvm/llvm-project/commit/86029e4c220b91be728f6ff6a17cad098821e657.diff LOG: [clang-tools-extra] Rename StringRef _lower() method calls to _insensitive() Added: Modified: clang-tools-extra/clang-tidy/ClangTidyCheck.cpp clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp clang-tools-extra/clang-tidy/readability/InconsistentDeclarationParameterNameCheck.cpp clang-tools-extra/clang-tidy/readability/UppercaseLiteralSuffixCheck.cpp clang-tools-extra/clangd/CodeComplete.cpp clang-tools-extra/clangd/CompileCommands.cpp clang-tools-extra/clangd/ConfigYAML.cpp clang-tools-extra/clangd/HeaderSourceSwitch.cpp clang-tools-extra/clangd/InlayHints.cpp clang-tools-extra/clangd/Quality.cpp clang-tools-extra/clangd/index/SymbolCollector.cpp clang-tools-extra/clangd/support/Path.cpp clang-tools-extra/modularize/ModularizeUtilities.cpp Removed: diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp index 6f7f6611c8d20..f447ee41f6f8f 100644 --- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp +++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp @@ -150,11 +150,11 @@ llvm::Optional ClangTidyCheck::OptionsView::getEnumInt( unsigned EditDistance = 3; for (const auto &NameAndEnum : Mapping) { if (IgnoreCase) { - if (Value.equals_lower(NameAndEnum.second)) + if (Value.equals_insensitive(NameAndEnum.second)) return NameAndEnum.first; } else if (Value.equals(NameAndEnum.second)) { return NameAndEnum.first; -} else if (Value.equals_lower(NameAndEnum.second)) { +} else if (Value.equals_insensitive(NameAndEnum.second)) { Closest = NameAndEnum.second; EditDistance = 0; continue; diff --git a/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp b/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp index f7c71cca71594..769494207aef2 100644 --- a/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp +++ b/clang-tools-extra/clang-tidy/altera/KernelNameRestrictionCheck.cpp @@ -70,9 +70,9 @@ void KernelNameRestrictionPPCallbacks::InclusionDirective( bool KernelNameRestrictionPPCallbacks::fileNameIsRestricted( StringRef FileName) { - return FileName.equals_lower("kernel.cl") || - FileName.equals_lower("verilog.cl") || - FileName.equals_lower("vhdl.cl"); + return FileName.equals_insensitive("kernel.cl") || + FileName.equals_insensitive("verilog.cl") || + FileName.equals_insensitive("vhdl.cl"); } void KernelNameRestrictionPPCallbacks::EndOfMainFile() { diff --git a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp index 32af0ee6266d2..e50ebdba3b343 100644 --- a/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp +++ b/clang-tools-extra/clang-tidy/bugprone/ArgumentCommentCheck.cpp @@ -176,8 +176,8 @@ static bool sameName(StringRef InComment, StringRef InDecl, bool StrictMode) { return InComment == InDecl; InComment = InComment.trim('_'); InDecl = InDecl.trim('_'); - // FIXME: compare_lower only works for ASCII. - return InComment.compare_lower(InDecl) == 0; + // FIXME: compare_insensitive only works for ASCII. + return InComment.compare_insensitive(InDecl) == 0; } static bool looksLikeExpectMethod(const CXXMethodDecl *Expect) { diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp index 6f056e73ad5d6..9ff94a009d0dd 100644 --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/PreferMemberInitializerCheck.cpp @@ -159,7 +159,7 @@ void PreferMemberInitializerCheck::check( if (S->getBeginLoc().isMacroID()) { StringRef MacroName = Lexer::getImmediateMacroName( S->getBeginLoc(), *Result.SourceManager, getLangOpts()); - if (MacroName.contains_lower("assert")) + if (MacroName.contains_insensitive("assert")) return; } if (isControlStatement(S)) diff --git a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp b/clang-tools-extra/clang-tidy/misc/StaticAssertCheck.cpp index 224936887e033..93df4915e9f74 100644 --- a/clang-tools-extra/clang-tidy/misc/StaticAssertCheck
[clang] e5c7c17 - [clang] Rename StringRef _lower() method calls to _insensitive()
Author: Martin Storsjö Date: 2021-06-25T00:22:01+03:00 New Revision: e5c7c171e5db6af1e3dca1059df4287b0d147eaf URL: https://github.com/llvm/llvm-project/commit/e5c7c171e5db6af1e3dca1059df4287b0d147eaf DIFF: https://github.com/llvm/llvm-project/commit/e5c7c171e5db6af1e3dca1059df4287b0d147eaf.diff LOG: [clang] Rename StringRef _lower() method calls to _insensitive() This is mostly a mechanical change, but a testcase that contains parts of the StringRef class (clang/test/Analysis/llvm-conventions.cpp) isn't touched. Added: Modified: clang/lib/ASTMatchers/Dynamic/Marshallers.cpp clang/lib/Analysis/CalledOnceCheck.cpp clang/lib/Analysis/RetainSummaryManager.cpp clang/lib/Basic/FileManager.cpp clang/lib/CodeGen/TargetInfo.cpp clang/lib/Driver/Driver.cpp clang/lib/Driver/ToolChains/Arch/RISCV.cpp clang/lib/Driver/ToolChains/Clang.cpp clang/lib/Driver/ToolChains/Fuchsia.cpp clang/lib/Driver/ToolChains/Gnu.cpp clang/lib/Driver/ToolChains/Hexagon.cpp clang/lib/Driver/ToolChains/MSVC.cpp clang/lib/Driver/ToolChains/MinGW.cpp clang/lib/Format/Format.cpp clang/lib/Format/SortJavaScriptImports.cpp clang/lib/Format/UsingDeclarationsSorter.cpp clang/lib/Frontend/CompilerInvocation.cpp clang/lib/Lex/HeaderMap.cpp clang/lib/Lex/PPDirectives.cpp clang/lib/Lex/PPMacroExpansion.cpp clang/lib/Sema/CodeCompleteConsumer.cpp clang/lib/Sema/SemaChecking.cpp clang/lib/Sema/SemaCodeComplete.cpp clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp clang/lib/StaticAnalyzer/Checkers/ContainerModeling.cpp clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp clang/lib/StaticAnalyzer/Checkers/Iterator.cpp clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp clang/lib/Tooling/Inclusions/HeaderIncludes.cpp clang/lib/Tooling/InterpolatingCompilationDatabase.cpp clang/tools/clang-refactor/TestSupport.cpp clang/tools/clang-scan-deps/ClangScanDeps.cpp clang/tools/driver/driver.cpp clang/tools/libclang/CIndexCodeCompletion.cpp clang/unittests/Tooling/CompilationDatabaseTest.cpp Removed: diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp index f6fdbe868e2df..40db70e6f4a51 100644 --- a/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp +++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.cpp @@ -20,7 +20,7 @@ getBestGuess(llvm::StringRef Search, llvm::ArrayRef Allowed, ++MaxEditDistance; llvm::StringRef Res; for (const llvm::StringRef &Item : Allowed) { -if (Item.equals_lower(Search)) { +if (Item.equals_insensitive(Search)) { assert(!Item.equals(Search) && "This should be handled earlier on."); MaxEditDistance = 1; Res = Item; @@ -40,7 +40,7 @@ getBestGuess(llvm::StringRef Search, llvm::ArrayRef Allowed, auto NoPrefix = Item; if (!NoPrefix.consume_front(DropPrefix)) continue; - if (NoPrefix.equals_lower(Search)) { + if (NoPrefix.equals_insensitive(Search)) { if (NoPrefix.equals(Search)) return Item.str(); MaxEditDistance = 1; diff --git a/clang/lib/Analysis/CalledOnceCheck.cpp b/clang/lib/Analysis/CalledOnceCheck.cpp index db094129a9608..661f7b999f2b9 100644 --- a/clang/lib/Analysis/CalledOnceCheck.cpp +++ b/clang/lib/Analysis/CalledOnceCheck.cpp @@ -478,7 +478,7 @@ bool mentionsAnyOfConventionalNames(const Expr *E) { return llvm::any_of( CONVENTIONAL_CONDITIONS, [ConditionName](const llvm::StringLiteral &Conventional) { - return ConditionName.contains_lower(Conventional); + return ConditionName.contains_insensitive(Conventional); }); }); } diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp index 58ead1dfe3522..7ed1e40333f43 100644 --- a/clang/lib/Analysis/RetainSummaryManager.cpp +++ b/clang/lib/Analysis/RetainSummaryManager.cpp @@ -189,20 +189,22 @@ static bool hasRCAnnotation(const Decl *D, StringRef rcAnnotation) { } static bool isRetain(const FunctionDecl *FD, StringRef FName) { - return FName.startswith_lower("retain") || FName.endswith_lower("retain"); + return FName.startswith_insensitive("retain") || + FName.endswith_insensitive("retain"); } static bool isRelease(const FunctionDecl *FD, StringRef FName) { - return FName.startswith_lower("release") || FName.endswith_lower("release"); + return FName.startswith_insensitive("release") || + FName.endswith_insensitive("release"); } static bool isAutorelease(const FunctionDecl *FD, StringRef FName) { - return FName.startswith_lower("autorelease") || - FName.endswith_lower("autorelease"); + return FName.startswith_insensitive("autorelease") || + FName.endswith_insensitive("autorelease"); } static bool isMakeCollectable(StringRef FName) { -
[clang] b34da6f - [clang] Apply MS ABI details on __builtin_ms_va_list on non-windows platforms on x86_64
Author: Martin Storsjö Date: 2021-06-08T12:14:12+03:00 New Revision: b34da6ff9c1d72816d0c9b87d5f0e879850bc424 URL: https://github.com/llvm/llvm-project/commit/b34da6ff9c1d72816d0c9b87d5f0e879850bc424 DIFF: https://github.com/llvm/llvm-project/commit/b34da6ff9c1d72816d0c9b87d5f0e879850bc424.diff LOG: [clang] Apply MS ABI details on __builtin_ms_va_list on non-windows platforms on x86_64 This fixes inconsistencies in the ms_abi.c testcase. Also add a couple cases of missing double pointers in the windows part of the testcase; the outcome of building that testcase on windows hasn't changed, but the previous form of the test was imprecise (checking for "%[[STRUCT_FOO]]*" when clang actually generates "%[[STRUCT_FOO]]**"), which still used to match. Ideally this would share code with the native Windows case, but X86_64ABIInfo and WinX86_64ABIInfo aren't superclasses/subclasses of each other so it's impractical, and the code to share currently only consists of a couple lines. Differential Revision: https://reviews.llvm.org/D103837 Added: Modified: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGen/ms_abi.c Removed: diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 440153c45e80..2b3c0e3492a0 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -4161,7 +4161,12 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, Address X86_64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const { - return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false, + // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is + // not 1, 2, 4, or 8 bytes, must be passed by reference." + uint64_t Width = getContext().getTypeSize(Ty); + bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width); + + return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, CGF.getContext().getTypeInfoInChars(Ty), CharUnits::fromQuantity(8), /*allowHigherAlign*/ false); diff --git a/clang/test/CodeGen/ms_abi.c b/clang/test/CodeGen/ms_abi.c index 6df5020081cc..33165385b3f0 100644 --- a/clang/test/CodeGen/ms_abi.c +++ b/clang/test/CodeGen/ms_abi.c @@ -45,12 +45,12 @@ void __attribute__((ms_abi)) f4(int a, ...) { // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8 // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]] // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32* - // FIXME: These are diff erent now. We probably need __builtin_ms_va_arg. double _Complex c = __builtin_va_arg(ap, double _Complex); // FREEBSD: %[[AP_CUR2:.*]] = load i8*, i8** %[[AP]] - // FREEBSD-NEXT: %[[AP_NEXT2:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR2]], i64 16 + // FREEBSD-NEXT: %[[AP_NEXT2:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR2]], i64 8 // FREEBSD-NEXT: store i8* %[[AP_NEXT2]], i8** %[[AP]] - // FREEBSD-NEXT: bitcast i8* %[[AP_CUR2]] to { double, double }* + // FREEBSD-NEXT: %[[CUR2:.*]] = bitcast i8* %[[AP_CUR2]] to { double, double }** + // FREEBSD-NEXT: load { double, double }*, { double, double }** %[[CUR2]] // WIN64: %[[AP_CUR2:.*]] = load i8*, i8** %[[AP]] // WIN64-NEXT: %[[AP_NEXT2:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR2]], i64 8 // WIN64-NEXT: store i8* %[[AP_NEXT2]], i8** %[[AP]] @@ -58,9 +58,10 @@ void __attribute__((ms_abi)) f4(int a, ...) { // WIN64-NEXT: load { double, double }*, { double, double }** %[[CUR2]] struct foo d = __builtin_va_arg(ap, struct foo); // FREEBSD: %[[AP_CUR3:.*]] = load i8*, i8** %[[AP]] - // FREEBSD-NEXT: %[[AP_NEXT3:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR3]], i64 16 + // FREEBSD-NEXT: %[[AP_NEXT3:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR3]], i64 8 // FREEBSD-NEXT: store i8* %[[AP_NEXT3]], i8** %[[AP]] - // FREEBSD-NEXT: bitcast i8* %[[AP_CUR3]] to %[[STRUCT_FOO]]* + // FREEBSD-NEXT: %[[CUR3:.*]] = bitcast i8* %[[AP_CUR3]] to %[[STRUCT_FOO]]* + // FREEBSD-NEXT: load %[[STRUCT_FOO]]*, %[[STRUCT_FOO]]** %[[CUR3]] // WIN64: %[[AP_CUR3:.*]] = load i8*, i8** %[[AP]] // WIN64-NEXT: %[[AP_NEXT3:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR3]], i64 8 // WIN64-NEXT: store i8* %[[AP_NEXT3]], i8** %[[AP]] @@ -123,22 +124,22 @@ void __attribute__((sysv_abi)) f6(__builtin_ms_va_list ap) { // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32* double _Complex c = __builtin_va_arg(ap, double _Complex); // FREEBSD: %[[AP_CUR2:.*]] = load i8*, i8** %[[AP]] - // FREEBSD-NEXT: %[[AP_NEXT2:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR2]], i64 16 + // FREEBSD-NEXT: %[[AP_NEXT2:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR2]], i64 8 // FREEBSD-NEXT: store i8* %[[AP_NEXT2]], i8** %[[AP]] - // FREEBSD-NEXT: bitcast i8* %[[AP_CUR2]] to { do
[clang] 6de45b9 - [clang] Fix reading long doubles with va_arg on x86_64 mingw
Author: Martin Storsjö Date: 2021-06-07T22:34:10+03:00 New Revision: 6de45b9e6a2c4b69ca82916a4cc1b4b8636d79b3 URL: https://github.com/llvm/llvm-project/commit/6de45b9e6a2c4b69ca82916a4cc1b4b8636d79b3 DIFF: https://github.com/llvm/llvm-project/commit/6de45b9e6a2c4b69ca82916a4cc1b4b8636d79b3.diff LOG: [clang] Fix reading long doubles with va_arg on x86_64 mingw On x86_64 mingw, long doubles are always passed indirectly as arguments (see an existing case in WinX86_64ABIInfo::classify); generalize the existing code for reading varargs - any non-aggregate type that is larger than 64 bits (which would be both long double in mingw, and __int128) are passed indirectly too. This makes reading varargs consistent with how they're passed, fixing interop with both gcc and clang callers, for long double and __int128. Differential Revision: https://reviews.llvm.org/D103452 Added: Modified: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGen/mingw-long-double.c clang/test/CodeGen/win64-i128.c clang/test/CodeGenCXX/ext-int.cpp Removed: diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index af516bbc8d31..440153c45e80 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -4358,15 +4358,10 @@ void WinX86_64ABIInfo::computeInfo(CGFunctionInfo &FI) const { Address WinX86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const { - - bool IsIndirect = false; - // MS x64 ABI requirement: "Any argument that doesn't fit in 8 bytes, or is // not 1, 2, 4, or 8 bytes, must be passed by reference." - if (isAggregateTypeForABI(Ty) || Ty->isMemberPointerType()) { -uint64_t Width = getContext().getTypeSize(Ty); -IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width); - } + uint64_t Width = getContext().getTypeSize(Ty); + bool IsIndirect = Width > 64 || !llvm::isPowerOf2_64(Width); return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, CGF.getContext().getTypeInfoInChars(Ty), diff --git a/clang/test/CodeGen/mingw-long-double.c b/clang/test/CodeGen/mingw-long-double.c index b953192fcab7..39ce46898485 100644 --- a/clang/test/CodeGen/mingw-long-double.c +++ b/clang/test/CodeGen/mingw-long-double.c @@ -45,3 +45,19 @@ long double _Complex TestLDC(long double _Complex x) { // GNU32: declare dso_local void @__mulxc3 // GNU64: declare dso_local void @__mulxc3 // MSC64: declare dso_local void @__muldc3 + +void VarArgLD(int a, ...) { + // GNU32-LABEL: define{{.*}} void @VarArgLD + // GNU64-LABEL: define{{.*}} void @VarArgLD + // MSC64-LABEL: define{{.*}} void @VarArgLD + __builtin_va_list ap; + __builtin_va_start(ap, a); + long double LD = __builtin_va_arg(ap, long double); + // GNU32-NOT: load x86_fp80*, x86_fp80** + // GNU32: load x86_fp80, x86_fp80* + // GNU64: load x86_fp80*, x86_fp80** + // GNU64: load x86_fp80, x86_fp80* + // MSC64-NOT: load double*, double** + // MSC64: load double, double* + __builtin_va_end(ap); +} diff --git a/clang/test/CodeGen/win64-i128.c b/clang/test/CodeGen/win64-i128.c index 6031147b353d..fe32c57e99cf 100644 --- a/clang/test/CodeGen/win64-i128.c +++ b/clang/test/CodeGen/win64-i128.c @@ -14,3 +14,16 @@ int128_t bar(int128_t a, int128_t b) { return a * b; } // GNU64: define dso_local <2 x i64> @bar(i128* %0, i128* %1) // MSC64: define dso_local <2 x i64> @bar(i128* %0, i128* %1) + +void vararg(int a, ...) { + // GNU64-LABEL: define{{.*}} void @vararg + // MSC64-LABEL: define{{.*}} void @vararg + __builtin_va_list ap; + __builtin_va_start(ap, a); + int128_t i = __builtin_va_arg(ap, int128_t); + // GNU64: load i128*, i128** + // GNU64: load i128, i128* + // MSC64: load i128*, i128** + // MSC64: load i128, i128* + __builtin_va_end(ap); +} diff --git a/clang/test/CodeGenCXX/ext-int.cpp b/clang/test/CodeGenCXX/ext-int.cpp index 99ebe9454df2..7f3bc07e98dd 100644 --- a/clang/test/CodeGenCXX/ext-int.cpp +++ b/clang/test/CodeGenCXX/ext-int.cpp @@ -164,10 +164,11 @@ void TakesVarargs(int i, ...) { // LIN: store i92 %[[LOAD1]], i92* // WIN: %[[CUR1:.+]] = load i8*, i8** %[[ARGS]] - // WIN: %[[NEXT1:.+]] = getelementptr inbounds i8, i8* %[[CUR1]], i64 16 + // WIN: %[[NEXT1:.+]] = getelementptr inbounds i8, i8* %[[CUR1]], i64 8 // WIN: store i8* %[[NEXT1]], i8** %[[ARGS]] - // WIN: %[[BC1:.+]] = bitcast i8* %[[CUR1]] to i92* - // WIN: %[[LOADV1:.+]] = load i92, i92* %[[BC1]] + // WIN: %[[BC1:.+]] = bitcast i8* %[[CUR1]] to i92** + // WIN: %[[LOADP1:.+]] = load i92*, i92** %[[BC1]] + // WIN: %[[LOADV1:.+]] = load i92, i92* %[[LOADP1]] // WIN: store i92 %[[LOADV1]], i92* _ExtInt(31) B = __builtin_va_arg(args, _ExtInt(31)); @@ -215,10 +216,11 @@ void TakesVarargs(int i, ...) { // LIN: store i129 %[[LOAD4]], i129* // WIN: %[[CUR4:.+]] = load i8*, i8** %[[ARGS]]
[clang] f59cd8a - [clang] [MinGW] Fix gcc version detection/picking
Author: Martin Storsjö Date: 2021-05-28T11:44:20+03:00 New Revision: f59cd8a4a606643e7248cecc239e0d229feb3320 URL: https://github.com/llvm/llvm-project/commit/f59cd8a4a606643e7248cecc239e0d229feb3320 DIFF: https://github.com/llvm/llvm-project/commit/f59cd8a4a606643e7248cecc239e0d229feb3320.diff LOG: [clang] [MinGW] Fix gcc version detection/picking Actually compare each version to the version of the last chosen one. There's no guarantee that the added test case does showcase the previous issue (it depends on the order that directory entries are returned when iterating), but with the issue fixed it should behave deterministically in any case. Also improve the match patterns in the mingw-sysroot.cpp test a bit. Differential Revision: https://reviews.llvm.org/D102873 Added: clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include-fixed/.keep clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/backward/.keep clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/x86_64-w64-mingw32/.keep Modified: clang/lib/Driver/ToolChains/MinGW.cpp clang/test/Driver/mingw-sysroot.cpp clang/test/Driver/mingw.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index f6cead412236..4ebcdf6a9445 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -338,6 +338,7 @@ static bool findGccVersion(StringRef LibDir, std::string &GccLibDir, continue; if (CandidateVersion <= Version) continue; +Version = CandidateVersion; Ver = std::string(VersionText); GccLibDir = LI->path(); } diff --git a/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include-fixed/.keep b/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include-fixed/.keep new file mode 100644 index ..e69de29bb2d1 diff --git a/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/backward/.keep b/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/backward/.keep new file mode 100644 index ..e69de29bb2d1 diff --git a/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/x86_64-w64-mingw32/.keep b/clang/test/Driver/Inputs/mingw_ubuntu_posix_tree/usr/lib/gcc/x86_64-w64-mingw32/10.2-posix/include/c++/x86_64-w64-mingw32/.keep new file mode 100644 index ..e69de29bb2d1 diff --git a/clang/test/Driver/mingw-sysroot.cpp b/clang/test/Driver/mingw-sysroot.cpp index 63f970fb1e10..8a2fb7d373a8 100644 --- a/clang/test/Driver/mingw-sysroot.cpp +++ b/clang/test/Driver/mingw-sysroot.cpp @@ -18,17 +18,17 @@ // sysroot: // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %clang -target x86_64-w64-mingw32 -rtlib=platform -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_GCC %s -// CHECK_TESTROOT_GCC: "{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++" -// CHECK_TESTROOT_GCC: "{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32" -// CHECK_TESTROOT_GCC: "{{.*}}/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}5.3-posix{{/|}}include{{/|}}c++{{/|}}backward" -// CHECK_TESTROOT_GCC: "{{.*}}/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include" +// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE:[^"]+]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++" +// CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}x86_64-w64-mingw32" +// CHECK_TESTROOT_GCC-SAME: {{^}} "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}lib{{/|}}gcc{{/|}}x86_64-w64-mingw32{{/|}}10.2-posix{{/|}}include{{/|}}c++{{/|}}backward" +// CHECK_TESTROOT_GCC: "-internal-isystem" "[[BASE]]/testroot-gcc{{/|}}x86_64-w64-mingw32{{/|}}include" // If there's a matching sysroot next to the clang binary itself, prefer that // over a gcc in the path: // RUN: env "PATH=%T/testroot-gcc/bin:%PATH%" %T/testroot-clang/bin/x86_64-w64-mingw32-clang -target x86_64-w64-mingw32 -rtlib=compiler-rt -stdlib=libstdc++ --sysroot="" -c -### %s 2>&1 | FileCheck -check-prefix=CHECK_TESTROOT_CLANG %s -// CHECK_TESTROOT_CLANG: "{{.*}}/testroot-clang{{/|}}x86_64-w64-mingw32{{/|}}include"
[clang] 0e4cf80 - [clang] [MinGW] Don't mark emutls variables as DSO local
Author: Martin Storsjö Date: 2021-05-27T23:51:22+03:00 New Revision: 0e4cf807aeaf54a10e02176498a7df13ac722b37 URL: https://github.com/llvm/llvm-project/commit/0e4cf807aeaf54a10e02176498a7df13ac722b37 DIFF: https://github.com/llvm/llvm-project/commit/0e4cf807aeaf54a10e02176498a7df13ac722b37.diff LOG: [clang] [MinGW] Don't mark emutls variables as DSO local These actually can be automatically imported from another DLL. (This works properly as long as the actual implementation of emutls is linked dynamically from e.g. libgcc; if the implementation comes from compiler-rt or a statically linked libgcc, it doesn't work as intended.) This fixes PR50146 and https://github.com/msys2/MINGW-packages/issues/8706 (fixing calling std::call_once in a dynamically linked libstdc++); since f73183958482602c4588b0f4a1c3a096e7542947 the dso_local attribute on the TLS variable affected the actual generated code for accessing the emutls variable. The dso_local attribute on the emutls variable made those accesses to use 32 bit relative addressing in code, which requires runtime pseudo relocations in the text section, and breaks entirely if the actual other variable ends up loaded too far away in the virtual address space. Differential Revision: https://reviews.llvm.org/D102970 Added: Modified: clang/lib/CodeGen/CodeGenModule.cpp clang/test/CodeGen/dso-local-executable.c Removed: diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 744ccf0fe59f..9b31ecdbd81a 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -986,8 +986,13 @@ static bool shouldAssumeDSOLocal(const CodeGenModule &CGM, // In MinGW, variables without DLLImport can still be automatically // imported from a DLL by the linker; don't mark variables that // potentially could come from another DLL as DSO local. + +// With EmulatedTLS, TLS variables can be autoimported from other DLLs +// (and this actually happens in the public interface of libstdc++), so +// such variables can't be marked as DSO local. (Native TLS variables +// can't be dllimported at all, though.) if (GV->isDeclarationForLinker() && isa(GV) && -!GV->isThreadLocal()) +(!GV->isThreadLocal() || CGM.getCodeGenOpts().EmulatedTLS)) return false; } diff --git a/clang/test/CodeGen/dso-local-executable.c b/clang/test/CodeGen/dso-local-executable.c index 4c282a334b11..e16b8db9d4ed 100644 --- a/clang/test/CodeGen/dso-local-executable.c +++ b/clang/test/CodeGen/dso-local-executable.c @@ -9,13 +9,15 @@ // COFF-DAG: define dso_local i32* @zed() // COFF-DAG: declare dllimport void @import_func() -// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck --check-prefix=MINGW %s +// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - | FileCheck --check-prefixes=MINGW,MINGW-NATIVE_TLS %s +// RUN: %clang_cc1 -triple x86_64-w64-mingw32 -emit-llvm %s -o - -femulated-tls | FileCheck --check-prefixes=MINGW,MINGW-EMUTLS %s // MINGW: @baz = dso_local global i32 42 // MINGW-NEXT: @import_var = external dllimport global i32 // MINGW-NEXT: @weak_bar = extern_weak global i32 // MINGW-NEXT: @bar = external global i32 // MINGW-NEXT: @local_thread_var = dso_local thread_local global i32 42 -// MINGW-NEXT: @thread_var = external dso_local thread_local global i32 +// MINGW-NATIVE_TLS-NEXT: @thread_var = external dso_local thread_local global i32 +// MINGW-EMUTLS-NEXT: @thread_var = external thread_local global i32 // MINGW-DAG: declare dso_local void @foo() // MINGW-DAG: define dso_local i32* @zed() // MINGW-DAG: declare dllimport void @import_func() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4468e5b - [clang] Don't pass multiple backend options if mixing -mimplicit-it and -Wa,-mimplicit-it
Author: Martin Storsjö Date: 2021-05-22T00:05:31+03:00 New Revision: 4468e5b8999291cc84b78f33f207dcd0e58146bc URL: https://github.com/llvm/llvm-project/commit/4468e5b8999291cc84b78f33f207dcd0e58146bc DIFF: https://github.com/llvm/llvm-project/commit/4468e5b8999291cc84b78f33f207dcd0e58146bc.diff LOG: [clang] Don't pass multiple backend options if mixing -mimplicit-it and -Wa,-mimplicit-it If multiple instances of the -arm-implicit-it option is passed to the backend, it errors out. Also fix cases where there are multiple -Wa,-mimplicit-it; the existing tests indicate that the last one specified takes effect, while in practice it passed double options, which didn't work as intended. Differential Revision: https://reviews.llvm.org/D102812 Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/arm-target-as-mimplicit-it.s Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index d30195b558816..e668bf09ad25a 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2366,15 +2366,15 @@ void Clang::DumpCompilationDatabaseFragmentToDir( DumpCompilationDatabase(C, "", Target, Output, Input, Args); } -static bool AddARMImplicitITArgs(const ArgList &Args, ArgStringList &CmdArgs, +static bool CheckARMImplicitITArg(StringRef Value) { + return Value == "always" || Value == "never" || Value == "arm" || + Value == "thumb"; +} + +static void AddARMImplicitITArgs(const ArgList &Args, ArgStringList &CmdArgs, StringRef Value) { - if (Value == "always" || Value == "never" || Value == "arm" || - Value == "thumb") { -CmdArgs.push_back("-mllvm"); -CmdArgs.push_back(Args.MakeArgString("-arm-implicit-it=" + Value)); -return true; - } - return false; + CmdArgs.push_back("-mllvm"); + CmdArgs.push_back(Args.MakeArgString("-arm-implicit-it=" + Value)); } static void CollectArgsForIntegratedAssembler(Compilation &C, @@ -2393,22 +2393,6 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, DefaultIncrementalLinkerCompatible)) CmdArgs.push_back("-mincremental-linker-compatible"); - switch (C.getDefaultToolChain().getArch()) { - case llvm::Triple::arm: - case llvm::Triple::armeb: - case llvm::Triple::thumb: - case llvm::Triple::thumbeb: -if (Arg *A = Args.getLastArg(options::OPT_mimplicit_it_EQ)) { - StringRef Value = A->getValue(); - if (!AddARMImplicitITArgs(Args, CmdArgs, Value)) -D.Diag(diag::err_drv_unsupported_option_argument) -<< A->getOption().getName() << Value; -} -break; - default: -break; - } - // If you add more args here, also add them to the block below that // starts with "// If CollectArgsForIntegratedAssembler() isn't called below". @@ -2422,8 +2406,27 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, bool UseRelaxRelocations = C.getDefaultToolChain().useRelaxRelocations(); bool UseNoExecStack = C.getDefaultToolChain().isNoExecStackDefault(); const char *MipsTargetFeature = nullptr; + StringRef ImplicitIt; for (const Arg *A : - Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler)) { + Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler, + options::OPT_mimplicit_it_EQ)) { +if (A->getOption().getID() == options::OPT_mimplicit_it_EQ) { + switch (C.getDefaultToolChain().getArch()) { + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: +// Only store the value; the last value set takes effect. +ImplicitIt = A->getValue(); +if (!CheckARMImplicitITArg(ImplicitIt)) + D.Diag(diag::err_drv_unsupported_option_argument) + << A->getOption().getName() << ImplicitIt; +continue; + default: +break; + } +} + A->claim(); for (StringRef Value : A->getValues()) { @@ -2444,9 +2447,12 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, case llvm::Triple::thumbeb: case llvm::Triple::arm: case llvm::Triple::armeb: -if (Value.startswith("-mimplicit-it=") && -AddARMImplicitITArgs(Args, CmdArgs, Value.split("=").second)) - continue; +if (Value.startswith("-mimplicit-it=")) { + // Only store the value; the last value set takes effect. + ImplicitIt = Value.split("=").second; + if (CheckARMImplicitITArg(ImplicitIt)) +continue; +} if (Value == "-mthumb") // -mthumb has already been processed in ComputeLLVMTriple() // recognize but skip over here. @@ -2576,6 +2582,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, } } } + if (Implic
[clang] 688b917 - Revert "[Driver] Delete -mimplicit-it="
Author: Martin Storsjö Date: 2021-05-20T00:17:50+03:00 New Revision: 688b917b4b3cbe09bf4954b2c10b01ef57386c0a URL: https://github.com/llvm/llvm-project/commit/688b917b4b3cbe09bf4954b2c10b01ef57386c0a DIFF: https://github.com/llvm/llvm-project/commit/688b917b4b3cbe09bf4954b2c10b01ef57386c0a.diff LOG: Revert "[Driver] Delete -mimplicit-it=" This reverts commit 2919222d8017f2425a85765b95e4b7c6f8e70ca4. That commit broke backwards compatibility. Additionally, the replacement, -Wa,-mimplicit-it, isn't yet supported by any stable release of Clang. See D102812 for a fix for the error cases when callers specify both -mimplicit-it and -Wa,-mimplicit-it. Added: clang/test/Driver/arm-implicit-it.s Modified: clang/include/clang/Driver/Options.td clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/arm-target-as-mimplicit-it.s clang/test/Driver/as-options.s Removed: diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td index 1b78810bf352..1274f7a0af2e 100644 --- a/clang/include/clang/Driver/Options.td +++ b/clang/include/clang/Driver/Options.td @@ -3017,6 +3017,7 @@ def mtls_size_EQ : Joined<["-"], "mtls-size=">, Group, Flags<[NoXarchOp HelpText<"Specify bit size of immediate TLS offsets (AArch64 ELF only): " "12 (for 4KB) | 24 (for 16MB, default) | 32 (for 4GB) | 48 (for 256TB, needs -mcmodel=large)">, MarshallingInfoInt>; +def mimplicit_it_EQ : Joined<["-"], "mimplicit-it=">, Group; def mdefault_build_attributes : Joined<["-"], "mdefault-build-attributes">, Group; def mno_default_build_attributes : Joined<["-"], "mno-default-build-attributes">, Group; def mconstant_cfstrings : Flag<["-"], "mconstant-cfstrings">, Group; diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index add62e3ab4ab..2ef635469df0 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -2393,6 +2393,22 @@ static void CollectArgsForIntegratedAssembler(Compilation &C, DefaultIncrementalLinkerCompatible)) CmdArgs.push_back("-mincremental-linker-compatible"); + switch (C.getDefaultToolChain().getArch()) { + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: +if (Arg *A = Args.getLastArg(options::OPT_mimplicit_it_EQ)) { + StringRef Value = A->getValue(); + if (!AddARMImplicitITArgs(Args, CmdArgs, Value)) +D.Diag(diag::err_drv_unsupported_option_argument) +<< A->getOption().getName() << Value; +} +break; + default: +break; + } + // If you add more args here, also add them to the block below that // starts with "// If CollectArgsForIntegratedAssembler() isn't called below". @@ -4337,6 +4353,16 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, Args.ClaimAllArgs(options::OPT_mno_relax_all); Args.ClaimAllArgs(options::OPT_mincremental_linker_compatible); Args.ClaimAllArgs(options::OPT_mno_incremental_linker_compatible); + switch (C.getDefaultToolChain().getArch()) { + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: +Args.ClaimAllArgs(options::OPT_mimplicit_it_EQ); +break; + default: +break; + } } Args.ClaimAllArgs(options::OPT_Wa_COMMA); Args.ClaimAllArgs(options::OPT_Xassembler); diff --git a/clang/test/Driver/arm-implicit-it.s b/clang/test/Driver/arm-implicit-it.s new file mode 100644 index ..48e4bdbe8c95 --- /dev/null +++ b/clang/test/Driver/arm-implicit-it.s @@ -0,0 +1,24 @@ +// RUN: %clang -target armv7--none-eabi -### %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-DEFAULT + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=arm -### %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-ARM + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=thumb -### %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-THUMB + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=never -### %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-NEVER + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=always -### %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-ALWAYS + +// RUN: %clang -target armv7--none-eabi -mimplicit-it=thisisnotavalidoption -### %s 2>&1 \ +// RUN:| FileCheck %s -check-prefix CHECK-INVALID + +// CHECK-DEFAULT-NOT: "-arm-implicit-it +// CHECK-ARM: "-arm-implicit-it=arm" +// CHECK-THUMB: "-arm-implicit-it=thumb" +// CHECK-NEVER: "-arm-implicit-it=never" +// CHECK-ALWAYS: "-arm-implicit-it=always" +// CHECK-INVALID: error: unsupported argument 'thisisnotavalidoption' to option 'mimplicit-it=' diff --git a/clang/test/Driver/arm-target-as-mimplicit-it.s b/clang/test/Driver/arm-target-as-mimplicit-it.
[clang] f8de9aa - [llvm-rc] Add a GNU windres-like frontend to llvm-rc
Author: Martin Storsjö Date: 2021-04-26T22:04:29+03:00 New Revision: f8de9aaef2f472ad7572748582444083d31d5a95 URL: https://github.com/llvm/llvm-project/commit/f8de9aaef2f472ad7572748582444083d31d5a95 DIFF: https://github.com/llvm/llvm-project/commit/f8de9aaef2f472ad7572748582444083d31d5a95.diff LOG: [llvm-rc] Add a GNU windres-like frontend to llvm-rc This primarily parses a different set of options and invokes the same resource compiler as llvm-rc normally. Additionally, it can convert directly to an object file (which in MSVC style setups is done with the separate cvtres tool, or by the linker). (GNU windres also supports other conversions; from coff object file back to .res, and from .res or object file back to .rc form; that's not yet implemented.) The other bigger complication lies in being able to imply or pass the intended target triple, to let clang find the corresponding mingw sysroot for finding include files, and for specifying the default output object machine format. It can be implied from the tool triple prefix, like `-[llvm-]windres` or picked up from the windres option e.g. `-F pe-x86-64`. In GNU windres, that option takes BFD style format names such as pe-i386 or pe-x86-64. As libbfd in binutils doesn't support Windows on ARM, there's no such canonical name for the ARM targets. Therefore, as an LLVM specific extension, this option is extended to allow passing full triples, too. Differential Revision: https://reviews.llvm.org/D100756 Added: clang/test/Preprocessor/Inputs/llvm-windres.h clang/test/Preprocessor/llvm-windres.rc llvm/test/tools/llvm-rc/windres-format.test llvm/test/tools/llvm-rc/windres-prefix.test llvm/test/tools/llvm-rc/windres-preproc.test llvm/test/tools/llvm-rc/windres-target.test llvm/test/tools/llvm-rc/windres-version.test llvm/tools/llvm-rc/WindresOpts.td Modified: clang/test/CMakeLists.txt llvm/test/CMakeLists.txt llvm/test/lit.cfg.py llvm/test/tools/llvm-rc/codepage.test llvm/test/tools/llvm-rc/language.test llvm/tools/llvm-rc/CMakeLists.txt llvm/tools/llvm-rc/llvm-rc.cpp Removed: diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt index 1325a0308d69e..f87b32a97fa67 100644 --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -125,6 +125,7 @@ if( NOT CLANG_BUILT_STANDALONE ) llvm-readobj llvm-strip llvm-symbolizer +llvm-windres opt split-file yaml2obj diff --git a/clang/test/Preprocessor/Inputs/llvm-windres.h b/clang/test/Preprocessor/Inputs/llvm-windres.h new file mode 100644 index 0..411ec48a8af9f --- /dev/null +++ b/clang/test/Preprocessor/Inputs/llvm-windres.h @@ -0,0 +1,10 @@ +#ifndef RC_INVOKED +#error RC_INVOKED not defined +#endif +#ifndef _WIN32 +#error _WIN32 not defined +#endif +#ifndef __MINGW32__ +#error __MINGW32__ not defined +#endif +#define MY_ID 42 diff --git a/clang/test/Preprocessor/llvm-windres.rc b/clang/test/Preprocessor/llvm-windres.rc new file mode 100644 index 0..3356cd1e253fd --- /dev/null +++ b/clang/test/Preprocessor/llvm-windres.rc @@ -0,0 +1,8 @@ +// RUN: llvm-windres -I%p/Inputs %s %t.res +// RUN: llvm-readobj %t.res | FileCheck %s +// CHECK: Resource type (int): RCDATA (ID 10) +// CHECK: Resource name (int): 42 +#include "llvm-windres.h" +MY_ID RCDATA { + "a long string of data" +} diff --git a/llvm/test/CMakeLists.txt b/llvm/test/CMakeLists.txt index bd02027c06038..77035899a6d98 100644 --- a/llvm/test/CMakeLists.txt +++ b/llvm/test/CMakeLists.txt @@ -117,6 +117,7 @@ set(LLVM_TEST_DEPENDS llvm-symbolizer llvm-tblgen llvm-undname + llvm-windres llvm-xray not obj2yaml diff --git a/llvm/test/lit.cfg.py b/llvm/test/lit.cfg.py index c66f6de56b8af..944276461be69 100644 --- a/llvm/test/lit.cfg.py +++ b/llvm/test/lit.cfg.py @@ -163,7 +163,8 @@ def get_asan_rtlib(): 'llvm-modextract', 'llvm-nm', 'llvm-objcopy', 'llvm-objdump', 'llvm-otool', 'llvm-pdbutil', 'llvm-profdata', 'llvm-profgen', 'llvm-ranlib', 'llvm-rc', 'llvm-readelf', 'llvm-readobj', 'llvm-rtdyld', 'llvm-size', 'llvm-split', 'llvm-strings', -'llvm-strip', 'llvm-tblgen', 'llvm-undname', 'llvm-c-test', 'llvm-cxxfilt', +'llvm-strip', 'llvm-tblgen', 'llvm-undname', 'llvm-windres', +'llvm-c-test', 'llvm-cxxfilt', 'llvm-xray', 'yaml2obj', 'obj2yaml', 'yaml-bench', 'verify-uselistorder', 'bugpoint', 'llc', 'llvm-symbolizer', 'opt', 'sancov', 'sanstats']) diff --git a/llvm/test/tools/llvm-rc/codepage.test b/llvm/test/tools/llvm-rc/codepage.test index 406ff00be53b0..20639d42ecb82 100644 --- a/llvm/test/tools/llvm-rc/codepage.test +++ b/llvm/test/tools/llvm-rc/codepage.test @@ -1,5 +1,9 @@ ; RUN: llvm-rc -no-preprocess /C 65001 /FO %t.utf8.res -- %p/Inputs/utf8.rc ; RUN: llvm-readobj %t.utf8.res | FileCheck %s --check
[clang] 174e796 - [llvm-rc] Fix a new test to disambiguate macOS paths like /Users/... from options starting with a slash
Author: Martin Storsjö Date: 2021-04-21T13:34:33+03:00 New Revision: 174e796c7d41e720e2a78e3de451b893d9e3a43f URL: https://github.com/llvm/llvm-project/commit/174e796c7d41e720e2a78e3de451b893d9e3a43f DIFF: https://github.com/llvm/llvm-project/commit/174e796c7d41e720e2a78e3de451b893d9e3a43f.diff LOG: [llvm-rc] Fix a new test to disambiguate macOS paths like /Users/... from options starting with a slash This should fix test failures on macOS. Added: Modified: clang/test/Preprocessor/llvm-rc.rc Removed: diff --git a/clang/test/Preprocessor/llvm-rc.rc b/clang/test/Preprocessor/llvm-rc.rc index 799bf347dbee..f08fdd0506bb 100644 --- a/clang/test/Preprocessor/llvm-rc.rc +++ b/clang/test/Preprocessor/llvm-rc.rc @@ -1,4 +1,4 @@ -// RUN: llvm-rc -v -i%p/Inputs -Fo%t.res %s +// RUN: llvm-rc -v -i%p/Inputs -Fo%t.res -- %s // RUN: llvm-readobj %t.res | FileCheck %s // CHECK: Resource type (int): RCDATA (ID 10) // CHECK: Resource name (int): 42 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 066b8f2 - [llvm-rc] Try to fix the Preprocessor/llvm-rc.rc test on non arm/x86 architectures
Author: Martin Storsjö Date: 2021-04-21T12:47:33+03:00 New Revision: 066b8f2fc6d584635a017a0a15494ce4460744e3 URL: https://github.com/llvm/llvm-project/commit/066b8f2fc6d584635a017a0a15494ce4460744e3 DIFF: https://github.com/llvm/llvm-project/commit/066b8f2fc6d584635a017a0a15494ce4460744e3.diff LOG: [llvm-rc] Try to fix the Preprocessor/llvm-rc.rc test on non arm/x86 architectures When llvm-rc invokes clang for preprocessing, it uses a target triple derived from the default target. The test verifies that e.g. _WIN32 is defined when preprocessing. If running clang with e.g. -target ppc64le-windows-msvc, that particular arch/OS combination isn't hooked up, so _WIN32 doesn't get defined in that configuration. Therefore, the preprocessing test fails. Instead make llvm-rc inspect the architecture of the default target. If it's one of the known supported architectures, use it as such, otherwise set a default one (x86_64). (Clang can run preprocessing with an x86_64 target triple, even if the x86 backend isn't enabled.) Also remove superfluous llvm:: specifications on enums in llvm-rc.cpp. Added: Modified: clang/test/Preprocessor/llvm-rc.rc llvm/tools/llvm-rc/llvm-rc.cpp Removed: diff --git a/clang/test/Preprocessor/llvm-rc.rc b/clang/test/Preprocessor/llvm-rc.rc index 689fc87473f9..799bf347dbee 100644 --- a/clang/test/Preprocessor/llvm-rc.rc +++ b/clang/test/Preprocessor/llvm-rc.rc @@ -1,4 +1,4 @@ -// RUN: llvm-rc -i%p/Inputs -Fo%t.res %s +// RUN: llvm-rc -v -i%p/Inputs -Fo%t.res %s // RUN: llvm-readobj %t.res | FileCheck %s // CHECK: Resource type (int): RCDATA (ID 10) // CHECK: Resource name (int): 42 diff --git a/llvm/tools/llvm-rc/llvm-rc.cpp b/llvm/tools/llvm-rc/llvm-rc.cpp index ab5ecb8fa3fd..b61fba78ad01 100644 --- a/llvm/tools/llvm-rc/llvm-rc.cpp +++ b/llvm/tools/llvm-rc/llvm-rc.cpp @@ -114,10 +114,25 @@ ErrorOr findClang(const char *Argv0) { std::string getClangClTriple() { Triple T(sys::getDefaultTargetTriple()); - T.setOS(llvm::Triple::Win32); - T.setVendor(llvm::Triple::PC); - T.setEnvironment(llvm::Triple::MSVC); - T.setObjectFormat(llvm::Triple::COFF); + switch (T.getArch()) { + case Triple::x86: + case Triple::x86_64: + case Triple::arm: + case Triple::thumb: + case Triple::aarch64: +// These work properly with the clang driver, setting the expected +// defines such as _WIN32 etc. +break; + default: +// Other archs aren't set up for use with windows as target OS, (clang +// doesn't define e.g. _WIN32 etc), so set a reasonable default arch. +T.setArch(Triple::x86_64); +break; + } + T.setOS(Triple::Win32); + T.setVendor(Triple::PC); + T.setEnvironment(Triple::MSVC); + T.setObjectFormat(Triple::COFF); return T.str(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 64bc44f - [llvm-rc] Run clang to preprocess input files
Author: Martin Storsjö Date: 2021-04-21T11:50:10+03:00 New Revision: 64bc44f5ddfb6da4b6a8b51ea9a03f8772b3ae95 URL: https://github.com/llvm/llvm-project/commit/64bc44f5ddfb6da4b6a8b51ea9a03f8772b3ae95 DIFF: https://github.com/llvm/llvm-project/commit/64bc44f5ddfb6da4b6a8b51ea9a03f8772b3ae95.diff LOG: [llvm-rc] Run clang to preprocess input files Allow opting out from preprocessing with a command line argument. Update tests to pass -no-preprocess to make it not try to use clang (which isn't a build level dependency of llvm-rc), but add a test that does preprocessing under clang/test/Preprocessor. Update a few options to allow them both joined (as -DFOO) and separate (-D BR), as rc.exe allows both forms of them. With the verbose flag set, this prints the preprocessing command used (which differs from what rc.exe does). Tests under llvm/test/tools/llvm-rc only test constructing the preprocessor commands, while tests under clang/test/Preprocessor test actually running the preprocessor. Differential Revision: https://reviews.llvm.org/D100755 Added: clang/test/Preprocessor/Inputs/llvm-rc.h clang/test/Preprocessor/llvm-rc.rc llvm/test/tools/llvm-rc/preproc.test Modified: clang/test/CMakeLists.txt clang/test/lit.cfg.py llvm/test/tools/llvm-rc/absolute.test llvm/test/tools/llvm-rc/codepage.test llvm/test/tools/llvm-rc/cpp-output.test llvm/test/tools/llvm-rc/flags.test llvm/test/tools/llvm-rc/helpmsg.test llvm/test/tools/llvm-rc/include-paths.test llvm/test/tools/llvm-rc/language.test llvm/test/tools/llvm-rc/memoryflags-stringtable.test llvm/test/tools/llvm-rc/memoryflags.test llvm/test/tools/llvm-rc/not-expr.test llvm/test/tools/llvm-rc/parser-expr.test llvm/test/tools/llvm-rc/parser.test llvm/test/tools/llvm-rc/tag-accelerators.test llvm/test/tools/llvm-rc/tag-dialog.test llvm/test/tools/llvm-rc/tag-escape.test llvm/test/tools/llvm-rc/tag-html.test llvm/test/tools/llvm-rc/tag-icon-cursor.test llvm/test/tools/llvm-rc/tag-menu.test llvm/test/tools/llvm-rc/tag-stringtable.test llvm/test/tools/llvm-rc/tag-user.test llvm/test/tools/llvm-rc/tag-versioninfo.test llvm/test/tools/llvm-rc/tokenizer.test llvm/test/tools/llvm-rc/versioninfo-padding.test llvm/tools/llvm-rc/Opts.td llvm/tools/llvm-rc/llvm-rc.cpp Removed: diff --git a/clang/test/CMakeLists.txt b/clang/test/CMakeLists.txt index 562a148260338..1325a0308d69e 100644 --- a/clang/test/CMakeLists.txt +++ b/clang/test/CMakeLists.txt @@ -120,6 +120,7 @@ if( NOT CLANG_BUILT_STANDALONE ) llvm-objcopy llvm-objdump llvm-profdata +llvm-rc llvm-readelf llvm-readobj llvm-strip diff --git a/clang/test/Preprocessor/Inputs/llvm-rc.h b/clang/test/Preprocessor/Inputs/llvm-rc.h new file mode 100644 index 0..dcc91c20961c4 --- /dev/null +++ b/clang/test/Preprocessor/Inputs/llvm-rc.h @@ -0,0 +1,7 @@ +#ifndef RC_INVOKED +#error RC_INVOKED not defined +#endif +#ifndef _WIN32 +#error _WIN32 not defined +#endif +#define MY_ID 42 diff --git a/clang/test/Preprocessor/llvm-rc.rc b/clang/test/Preprocessor/llvm-rc.rc new file mode 100644 index 0..689fc87473f92 --- /dev/null +++ b/clang/test/Preprocessor/llvm-rc.rc @@ -0,0 +1,8 @@ +// RUN: llvm-rc -i%p/Inputs -Fo%t.res %s +// RUN: llvm-readobj %t.res | FileCheck %s +// CHECK: Resource type (int): RCDATA (ID 10) +// CHECK: Resource name (int): 42 +#include "llvm-rc.h" +MY_ID RCDATA { + "a long string of data" +} diff --git a/clang/test/lit.cfg.py b/clang/test/lit.cfg.py index 63ba8160c6612..7411e87169435 100644 --- a/clang/test/lit.cfg.py +++ b/clang/test/lit.cfg.py @@ -26,7 +26,7 @@ # suffixes: A list of file extensions to treat as test files. config.suffixes = ['.c', '.cpp', '.i', '.cppm', '.m', '.mm', '.cu', '.hip', - '.ll', '.cl', '.clcpp', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs'] + '.ll', '.cl', '.clcpp', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs', '.rc'] # excludes: A list of directories to exclude from the testsuite. The 'Inputs' # subdirectories contain auxiliary inputs for various tests in their parent diff --git a/llvm/test/tools/llvm-rc/absolute.test b/llvm/test/tools/llvm-rc/absolute.test index fd8b2d68d41e2..fd054536b3bfd 100644 --- a/llvm/test/tools/llvm-rc/absolute.test +++ b/llvm/test/tools/llvm-rc/absolute.test @@ -1,7 +1,7 @@ ; RUN: touch %t.manifest ; RUN: echo "1 24 \"%t.manifest\"" > %t.rc -; RUN: llvm-rc -- %t.rc +; RUN: llvm-rc -no-preprocess -- %t.rc ;; On Windows, try stripping out the drive name from the absolute path, ;; and make sure the path still is found. ; RUN: cat %t.rc | sed 's/"[a-zA-Z]:/"/' > %t2.rc -; RUN: llvm-rc -- %t2.rc +; RUN: llvm-rc -no-preprocess -- %t2.rc diff --git a/llvm/test/tools/llvm-rc/codepage.test b/llvm/test/tools/llvm-rc/codepage.test
[clang] d4528cb - [clang] Fix cross compiling clang for windows after 141945f950e2f3f
Author: Martin Storsjö Date: 2021-04-18T15:56:18+03:00 New Revision: d4528cbb0e703ee17ee6fb4abe72b7246ccb38f1 URL: https://github.com/llvm/llvm-project/commit/d4528cbb0e703ee17ee6fb4abe72b7246ccb38f1 DIFF: https://github.com/llvm/llvm-project/commit/d4528cbb0e703ee17ee6fb4abe72b7246ccb38f1.diff LOG: [clang] Fix cross compiling clang for windows after 141945f950e2f3f Don't try to execute clang-ast-dump when cross compiling. Added: Modified: clang/lib/Tooling/CMakeLists.txt Removed: diff --git a/clang/lib/Tooling/CMakeLists.txt b/clang/lib/Tooling/CMakeLists.txt index dfb732371dfb..a0bb108a2b6c 100644 --- a/clang/lib/Tooling/CMakeLists.txt +++ b/clang/lib/Tooling/CMakeLists.txt @@ -25,6 +25,7 @@ string(CONCAT BINARY_INCLUDE_DIR ${PATH_HEAD} "/include/clang/" ${PATH_TAIL}) if (NOT Python3_EXECUTABLE OR APPLE +OR CMAKE_CROSSCOMPILING OR GENERATOR_IS_MULTI_CONFIG OR NOT LLVM_NATIVE_ARCH IN_LIST LLVM_TARGETS_TO_BUILD OR NOT X86 IN_LIST LLVM_TARGETS_TO_BUILD ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 8e0f2e8 - [clang] [AArch64] Fix handling of HFAs passed to Windows variadic functions
Author: Martin Storsjö Date: 2021-04-15T22:21:27+03:00 New Revision: 8e0f2e89ff951c74875ed751e2215cc263b33328 URL: https://github.com/llvm/llvm-project/commit/8e0f2e89ff951c74875ed751e2215cc263b33328 DIFF: https://github.com/llvm/llvm-project/commit/8e0f2e89ff951c74875ed751e2215cc263b33328.diff LOG: [clang] [AArch64] Fix handling of HFAs passed to Windows variadic functions The documentation says that for variadic functions, all composites are treated similarly, no special handling of HFAs/HVAs, not even for the fixed arguments of a variadic function. Differential Revision: https://reviews.llvm.org/D100467 Added: Modified: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGen/ms_abi_aarch64.c Removed: diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 3ff3eed15608..bd3c26537892 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -5418,7 +5418,8 @@ class AArch64ABIInfo : public SwiftABIInfo { bool isDarwinPCS() const { return Kind == DarwinPCS; } ABIArgInfo classifyReturnType(QualType RetTy, bool IsVariadic) const; - ABIArgInfo classifyArgumentType(QualType RetTy) const; + ABIArgInfo classifyArgumentType(QualType RetTy, bool IsVariadic, + unsigned CallingConvention) const; ABIArgInfo coerceIllegalVector(QualType Ty) const; bool isHomogeneousAggregateBaseType(QualType Ty) const override; bool isHomogeneousAggregateSmallEnough(const Type *Ty, @@ -5432,7 +5433,8 @@ class AArch64ABIInfo : public SwiftABIInfo { classifyReturnType(FI.getReturnType(), FI.isVariadic()); for (auto &it : FI.arguments()) - it.info = classifyArgumentType(it.type); + it.info = classifyArgumentType(it.type, FI.isVariadic(), + FI.getCallingConvention()); } Address EmitDarwinVAArg(Address VAListAddr, QualType Ty, @@ -5635,7 +5637,9 @@ ABIArgInfo AArch64ABIInfo::coerceIllegalVector(QualType Ty) const { return getNaturalAlignIndirect(Ty, /*ByVal=*/false); } -ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty) const { +ABIArgInfo +AArch64ABIInfo::classifyArgumentType(QualType Ty, bool IsVariadic, + unsigned CallingConvention) const { Ty = useFirstFieldIfTransparentUnion(Ty); // Handle illegal vector types here. @@ -5681,7 +5685,11 @@ ABIArgInfo AArch64ABIInfo::classifyArgumentType(QualType Ty) const { // Homogeneous Floating-point Aggregates (HFAs) need to be expanded. const Type *Base = nullptr; uint64_t Members = 0; - if (isHomogeneousAggregate(Ty, Base, Members)) { + bool IsWin64 = Kind == Win64 || CallingConvention == llvm::CallingConv::Win64; + bool IsWinVariadic = IsWin64 && IsVariadic; + // In variadic functions on Windows, all composite types are treated alike, + // no special handling of HFAs/HVAs. + if (!IsWinVariadic && isHomogeneousAggregate(Ty, Base, Members)) { return ABIArgInfo::getDirect( llvm::ArrayType::get(CGT.ConvertType(QualType(Base, 0)), Members)); } @@ -5838,10 +5846,10 @@ bool AArch64ABIInfo::isHomogeneousAggregateSmallEnough(const Type *Base, return Members <= 4; } -Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, -QualType Ty, -CodeGenFunction &CGF) const { - ABIArgInfo AI = classifyArgumentType(Ty); +Address AArch64ABIInfo::EmitAAPCSVAArg(Address VAListAddr, QualType Ty, + CodeGenFunction &CGF) const { + ABIArgInfo AI = classifyArgumentType(Ty, /*IsVariadic=*/true, + CGF.CurFnInfo->getCallingConvention()); bool IsIndirect = AI.isIndirect(); llvm::Type *BaseTy = CGF.ConvertType(Ty); diff --git a/clang/test/CodeGen/ms_abi_aarch64.c b/clang/test/CodeGen/ms_abi_aarch64.c index 8526ce934ef5..cf244420296d 100644 --- a/clang/test/CodeGen/ms_abi_aarch64.c +++ b/clang/test/CodeGen/ms_abi_aarch64.c @@ -84,3 +84,39 @@ void f5(int a, ...) { __builtin_va_end(ap); // WIN64: call void @llvm.va_end } + +struct HFA { + float a, b, c; +}; + +__attribute__((ms_abi)) void msabi_hfa(struct HFA a); +__attribute__((ms_abi)) void msabi_hfa_vararg(struct HFA a, int b, ...); + +void call_msabi_hfa(void) { + // COMMON-LABEL: define{{.*}} void @call_msabi_hfa() + // WIN64: call void @msabi_hfa([3 x float] {{.*}}) + // LINUX: call win64cc void @msabi_hfa([3 x float] {{.*}}) + msabi_hfa((struct HFA){1.0f, 2.0f, 3.0f}); +} + +void call_msabi_hfa_vararg(void) { + // COMMON-LABEL: define{{.*}} void @call_msabi_hfa_vararg() + // WIN64: call void ([2 x i64], i32, ...) @msabi_hfa_vararg([2 x i64] {{.*}}, i32 4, [2 x i64] {{.*}}) + // LINUX: call win64cc void ([2 x i64], i32, ...) @msabi_hfa_vararg([2 x i64] {{.*}}, i32 4, [2 x i64] {{.*}}) + msab
[clang] ee570e2 - [clang] [test] Share patterns in CodeGen/ms_abi_aarch64.c between cases. NFC.
Author: Martin Storsjö Date: 2021-04-15T11:02:14+03:00 New Revision: ee570e215353625a867fcbfd8c3089e9e0f8660d URL: https://github.com/llvm/llvm-project/commit/ee570e215353625a867fcbfd8c3089e9e0f8660d DIFF: https://github.com/llvm/llvm-project/commit/ee570e215353625a867fcbfd8c3089e9e0f8660d.diff LOG: [clang] [test] Share patterns in CodeGen/ms_abi_aarch64.c between cases. NFC. Differential Revision: https://reviews.llvm.org/D100468 Added: Modified: clang/test/CodeGen/ms_abi_aarch64.c Removed: diff --git a/clang/test/CodeGen/ms_abi_aarch64.c b/clang/test/CodeGen/ms_abi_aarch64.c index 52685618176b..8526ce934ef5 100644 --- a/clang/test/CodeGen/ms_abi_aarch64.c +++ b/clang/test/CodeGen/ms_abi_aarch64.c @@ -18,8 +18,7 @@ void f3(void) { // LINUX: call win64cc void @f1() // WIN64: call void @f1() f2(); - // LINUX: call void @f2() - // WIN64: call void @f2() + // COMMON: call void @f2() } // LINUX: declare win64cc void @f1() // LINUX: declare void @f2() @@ -32,28 +31,19 @@ void __attribute__((ms_abi)) f4(int a, ...) { // WIN64-LABEL: define dso_local void @f4 __builtin_ms_va_list ap; __builtin_ms_va_start(ap, a); - // LINUX: %[[AP:.*]] = alloca i8* - // LINUX: call void @llvm.va_start - // WIN64: %[[AP:.*]] = alloca i8* - // WIN64: call void @llvm.va_start + // COMMON: %[[AP:.*]] = alloca i8* + // COMMON: call void @llvm.va_start int b = __builtin_va_arg(ap, int); - // LINUX: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]] - // LINUX-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8 - // LINUX-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]] - // LINUX-NEXT: bitcast i8* %[[AP_CUR]] to i32* - // WIN64: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]] - // WIN64-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8 - // WIN64-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]] - // WIN64-NEXT: bitcast i8* %[[AP_CUR]] to i32* + // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]] + // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8 + // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]] + // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to i32* __builtin_ms_va_list ap2; __builtin_ms_va_copy(ap2, ap); - // LINUX: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]] - // LINUX-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]] - // WIN64: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]] - // WIN64-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]] + // COMMON: %[[AP_VAL:.*]] = load i8*, i8** %[[AP]] + // COMMON-NEXT: store i8* %[[AP_VAL]], i8** %[[AP2:.*]] __builtin_ms_va_end(ap); - // LINUX: call void @llvm.va_end - // WIN64: call void @llvm.va_end + // COMMON: call void @llvm.va_end } void __attribute__((ms_abi)) f4_2(int a, ...) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3637c5c - [clang] [AArch64] Fix Windows va_arg handling for larger structs
Author: Martin Storsjö Date: 2021-04-14T14:51:53+03:00 New Revision: 3637c5c8ec3d4dc0b87eb4e3ee9c9ae8816cade2 URL: https://github.com/llvm/llvm-project/commit/3637c5c8ec3d4dc0b87eb4e3ee9c9ae8816cade2 DIFF: https://github.com/llvm/llvm-project/commit/3637c5c8ec3d4dc0b87eb4e3ee9c9ae8816cade2.diff LOG: [clang] [AArch64] Fix Windows va_arg handling for larger structs Aggregate types over 16 bytes are passed by reference. Contrary to the x86_64 ABI, smaller structs with an odd (non power of two) are padded and passed in registers. Differential Revision: https://reviews.llvm.org/D100374 Added: Modified: clang/lib/CodeGen/TargetInfo.cpp clang/test/CodeGen/ms_abi_aarch64.c Removed: diff --git a/clang/lib/CodeGen/TargetInfo.cpp b/clang/lib/CodeGen/TargetInfo.cpp index 55e38741e287..3ff3eed15608 100644 --- a/clang/lib/CodeGen/TargetInfo.cpp +++ b/clang/lib/CodeGen/TargetInfo.cpp @@ -6121,7 +6121,13 @@ Address AArch64ABIInfo::EmitDarwinVAArg(Address VAListAddr, QualType Ty, Address AArch64ABIInfo::EmitMSVAArg(CodeGenFunction &CGF, Address VAListAddr, QualType Ty) const { - return emitVoidPtrVAArg(CGF, VAListAddr, Ty, /*indirect*/ false, + bool IsIndirect = false; + + // Composites larger than 16 bytes are passed by reference. + if (isAggregateTypeForABI(Ty) && getContext().getTypeSize(Ty) > 128) +IsIndirect = true; + + return emitVoidPtrVAArg(CGF, VAListAddr, Ty, IsIndirect, CGF.getContext().getTypeInfoInChars(Ty), CharUnits::fromQuantity(8), /*allowHigherAlign*/ false); diff --git a/clang/test/CodeGen/ms_abi_aarch64.c b/clang/test/CodeGen/ms_abi_aarch64.c index bbb4be94d7dc..52685618176b 100644 --- a/clang/test/CodeGen/ms_abi_aarch64.c +++ b/clang/test/CodeGen/ms_abi_aarch64.c @@ -1,5 +1,13 @@ -// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck -check-prefix=LINUX %s -// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck -check-prefix=WIN64 %s +// RUN: %clang_cc1 -triple aarch64-linux-gnu -emit-llvm < %s | FileCheck -check-prefixes=LINUX,COMMON %s +// RUN: %clang_cc1 -triple aarch64-pc-win32 -emit-llvm < %s | FileCheck -check-prefixes=WIN64,COMMON %s + +struct small_odd { + char a, b, c; +}; + +struct larger { + int a, b, c, d, e; +}; void __attribute__((ms_abi)) f1(void); void f2(void); @@ -48,6 +56,26 @@ void __attribute__((ms_abi)) f4(int a, ...) { // WIN64: call void @llvm.va_end } +void __attribute__((ms_abi)) f4_2(int a, ...) { + // LINUX-LABEL: define{{.*}} win64cc void @f4_2 + // WIN64-LABEL: define dso_local void @f4_2 + __builtin_ms_va_list ap; + __builtin_ms_va_start(ap, a); + // COMMON: %[[AP:.*]] = alloca i8* + // COMMON: call void @llvm.va_start + struct small_odd s1 = __builtin_va_arg(ap, struct small_odd); + // COMMON: %[[AP_CUR:.*]] = load i8*, i8** %[[AP]] + // COMMON-NEXT: %[[AP_NEXT:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR]], i64 8 + // COMMON-NEXT: store i8* %[[AP_NEXT]], i8** %[[AP]] + // COMMON-NEXT: bitcast i8* %[[AP_CUR]] to %struct.small_odd* + struct larger s2 = __builtin_va_arg(ap, struct larger); + // COMMON: %[[AP_CUR2:.*]] = load i8*, i8** %[[AP]] + // COMMON-NEXT: %[[AP_NEXT3:.*]] = getelementptr inbounds i8, i8* %[[AP_CUR2]], i64 8 + // COMMON-NEXT: store i8* %[[AP_NEXT3]], i8** %[[AP]] + // COMMON-NEXT: bitcast i8* %[[AP_CUR2]] to %struct.larger** + __builtin_ms_va_end(ap); +} + // Let's verify that normal va_lists work right on Win64, too. void f5(int a, ...) { // WIN64-LABEL: define dso_local void @f5 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e81d813 - [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to compiler-rt
Author: Martin Storsjö Date: 2021-03-08T22:29:54+02:00 New Revision: e81d813717b2ef227c5b995057153d2cca027afb URL: https://github.com/llvm/llvm-project/commit/e81d813717b2ef227c5b995057153d2cca027afb DIFF: https://github.com/llvm/llvm-project/commit/e81d813717b2ef227c5b995057153d2cca027afb.diff LOG: [clang] Don't set CLANG_DEFAULT_UNWINDLIB to none if rtlib is set to compiler-rt 002dd47bdd674fad8186650f07458b1e062545df was meant to not be any functional change, but it turned out it was. With CLANG_DEFAULT_RTLIB set to compiler-rt, CLANG_DEFAULT_UNWINDLIB used to bet set to an empty string, but now was set to "none". If one only overrode rtlib to libgcc, one previously would get libgcc as unwind lib, but now didn't. This caused test failures, fixed in 41476d89b82647c1ff690fdc805c859262d571e5. Secondly, for the android target, the previous default was to link libunwind, which this now changed. Reinstate the exact same behaviour as before (removing the previously typoed cmake check) and fix the option comment in one place to match the other one above. Differential Revision: https://reviews.llvm.org/D98142 Added: Modified: clang/CMakeLists.txt Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index f0fa61a0c3f7..4695dc8a46ff 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -262,8 +262,6 @@ set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING if (CLANG_DEFAULT_UNWINDLIB STREQUAL "") if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc") set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE) - elseif (CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt") -set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE) endif() endif() @@ -273,7 +271,7 @@ if (NOT(CLANG_DEFAULT_UNWINDLIB STREQUAL "" OR CLANG_DEFAULT_UNWINDLIB STREQUAL "libunwind")) message(WARNING "Resetting default unwindlib to use platform default") set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING -"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty for none)" FORCE) +"Default unwind library to use (\"none\" \"libgcc\" or \"libunwind\", empty to match runtime library.)" FORCE) endif() set(CLANG_DEFAULT_OBJCOPY "objcopy" CACHE STRING ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] 39ad160 - [libunwind] Install the DLL when doing "ninja install"
Author: Martin Storsjö Date: 2021-03-07T10:36:22+02:00 New Revision: 39ad160468e2b6acaa0b2b1ab353079eca4a3b03 URL: https://github.com/llvm/llvm-project/commit/39ad160468e2b6acaa0b2b1ab353079eca4a3b03 DIFF: https://github.com/llvm/llvm-project/commit/39ad160468e2b6acaa0b2b1ab353079eca4a3b03.diff LOG: [libunwind] Install the DLL when doing "ninja install" This matches how install(... RUNTIME) is used in e.g. libcxx. Differential Revision: https://reviews.llvm.org/D98020 Added: Modified: libunwind/src/CMakeLists.txt Removed: diff --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt index f59dfdde9f03..f341b21e6016 100644 --- a/libunwind/src/CMakeLists.txt +++ b/libunwind/src/CMakeLists.txt @@ -183,7 +183,8 @@ add_custom_target(unwind DEPENDS ${LIBUNWIND_BUILD_TARGETS}) if (LIBUNWIND_INSTALL_LIBRARY) install(TARGETS ${LIBUNWIND_INSTALL_TARGETS} LIBRARY DESTINATION ${LIBUNWIND_INSTALL_PREFIX}${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind -ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind) +ARCHIVE DESTINATION ${LIBUNWIND_INSTALL_PREFIX}${LIBUNWIND_INSTALL_LIBRARY_DIR} COMPONENT unwind +RUNTIME DESTINATION ${LIBUNWIND_INSTALL_PREFIX}bin COMPONENT unwind) endif() if (NOT CMAKE_CONFIGURATION_TYPES AND LIBUNWIND_INSTALL_LIBRARY) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ebe6d3b - [clang] Don't default to a specifically shared libunwind on mingw with a g++ driver
Author: Martin Storsjö Date: 2021-03-06T08:50:46+02:00 New Revision: ebe6d3be0f73c15e64b1ebafd2a4b9fa836be78c URL: https://github.com/llvm/llvm-project/commit/ebe6d3be0f73c15e64b1ebafd2a4b9fa836be78c DIFF: https://github.com/llvm/llvm-project/commit/ebe6d3be0f73c15e64b1ebafd2a4b9fa836be78c.diff LOG: [clang] Don't default to a specifically shared libunwind on mingw with a g++ driver For MinGW targets, we distinguish between an explicitly shared unwinder library (requested via -shared-libgcc), an explicitly static one (requested via -static-libgcc or -static) and the default case (which just passes -lunwind to the linker, which will pick either shared or static depending on what's available, with the normal linker logic). This makes the implicit default case (as added in D79995) actually work as it was intended, when using the g++ driver (which is the main usecase for libunwind as far as I know). Differential Revision: https://reviews.llvm.org/D98023 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/compiler-rt-unwind.c Removed: diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 46a0fc67ced0..5afb213a178b 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1382,7 +1382,9 @@ static LibGccType getLibGccType(const ToolChain &TC, const Driver &D, // The Android NDK only provides libunwind.a, not libunwind.so. if (TC.getTriple().isAndroid()) return LibGccType::StaticLibGcc; - if (D.CCCIsCXX()) + // For MinGW, don't imply a shared libgcc here, we only want to return + // SharedLibGcc if that was explicitly requested. + if (D.CCCIsCXX() && !TC.getTriple().isOSCygMing()) return LibGccType::SharedLibGcc; return LibGccType::UnspecifiedLibGcc; } diff --git a/clang/test/Driver/compiler-rt-unwind.c b/clang/test/Driver/compiler-rt-unwind.c index e21916d41f93..86c2c9b982c3 100644 --- a/clang/test/Driver/compiler-rt-unwind.c +++ b/clang/test/Driver/compiler-rt-unwind.c @@ -69,5 +69,9 @@ // RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \ // RUN: --gcc-toolchain="" \ // RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s +// RUN: %clangxx -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \ +// RUN: --gcc-toolchain="" \ +// RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s // MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a" // MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 002dd47 - [clang] Fix typos in the default logic for CLANG_DEFAULT_UNWINDLIB
Author: Martin Storsjö Date: 2021-03-06T08:50:46+02:00 New Revision: 002dd47bdd674fad8186650f07458b1e062545df URL: https://github.com/llvm/llvm-project/commit/002dd47bdd674fad8186650f07458b1e062545df DIFF: https://github.com/llvm/llvm-project/commit/002dd47bdd674fad8186650f07458b1e062545df.diff LOG: [clang] Fix typos in the default logic for CLANG_DEFAULT_UNWINDLIB CLANG_DEFAULT_RTLIB had a typo, and libunwind isn't a valid option for it. This keeps the actual behaviour from before, defaulting to none if using compiler-rt as rtlib. Differential Revision: https://reviews.llvm.org/D98022 Added: Modified: clang/CMakeLists.txt Removed: diff --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt index 7e1e58fdc138..f0fa61a0c3f7 100644 --- a/clang/CMakeLists.txt +++ b/clang/CMakeLists.txt @@ -262,7 +262,7 @@ set(CLANG_DEFAULT_UNWINDLIB "" CACHE STRING if (CLANG_DEFAULT_UNWINDLIB STREQUAL "") if (CLANG_DEFAULT_RTLIB STREQUAL "libgcc") set (CLANG_DEFAULT_UNWINDLIB "libgcc" CACHE STRING "" FORCE) - elseif (CLANG_DEFAULT_RTLIBS STREQUAL "libunwind") + elseif (CLANG_DEFAULT_RTLIB STREQUAL "compiler-rt") set (CLANG_DEFAULT_UNWINDLIB "none" CACHE STRING "" FORCE) endif() endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0c8b26b - [clang] Remove a superfluous semicolon, silencing GCC warnings. NFC.
Author: Martin Storsjö Date: 2021-02-25T14:54:19+02:00 New Revision: 0c8b26bf530b3fc65af9205c593583f26549da3e URL: https://github.com/llvm/llvm-project/commit/0c8b26bf530b3fc65af9205c593583f26549da3e DIFF: https://github.com/llvm/llvm-project/commit/0c8b26bf530b3fc65af9205c593583f26549da3e.diff LOG: [clang] Remove a superfluous semicolon, silencing GCC warnings. NFC. Added: Modified: clang/lib/Frontend/CompilerInvocation.cpp Removed: diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index f53cc8bff28c..eb447541124a 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -1147,7 +1147,7 @@ GenerateOptimizationRemark(SmallVectorImpl &Args, } else if (Remark.Kind == CodeGenOptions::RK_Disabled) { GenerateArg(Args, OPT_R_Joined, StringRef("no-") + Name, SA); } -}; +} /// Parse a remark command line argument. It may be missing, disabled/enabled by /// '-R[no-]group' or specified with a regular expression by '-Rgroup=regexp'. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] c17fdca - [clang] [Headers] Use the corresponding _aligned_free or __mingw_aligned_free in _mm_free
Author: Martin Storsjö Date: 2020-12-04T11:34:12+02:00 New Revision: c17fdca1883ddee94c6b7e055428d4445ab13e42 URL: https://github.com/llvm/llvm-project/commit/c17fdca1883ddee94c6b7e055428d4445ab13e42 DIFF: https://github.com/llvm/llvm-project/commit/c17fdca1883ddee94c6b7e055428d4445ab13e42.diff LOG: [clang] [Headers] Use the corresponding _aligned_free or __mingw_aligned_free in _mm_free Differential Revision: https://reviews.llvm.org/D92570 Added: Modified: clang/lib/Headers/mm_malloc.h Removed: diff --git a/clang/lib/Headers/mm_malloc.h b/clang/lib/Headers/mm_malloc.h index 0ea32517aea8..933dbaacade5 100644 --- a/clang/lib/Headers/mm_malloc.h +++ b/clang/lib/Headers/mm_malloc.h @@ -54,7 +54,13 @@ _mm_malloc(size_t __size, size_t __align) static __inline__ void __attribute__((__always_inline__, __nodebug__)) _mm_free(void *__p) { +#if defined(__MINGW32__) + __mingw_aligned_free(__p); +#elif defined(_WIN32) + _aligned_free(__p); +#else free(__p); +#endif } #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] d3bd06f - [clang] Fix the fsanitize.c testcase after eaae6fdf67e1f. NFC.
Author: Martin Storsjö Date: 2020-11-03T10:21:29+02:00 New Revision: d3bd06f5c709fe073739a06e0d5a22020f0bf90c URL: https://github.com/llvm/llvm-project/commit/d3bd06f5c709fe073739a06e0d5a22020f0bf90c DIFF: https://github.com/llvm/llvm-project/commit/d3bd06f5c709fe073739a06e0d5a22020f0bf90c.diff LOG: [clang] Fix the fsanitize.c testcase after eaae6fdf67e1f. NFC. After that commit, the vptr sanitizer is enabled for mingw targets. Added: Modified: clang/test/Driver/fsanitize.c Removed: diff --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c index 0ecf656f292c..8926d55a0cf4 100644 --- a/clang/test/Driver/fsanitize.c +++ b/clang/test/Driver/fsanitize.c @@ -15,16 +15,17 @@ // RUN: %clang -target x86_64-apple-darwin10 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-DARWIN // CHECK-UNDEFINED-DARWIN: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|function|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){18}"}} -// RUN: %clang -target i386-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32 -// RUN: %clang -target i386-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-WIN-CXX -// RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64 +// RUN: %clang -target i386-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-MSVC +// RUN: %clang -target i386-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN32 --check-prefix=CHECK-UNDEFINED-WIN-CXX --check-prefix=CHECK-UNDEFINED-MSVC +// RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64 --check-prefix=CHECK-UNDEFINED-MSVC // RUN: %clang -target x86_64-w64-mingw32 -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64-MINGW -// RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64 --check-prefix=CHECK-UNDEFINED-WIN-CXX +// RUN: %clang -target x86_64-pc-win32 -fsanitize=undefined -x c++ %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-UNDEFINED-WIN --check-prefix=CHECK-UNDEFINED-WIN64 --check-prefix=CHECK-UNDEFINED-WIN-CXX --check-prefix=CHECK-UNDEFINED-MSVC // CHECK-UNDEFINED-WIN32: "--dependent-lib={{[^"]*}}ubsan_standalone-i386.lib" // CHECK-UNDEFINED-WIN64: "--dependent-lib={{[^"]*}}ubsan_standalone-x86_64.lib" // CHECK-UNDEFINED-WIN64-MINGW: "--dependent-lib={{[^"]*}}libclang_rt.ubsan_standalone-x86_64.a" // CHECK-UNDEFINED-WIN-CXX: "--dependent-lib={{[^"]*}}ubsan_standalone_cxx{{[^"]*}}.lib" -// CHECK-UNDEFINED-WIN-SAME: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){17}"}} +// CHECK-UNDEFINED-MSVC-SAME: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute),?){17}"}} +// CHECK-UNDEFINED-WIN64-MINGW-SAME: "-fsanitize={{((signed-integer-overflow|integer-divide-by-zero|shift-base|shift-exponent|unreachable|return|vla-bound|alignment|null|pointer-overflow|float-cast-overflow|array-bounds|enum|bool|builtin|returns-nonnull-attribute|nonnull-attribute|vptr),?){18}"}} // RUN: %clang -target i386-pc-win32 -fsanitize-coverage=bb %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-COVERAGE-WIN32 // CHECK-COVERAGE-WIN32: "--dependent-lib={{[^"]*}}ubsan_standalone-i386.lib" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] eaae6fd - [clang] [MinGW] Allow using the vptr sanitizer
Author: Martin Storsjö Date: 2020-11-03T09:59:09+02:00 New Revision: eaae6fdf67e1f61599331d69a41a7dafe6199667 URL: https://github.com/llvm/llvm-project/commit/eaae6fdf67e1f61599331d69a41a7dafe6199667 DIFF: https://github.com/llvm/llvm-project/commit/eaae6fdf67e1f61599331d69a41a7dafe6199667.diff LOG: [clang] [MinGW] Allow using the vptr sanitizer Differential Revision: https://reviews.llvm.org/D90572 Added: Modified: clang/lib/Driver/ToolChains/MinGW.cpp clang/test/Driver/mingw-sanitizers.c Removed: diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index 49fef4298bfe..f6cead412236 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -491,6 +491,7 @@ SanitizerMask toolchains::MinGW::getSupportedSanitizers() const { Res |= SanitizerKind::Address; Res |= SanitizerKind::PointerCompare; Res |= SanitizerKind::PointerSubtract; + Res |= SanitizerKind::Vptr; return Res; } diff --git a/clang/test/Driver/mingw-sanitizers.c b/clang/test/Driver/mingw-sanitizers.c index 09f28fea8abf..701e9107f485 100644 --- a/clang/test/Driver/mingw-sanitizers.c +++ b/clang/test/Driver/mingw-sanitizers.c @@ -9,3 +9,5 @@ // ASAN-X86_64: "{{[^"]*}}libclang_rt.asan_dynamic_runtime_thunk-x86_64.a" // ASAN-X86_64: "--require-defined" "__asan_seh_interceptor" // ASAN-X86_64: "--whole-archive" "{{.*}}libclang_rt.asan_dynamic_runtime_thunk-x86_64.a" "--no-whole-archive" + +// RUN: %clang -target x86_64-windows-gnu %s -### -fsanitize=vptr ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] df6d2e8 - [libunwind] Add -Wno-dll-attribute-on-redeclaration when building for windows
Author: Martin Storsjö Date: 2020-10-26T23:23:01+02:00 New Revision: df6d2e8ab1a4212284e4763724a2211df2c7394a URL: https://github.com/llvm/llvm-project/commit/df6d2e8ab1a4212284e4763724a2211df2c7394a DIFF: https://github.com/llvm/llvm-project/commit/df6d2e8ab1a4212284e4763724a2211df2c7394a.diff LOG: [libunwind] Add -Wno-dll-attribute-on-redeclaration when building for windows It's not worth trying to fix these warnings within libunwind, instead silence them. Differential Revision: https://reviews.llvm.org/D90075 Added: Modified: libunwind/CMakeLists.txt Removed: diff --git a/libunwind/CMakeLists.txt b/libunwind/CMakeLists.txt index 1c053e6e8b2a..d7e13b78a9c9 100644 --- a/libunwind/CMakeLists.txt +++ b/libunwind/CMakeLists.txt @@ -203,6 +203,14 @@ add_compile_flags_if_supported(-Wundef) add_compile_flags_if_supported(-Wno-suggest-override) +if (WIN32) + # The headers lack matching dllexport attributes (_LIBUNWIND_EXPORT); + # silence the warning instead of cluttering the headers (which aren't + # necessarily the ones that the callers will use anyway) with the + # attributes. + add_compile_flags_if_supported(-Wno-dll-attribute-on-redeclaration) +endif() + if (LIBUNWIND_ENABLE_WERROR) add_compile_flags_if_supported(-Werror) add_compile_flags_if_supported(-WX) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 5eece13 - [clang] Automatically link against oldnames just as linking against libcmt
Author: Martin Storsjö Date: 2020-10-20T00:07:00+03:00 New Revision: 5eece137bc76f349cefc8922447694bea29ae101 URL: https://github.com/llvm/llvm-project/commit/5eece137bc76f349cefc8922447694bea29ae101 DIFF: https://github.com/llvm/llvm-project/commit/5eece137bc76f349cefc8922447694bea29ae101.diff LOG: [clang] Automatically link against oldnames just as linking against libcmt Differential Revision: https://reviews.llvm.org/D89702 Added: Modified: clang/lib/Driver/ToolChains/MSVC.cpp clang/test/Driver/msvc-link.c Removed: diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp index ba2c7146b924..1e04cc9f6271 100644 --- a/clang/lib/Driver/ToolChains/MSVC.cpp +++ b/clang/lib/Driver/ToolChains/MSVC.cpp @@ -333,8 +333,10 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA, Args.MakeArgString(std::string("-out:") + Output.getFilename())); if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) && - !C.getDriver().IsCLMode()) + !C.getDriver().IsCLMode()) { CmdArgs.push_back("-defaultlib:libcmt"); +CmdArgs.push_back("-defaultlib:oldnames"); + } if (!llvm::sys::Process::GetEnv("LIB")) { // If the VC environment hasn't been configured (perhaps because the user diff --git a/clang/test/Driver/msvc-link.c b/clang/test/Driver/msvc-link.c index e3829e6651e3..13dccd21bfd8 100644 --- a/clang/test/Driver/msvc-link.c +++ b/clang/test/Driver/msvc-link.c @@ -2,6 +2,7 @@ // BASIC: link.exe" // BASIC: "-out:a.exe" // BASIC: "-defaultlib:libcmt" +// BASIC: "-defaultlib:oldnames" // BASIC: "-nologo" // BASIC-NOT: "-Brepro" @@ -9,6 +10,7 @@ // DLL: link.exe" // DLL: "-out:a.dll" // DLL: "-defaultlib:libcmt" +// DLL: "-defaultlib:oldnames" // DLL: "-nologo" // DLL: "-dll" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3b1d018 - [MinGW][clang-shlib] Build only when LLVM_LINK_LLVM_DYLIB is enabled
Author: Mateusz Mikuła Date: 2020-10-12T23:28:23+03:00 New Revision: 3b1d018c0dba45408164f5e69cb400976efa350f URL: https://github.com/llvm/llvm-project/commit/3b1d018c0dba45408164f5e69cb400976efa350f DIFF: https://github.com/llvm/llvm-project/commit/3b1d018c0dba45408164f5e69cb400976efa350f.diff LOG: [MinGW][clang-shlib] Build only when LLVM_LINK_LLVM_DYLIB is enabled Otherwise it's easy to hit 2^16 DLL exports limit. Differential Revision: https://reviews.llvm.org/D89225 Added: Modified: clang/tools/CMakeLists.txt Removed: diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt index 85a85812a8d4..84e3fb156f1a 100644 --- a/clang/tools/CMakeLists.txt +++ b/clang/tools/CMakeLists.txt @@ -15,7 +15,9 @@ add_clang_subdirectory(c-index-test) add_clang_subdirectory(clang-rename) add_clang_subdirectory(clang-refactor) -if(UNIX OR MINGW) +# For MinGW we only enable shared library if LLVM_LINK_LLVM_DYLIB=ON. +# Without that option resulting library is too close to 2^16 DLL exports limit. +if(UNIX OR (MINGW AND LLVM_LINK_LLVM_DYLIB)) add_clang_subdirectory(clang-shlib) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] fc5e68f - [libunwind] [SEH] Don't interact with foreign exceptions
Author: Martin Storsjö Date: 2020-10-12T23:28:22+03:00 New Revision: fc5e68fab965bdc8fdf6db9ae2603f9dd02dec5b URL: https://github.com/llvm/llvm-project/commit/fc5e68fab965bdc8fdf6db9ae2603f9dd02dec5b DIFF: https://github.com/llvm/llvm-project/commit/fc5e68fab965bdc8fdf6db9ae2603f9dd02dec5b.diff LOG: [libunwind] [SEH] Don't interact with foreign exceptions This unfortunately means that we don't execute C++ destructors when unwinding past such frames for a different SEH unwind purpose (e.g. as part of setjmp/longjmp), but that case isn't handled properly at the moment (the original unwind intent is lost and we end up with an unhandled exception). This patch makes sure the foreign unwind terminates as intended. After executing a handler, _Unwind_Resume doesn't have access to the target frame parameter of the original foreign unwind. We also currently blindly set ExceptionCode to STATUS_GCC_THROW - we could set that correctly by storing the original code in _GCC_specific_handler, but we don't have access to the original target frame value. This also matches what libgcc's SEH unwinding code does in this case. Differential Revision: https://reviews.llvm.org/D89231 Added: Modified: libunwind/src/Unwind-seh.cpp Removed: diff --git a/libunwind/src/Unwind-seh.cpp b/libunwind/src/Unwind-seh.cpp index 403ab2d77110..6e2b4e73e41e 100644 --- a/libunwind/src/Unwind-seh.cpp +++ b/libunwind/src/Unwind-seh.cpp @@ -46,18 +46,6 @@ using namespace libunwind; /// handling. #define STATUS_GCC_UNWIND MAKE_GCC_EXCEPTION(1) // 0x21474343 -/// Class of foreign exceptions based on unrecognized SEH exceptions. -static const uint64_t kSEHExceptionClass = 0x434C4E4753454800; // CLNGSEH\0 - -/// Exception cleanup routine used by \c _GCC_specific_handler to -/// free foreign exceptions. -static void seh_exc_cleanup(_Unwind_Reason_Code urc, _Unwind_Exception *exc) { - (void)urc; - if (exc->exception_class != kSEHExceptionClass) -_LIBUNWIND_ABORT("SEH cleanup called on non-SEH exception"); - free(exc); -} - static int __unw_init_seh(unw_cursor_t *cursor, CONTEXT *ctx); static DISPATCHER_CONTEXT *__unw_seh_get_disp_ctx(unw_cursor_t *cursor); static void __unw_seh_set_disp_ctx(unw_cursor_t *cursor, @@ -108,10 +96,10 @@ _GCC_specific_handler(PEXCEPTION_RECORD ms_exc, PVOID frame, PCONTEXT ms_ctx, } } else { // Foreign exception. -exc = (_Unwind_Exception *)malloc(sizeof(_Unwind_Exception)); -exc->exception_class = kSEHExceptionClass; -exc->exception_cleanup = seh_exc_cleanup; -memset(exc->private_, 0, sizeof(exc->private_)); +// We can't interact with them (we don't know the original target frame +// that we should pass on to RtlUnwindEx in _Unwind_Resume), so just +// pass without calling our destructors here. +return ExceptionContinueSearch; } if (!ctx) { __unw_init_seh(&cursor, disp->ContextRecord); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 3fec6dd - Reapply: [clang-cl] Always interpret the LIB env var as separated with semicolons
Author: Martin Storsjö Date: 2020-09-22T10:51:25+03:00 New Revision: 3fec6ddc276a595e4409f04dabdd50c84f5f2a2d URL: https://github.com/llvm/llvm-project/commit/3fec6ddc276a595e4409f04dabdd50c84f5f2a2d DIFF: https://github.com/llvm/llvm-project/commit/3fec6ddc276a595e4409f04dabdd50c84f5f2a2d.diff LOG: Reapply: [clang-cl] Always interpret the LIB env var as separated with semicolons When cross compiling with clang-cl, clang splits the INCLUDE env variable around semicolons (clang/lib/Driver/ToolChains/MSVC.cpp, MSVCToolChain::AddClangSystemIncludeArgs) and lld splits the LIB variable similarly (lld/COFF/Driver.cpp, LinkerDriver::addLibSearchPaths). Therefore, the consensus for cross compilation with clang-cl and lld-link seems to be to use semicolons, despite path lists normally being separated by colons on unix and EnvPathSeparator being set to that. Therefore, handle the LIB variable similarly in Clang, when handling lib file arguments when driving linking via Clang. This fixes commands like "clang-cl test.c -Fetest.exe kernel32.lib" in a cross compilation setting. Normally, most users call (lld-)link directly, but meson happens to use this command syntax for has_function() tests. Reapply: Change Program.h to define procid_t as ::pid_t. When included in lldb/unittests/Host/NativeProcessProtocolTest.cpp, it is included after an lldb namespace containing an lldb::pid_t typedef, followed later by a "using namespace lldb;". Previously, Program.h wasn't included in this translation unit, but now it ends up included transitively from Process.h. Differential Revision: https://reviews.llvm.org/D88002 Added: Modified: clang/lib/Driver/Driver.cpp clang/test/Driver/cl-inputs.c llvm/include/llvm/Support/Process.h llvm/include/llvm/Support/Program.h llvm/lib/Support/Process.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 65b44597bc16..69336f6f94b6 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2085,7 +2085,7 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value, if (IsCLMode()) { if (!llvm::sys::path::is_absolute(Twine(Value)) && -llvm::sys::Process::FindInEnvPath("LIB", Value)) +llvm::sys::Process::FindInEnvPath("LIB", Value, ';')) return true; if (Args.hasArg(options::OPT__SLASH_link) && Ty == types::TY_Object) { diff --git a/clang/test/Driver/cl-inputs.c b/clang/test/Driver/cl-inputs.c index c67fc24484ee..59455a0aa5e5 100644 --- a/clang/test/Driver/cl-inputs.c +++ b/clang/test/Driver/cl-inputs.c @@ -32,7 +32,9 @@ // WARN-NOT: note // MSYS2_ARG_CONV_EXCL tells MSYS2 to skip conversion of the specified argument. -// RUN: env LIB=%S/Inputs/cl-libs MSYS2_ARG_CONV_EXCL="/TP;/c" %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s +// Add a dummy "other" entry to the path as well, to check that it's split +// around semicolons even on unix. +// RUN: env LIB="other;%S/Inputs/cl-libs" MSYS2_ARG_CONV_EXCL="/TP;/c" %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s // TPlib: warning: cl-test.lib: 'linker' input unused // TPlib: warning: argument unused during compilation: '/TP' // TPlib-NOT: cl-test.lib diff --git a/llvm/include/llvm/Support/Process.h b/llvm/include/llvm/Support/Process.h index 0ba6d58ba287..af5091ab8ff4 100644 --- a/llvm/include/llvm/Support/Process.h +++ b/llvm/include/llvm/Support/Process.h @@ -29,6 +29,7 @@ #include "llvm/Support/Chrono.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" +#include "llvm/Support/Program.h" #include namespace llvm { @@ -107,10 +108,12 @@ class Process { /// considered. static Optional FindInEnvPath(StringRef EnvName, StringRef FileName, - ArrayRef IgnoreList); + ArrayRef IgnoreList, + char Separator = EnvPathSeparator); static Optional FindInEnvPath(StringRef EnvName, - StringRef FileName); + StringRef FileName, + char Separator = EnvPathSeparator); // This functions ensures that the standard file descriptors (input, output, // and error) are properly mapped to a file descriptor before we use any of diff --git a/llvm/include/llvm/Support/Program.h b/llvm/include/llvm/Support/Program.h index d729d3883650..b32de47adb57 100644 --- a/llvm/include/llvm/Support/Program.h +++ b/llvm/include/llvm/Support/Program.h @@ -36,7 +36,7 @@ namespace sys { typedef unsigned long procid_t; // Must match the type of DWORD on Windows. typedef void *process_t;// Must match the type of HANDLE on Window
[clang] 8c3ef08 - Revert "[clang-cl] Always interpret the LIB env var as separated with semicolons"
Author: Martin Storsjö Date: 2020-09-22T00:14:45+03:00 New Revision: 8c3ef08f8a4eb40609af55d541e5135856fde086 URL: https://github.com/llvm/llvm-project/commit/8c3ef08f8a4eb40609af55d541e5135856fde086 DIFF: https://github.com/llvm/llvm-project/commit/8c3ef08f8a4eb40609af55d541e5135856fde086.diff LOG: Revert "[clang-cl] Always interpret the LIB env var as separated with semicolons" This reverts commit 4d85444b317a00a3e15da63cdb693d272c99a0cc. This commit broke building lldb's NativeProcessProtocolTest.cpp, with errors like these: In file included from include/llvm/Support/Process.h:32:0, from tools/lldb/unittests/Host/NativeProcessProtocolTest.cpp:12: include/llvm/Support/Program.h:39:11: error: reference to ‘pid_t’ is ambiguous typedef pid_t procid_t; /usr/include/sched.h:38:17: note: candidates are: typedef __pid_t pid_t typedef __pid_t pid_t; tools/lldb/include/lldb/lldb-types.h:85:18: note: typedef uint64_t lldb::pid_t typedef uint64_t pid_t; Added: Modified: clang/lib/Driver/Driver.cpp clang/test/Driver/cl-inputs.c llvm/include/llvm/Support/Process.h llvm/lib/Support/Process.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 69336f6f94b6..65b44597bc16 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2085,7 +2085,7 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value, if (IsCLMode()) { if (!llvm::sys::path::is_absolute(Twine(Value)) && -llvm::sys::Process::FindInEnvPath("LIB", Value, ';')) +llvm::sys::Process::FindInEnvPath("LIB", Value)) return true; if (Args.hasArg(options::OPT__SLASH_link) && Ty == types::TY_Object) { diff --git a/clang/test/Driver/cl-inputs.c b/clang/test/Driver/cl-inputs.c index 59455a0aa5e5..c67fc24484ee 100644 --- a/clang/test/Driver/cl-inputs.c +++ b/clang/test/Driver/cl-inputs.c @@ -32,9 +32,7 @@ // WARN-NOT: note // MSYS2_ARG_CONV_EXCL tells MSYS2 to skip conversion of the specified argument. -// Add a dummy "other" entry to the path as well, to check that it's split -// around semicolons even on unix. -// RUN: env LIB="other;%S/Inputs/cl-libs" MSYS2_ARG_CONV_EXCL="/TP;/c" %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s +// RUN: env LIB=%S/Inputs/cl-libs MSYS2_ARG_CONV_EXCL="/TP;/c" %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s // TPlib: warning: cl-test.lib: 'linker' input unused // TPlib: warning: argument unused during compilation: '/TP' // TPlib-NOT: cl-test.lib diff --git a/llvm/include/llvm/Support/Process.h b/llvm/include/llvm/Support/Process.h index af5091ab8ff4..0ba6d58ba287 100644 --- a/llvm/include/llvm/Support/Process.h +++ b/llvm/include/llvm/Support/Process.h @@ -29,7 +29,6 @@ #include "llvm/Support/Chrono.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" -#include "llvm/Support/Program.h" #include namespace llvm { @@ -108,12 +107,10 @@ class Process { /// considered. static Optional FindInEnvPath(StringRef EnvName, StringRef FileName, - ArrayRef IgnoreList, - char Separator = EnvPathSeparator); + ArrayRef IgnoreList); static Optional FindInEnvPath(StringRef EnvName, - StringRef FileName, - char Separator = EnvPathSeparator); + StringRef FileName); // This functions ensures that the standard file descriptors (input, output, // and error) are properly mapped to a file descriptor before we use any of diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp index 9f0b689ce6c8..9e6e233b26ac 100644 --- a/llvm/lib/Support/Process.cpp +++ b/llvm/lib/Support/Process.cpp @@ -28,22 +28,21 @@ using namespace sys; //=== independent code. //===--===// -Optional -Process::FindInEnvPath(StringRef EnvName, StringRef FileName, char Separator) { - return FindInEnvPath(EnvName, FileName, {}, Separator); +Optional Process::FindInEnvPath(StringRef EnvName, + StringRef FileName) { + return FindInEnvPath(EnvName, FileName, {}); } Optional Process::FindInEnvPath(StringRef EnvName, StringRef FileName, - ArrayRef IgnoreList, - char Separator) { + ArrayRef IgnoreList) { assert(!path::is_absolute(FileName)); Optional FoundPath; Optional OptPath = Process:
[clang] ead7c3c - [clang] [MinGW] Add an implicit .exe suffix even when crosscompiling
Author: Martin Storsjö Date: 2020-09-21T23:42:59+03:00 New Revision: ead7c3cdc34c63d8df78d8e333b7cc64d03236ea URL: https://github.com/llvm/llvm-project/commit/ead7c3cdc34c63d8df78d8e333b7cc64d03236ea DIFF: https://github.com/llvm/llvm-project/commit/ead7c3cdc34c63d8df78d8e333b7cc64d03236ea.diff LOG: [clang] [MinGW] Add an implicit .exe suffix even when crosscompiling GCC 8 changed behaviour wrt this, and made it consistent for cross compilation cases. While it's a change, it's a more sensible behaviour going forward. Differential Revision: https://reviews.llvm.org/D88005 Added: Modified: clang/lib/Driver/ToolChains/MinGW.cpp clang/test/Driver/mingw-implicit-extension-windows.c Removed: clang/test/Driver/mingw-implicit-extension-cross.c diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index a1a1b413fb6c..ea9d29a1f831 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -164,17 +164,13 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-o"); const char *OutputFile = Output.getFilename(); // GCC implicitly adds an .exe extension if it is given an output file name - // that lacks an extension. However, GCC only does this when actually - // running on windows, not when operating as a cross compiler. As some users - // have come to rely on this behaviour, try to replicate it. -#ifdef _WIN32 + // that lacks an extension. + // GCC used to do this only when the compiler itself runs on windows, but + // since GCC 8 it does the same when cross compiling as well. if (!llvm::sys::path::has_extension(OutputFile)) CmdArgs.push_back(Args.MakeArgString(Twine(OutputFile) + ".exe")); else CmdArgs.push_back(OutputFile); -#else - CmdArgs.push_back(OutputFile); -#endif Args.AddAllArgs(CmdArgs, options::OPT_e); // FIXME: add -N, -n flags diff --git a/clang/test/Driver/mingw-implicit-extension-cross.c b/clang/test/Driver/mingw-implicit-extension-cross.c deleted file mode 100644 index 2cf24dcb8a57.. --- a/clang/test/Driver/mingw-implicit-extension-cross.c +++ /dev/null @@ -1,9 +0,0 @@ -// Test how an implicit .exe extension is added. If not running the compiler -// on windows, no implicit extension is added. (Therefore, this test is skipped -// when running on windows.) - -// UNSUPPORTED: system-windows - -// RUN: %clang -target i686-windows-gnu -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -o outputname 2>&1 | FileCheck %s - -// CHECK: "-o" "outputname" diff --git a/clang/test/Driver/mingw-implicit-extension-windows.c b/clang/test/Driver/mingw-implicit-extension-windows.c index 9c60308b142e..bc15f6abb266 100644 --- a/clang/test/Driver/mingw-implicit-extension-windows.c +++ b/clang/test/Driver/mingw-implicit-extension-windows.c @@ -1,8 +1,4 @@ -// Test how an implicit .exe extension is added. If running the compiler -// on windows, an implicit extension is added if none is provided in the -// given name. (Therefore, this test is skipped when not running on windows.) - -// REQUIRES: system-windows +// Test how an implicit .exe extension is added. // RUN: %clang -target i686-windows-gnu -### --sysroot=%S/Inputs/mingw_clang_tree/mingw32 %s -o outputname 2>&1 | FileCheck %s --check-prefix=CHECK-OUTPUTNAME-EXE ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 4d85444 - [clang-cl] Always interpret the LIB env var as separated with semicolons
Author: Martin Storsjö Date: 2020-09-21T23:42:59+03:00 New Revision: 4d85444b317a00a3e15da63cdb693d272c99a0cc URL: https://github.com/llvm/llvm-project/commit/4d85444b317a00a3e15da63cdb693d272c99a0cc DIFF: https://github.com/llvm/llvm-project/commit/4d85444b317a00a3e15da63cdb693d272c99a0cc.diff LOG: [clang-cl] Always interpret the LIB env var as separated with semicolons When cross compiling with clang-cl, clang splits the INCLUDE env variable around semicolons (clang/lib/Driver/ToolChains/MSVC.cpp, MSVCToolChain::AddClangSystemIncludeArgs) and lld splits the LIB variable similarly (lld/COFF/Driver.cpp, LinkerDriver::addLibSearchPaths). Therefore, the consensus for cross compilation with clang-cl and lld-link seems to be to use semicolons, despite path lists normally being separated by colons on unix and EnvPathSeparator being set to that. Therefore, handle the LIB variable similarly in Clang, when handling lib file arguments when driving linking via Clang. This fixes commands like "clang-cl test.c -Fetest.exe kernel32.lib" in a cross compilation setting. Normally, most users call (lld-)link directly, but meson happens to use this command syntax for has_function() tests. Differential Revision: https://reviews.llvm.org/D88002 Added: Modified: clang/lib/Driver/Driver.cpp clang/test/Driver/cl-inputs.c llvm/include/llvm/Support/Process.h llvm/lib/Support/Process.cpp Removed: diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 65b44597bc16..69336f6f94b6 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -2085,7 +2085,7 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value, if (IsCLMode()) { if (!llvm::sys::path::is_absolute(Twine(Value)) && -llvm::sys::Process::FindInEnvPath("LIB", Value)) +llvm::sys::Process::FindInEnvPath("LIB", Value, ';')) return true; if (Args.hasArg(options::OPT__SLASH_link) && Ty == types::TY_Object) { diff --git a/clang/test/Driver/cl-inputs.c b/clang/test/Driver/cl-inputs.c index c67fc24484ee..59455a0aa5e5 100644 --- a/clang/test/Driver/cl-inputs.c +++ b/clang/test/Driver/cl-inputs.c @@ -32,7 +32,9 @@ // WARN-NOT: note // MSYS2_ARG_CONV_EXCL tells MSYS2 to skip conversion of the specified argument. -// RUN: env LIB=%S/Inputs/cl-libs MSYS2_ARG_CONV_EXCL="/TP;/c" %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s +// Add a dummy "other" entry to the path as well, to check that it's split +// around semicolons even on unix. +// RUN: env LIB="other;%S/Inputs/cl-libs" MSYS2_ARG_CONV_EXCL="/TP;/c" %clang_cl /c /TP cl-test.lib -### 2>&1 | FileCheck -check-prefix=TPlib %s // TPlib: warning: cl-test.lib: 'linker' input unused // TPlib: warning: argument unused during compilation: '/TP' // TPlib-NOT: cl-test.lib diff --git a/llvm/include/llvm/Support/Process.h b/llvm/include/llvm/Support/Process.h index 0ba6d58ba287..af5091ab8ff4 100644 --- a/llvm/include/llvm/Support/Process.h +++ b/llvm/include/llvm/Support/Process.h @@ -29,6 +29,7 @@ #include "llvm/Support/Chrono.h" #include "llvm/Support/DataTypes.h" #include "llvm/Support/Error.h" +#include "llvm/Support/Program.h" #include namespace llvm { @@ -107,10 +108,12 @@ class Process { /// considered. static Optional FindInEnvPath(StringRef EnvName, StringRef FileName, - ArrayRef IgnoreList); + ArrayRef IgnoreList, + char Separator = EnvPathSeparator); static Optional FindInEnvPath(StringRef EnvName, - StringRef FileName); + StringRef FileName, + char Separator = EnvPathSeparator); // This functions ensures that the standard file descriptors (input, output, // and error) are properly mapped to a file descriptor before we use any of diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp index 9e6e233b26ac..9f0b689ce6c8 100644 --- a/llvm/lib/Support/Process.cpp +++ b/llvm/lib/Support/Process.cpp @@ -28,21 +28,22 @@ using namespace sys; //=== independent code. //===--===// -Optional Process::FindInEnvPath(StringRef EnvName, - StringRef FileName) { - return FindInEnvPath(EnvName, FileName, {}); +Optional +Process::FindInEnvPath(StringRef EnvName, StringRef FileName, char Separator) { + return FindInEnvPath(EnvName, FileName, {}, Separator); } Optional Process::FindInEnvPath(StringRef EnvName, StringRef FileName, -
[clang] 7da9419 - [MinGW][libclang] Allow simultaneous shared and static lib
Author: Mateusz Mikuła Date: 2020-09-12T22:03:43+03:00 New Revision: 7da941939902768af25ffa45149695a0a5f15951 URL: https://github.com/llvm/llvm-project/commit/7da941939902768af25ffa45149695a0a5f15951 DIFF: https://github.com/llvm/llvm-project/commit/7da941939902768af25ffa45149695a0a5f15951.diff LOG: [MinGW][libclang] Allow simultaneous shared and static lib It builds fine for MinGW on Windows. Differential Revision: https://reviews.llvm.org/D87539 Added: Modified: clang/tools/libclang/CMakeLists.txt Removed: diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index 88279ff7dae6..15f7ff94dfea 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -97,7 +97,7 @@ if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) set(ENABLE_STATIC STATIC) endif() -if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC) +if (MSVC AND ENABLE_SHARED AND ENABLE_STATIC) unset(ENABLE_STATIC) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] bb61304 - [MinGW][clang-shlib] Build by default on MinGW
Author: Mateusz Mikuła Date: 2020-09-12T22:02:31+03:00 New Revision: bb613044b6800b8ccc238232677f905bda423819 URL: https://github.com/llvm/llvm-project/commit/bb613044b6800b8ccc238232677f905bda423819 DIFF: https://github.com/llvm/llvm-project/commit/bb613044b6800b8ccc238232677f905bda423819.diff LOG: [MinGW][clang-shlib] Build by default on MinGW It builds without errors and makes possible to use CLANG_LINK_CLANG_DYLIB=1. Differential Revision: https://reviews.llvm.org/D87547 Added: Modified: clang/tools/CMakeLists.txt Removed: diff --git a/clang/tools/CMakeLists.txt b/clang/tools/CMakeLists.txt index e46c3669a2c2..85a85812a8d4 100644 --- a/clang/tools/CMakeLists.txt +++ b/clang/tools/CMakeLists.txt @@ -15,7 +15,7 @@ add_clang_subdirectory(c-index-test) add_clang_subdirectory(clang-rename) add_clang_subdirectory(clang-refactor) -if(UNIX) +if(UNIX OR MINGW) add_clang_subdirectory(clang-shlib) endif() ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cc76965 - [MinGW] Use lib prefix for libraries
Author: Mateusz Mikuła Date: 2020-09-12T22:01:29+03:00 New Revision: cc76965b19085519278bff1052059e03769b71e8 URL: https://github.com/llvm/llvm-project/commit/cc76965b19085519278bff1052059e03769b71e8 DIFF: https://github.com/llvm/llvm-project/commit/cc76965b19085519278bff1052059e03769b71e8.diff LOG: [MinGW] Use lib prefix for libraries In MinGW world, UNIX like lib prefix is preferred for the libraries. This patch adjusts CMake files to do that. Differential Revision: https://reviews.llvm.org/D87517 Added: Modified: clang/tools/libclang/CMakeLists.txt lldb/source/API/CMakeLists.txt llvm/cmake/modules/AddLLVM.cmake llvm/tools/llvm-config/llvm-config.cpp Removed: diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index c3b9ab6ffb9b..88279ff7dae6 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -101,7 +101,7 @@ if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC) unset(ENABLE_STATIC) endif() -if(WIN32) +if(MSVC) set(output_name "libclang") else() set(output_name "clang") diff --git a/lldb/source/API/CMakeLists.txt b/lldb/source/API/CMakeLists.txt index 8a7f28c01a9c..aeb1f15e294b 100644 --- a/lldb/source/API/CMakeLists.txt +++ b/lldb/source/API/CMakeLists.txt @@ -182,10 +182,10 @@ if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows") set_target_properties(liblldb_exports PROPERTIES FOLDER "lldb misc") endif() -if ( CMAKE_SYSTEM_NAME MATCHES "Windows" ) +if (MSVC) # Only MSVC has the ABI compatibility problem and avoids using FindPythonLibs, # so only it needs to explicitly link against ${Python3_LIBRARIES} - if (MSVC AND LLDB_ENABLE_PYTHON) + if (LLDB_ENABLE_PYTHON) target_link_libraries(liblldb PRIVATE ${Python3_LIBRARIES}) endif() else() diff --git a/llvm/cmake/modules/AddLLVM.cmake b/llvm/cmake/modules/AddLLVM.cmake index a40cf17426fe..e57abea42753 100644 --- a/llvm/cmake/modules/AddLLVM.cmake +++ b/llvm/cmake/modules/AddLLVM.cmake @@ -567,7 +567,7 @@ function(llvm_add_library name) endif() if(ARG_SHARED) -if(WIN32) +if(MSVC) set_target_properties(${name} PROPERTIES PREFIX "" ) diff --git a/llvm/tools/llvm-config/llvm-config.cpp b/llvm/tools/llvm-config/llvm-config.cpp index a9d3f64aaa5b..1a2f04552d13 100644 --- a/llvm/tools/llvm-config/llvm-config.cpp +++ b/llvm/tools/llvm-config/llvm-config.cpp @@ -381,6 +381,7 @@ int main(int argc, char **argv) { SharedExt = "dll"; SharedVersionedExt = LLVM_DYLIB_VERSION ".dll"; if (HostTriple.isOSCygMing()) { + SharedPrefix = "lib"; StaticExt = "a"; StaticPrefix = "lib"; } else { ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 28b9ace - [clang] Remove a stray semicolon, fixing pedantic GCC warnings. NFC.
Author: Martin Storsjö Date: 2020-09-08T09:26:39+03:00 New Revision: 28b9ace85f6871cdb48f1483314d8342e099b136 URL: https://github.com/llvm/llvm-project/commit/28b9ace85f6871cdb48f1483314d8342e099b136 DIFF: https://github.com/llvm/llvm-project/commit/28b9ace85f6871cdb48f1483314d8342e099b136.diff LOG: [clang] Remove a stray semicolon, fixing pedantic GCC warnings. NFC. Added: Modified: clang/include/clang/AST/IgnoreExpr.h Removed: diff --git a/clang/include/clang/AST/IgnoreExpr.h b/clang/include/clang/AST/IgnoreExpr.h index 15d31f3af995..0aeb547606a2 100644 --- a/clang/include/clang/AST/IgnoreExpr.h +++ b/clang/include/clang/AST/IgnoreExpr.h @@ -19,7 +19,7 @@ namespace clang { namespace detail { /// Given an expression E and functions Fn_1,...,Fn_n : Expr * -> Expr *, /// Return Fn_n(...(Fn_1(E))) -inline Expr *IgnoreExprNodesImpl(Expr *E) { return E; }; +inline Expr *IgnoreExprNodesImpl(Expr *E) { return E; } template Expr *IgnoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&... Fns) { return IgnoreExprNodesImpl(Fn(E), std::forward(Fns)...); ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libunwind] e524daa - [libunwind] Convert x86, x86_64, arm64 register restore functions to C calling convention and name mangling
Author: Martin Storsjö Date: 2020-08-26T14:32:32+03:00 New Revision: e524daa7e8719f4b43e6ebcf25fd4e7d74c5d1c4 URL: https://github.com/llvm/llvm-project/commit/e524daa7e8719f4b43e6ebcf25fd4e7d74c5d1c4 DIFF: https://github.com/llvm/llvm-project/commit/e524daa7e8719f4b43e6ebcf25fd4e7d74c5d1c4.diff LOG: [libunwind] Convert x86, x86_64, arm64 register restore functions to C calling convention and name mangling Currently, the assembly functions for restoring register state have been direct implementations of the Registers_*::jumpto() method (contrary to the functions for saving register state, which are implementations of the extern C function __unw_getcontext). This has included having the assembly function name match the C++ mangling of that method name (and having the function match the C++ member function calling convention). To simplify the interface of the assembly implementations, make the functions have C calling conventions and name mangling. This fixes building the library in with a MSVC C++ ABI with clang-cl, which uses a significantly different method name mangling scheme. (The library might not be of much use as C++ exception unwinder in such an environment, but the libunwind.h interface for stepwise unwinding still is usable, as is the _Unwind_Backtrace function.) Differential Revision: https://reviews.llvm.org/D86041 Added: Modified: libunwind/src/Registers.hpp libunwind/src/UnwindRegistersRestore.S Removed: diff --git a/libunwind/src/Registers.hpp b/libunwind/src/Registers.hpp index c76b05bf314e..4d963b4156d1 100644 --- a/libunwind/src/Registers.hpp +++ b/libunwind/src/Registers.hpp @@ -39,6 +39,8 @@ enum { }; #if defined(_LIBUNWIND_TARGET_I386) +class _LIBUNWIND_HIDDEN Registers_x86; +extern "C" void __libunwind_Registers_x86_jumpto(Registers_x86 *); /// Registers_x86 holds the register state of a thread in a 32-bit intel /// process. class _LIBUNWIND_HIDDEN Registers_x86 { @@ -56,7 +58,7 @@ class _LIBUNWIND_HIDDEN Registers_x86 { v128getVectorRegister(int num) const; voidsetVectorRegister(int num, v128 value); static const char *getRegisterName(int num); - voidjumpto(); + voidjumpto() { __libunwind_Registers_x86_jumpto(this); } static int lastDwarfRegNum() { return _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86; } static int getArch() { return REGISTERS_X86; } @@ -248,6 +250,8 @@ inline void Registers_x86::setVectorRegister(int, v128) { #if defined(_LIBUNWIND_TARGET_X86_64) /// Registers_x86_64 holds the register state of a thread in a 64-bit intel /// process. +class _LIBUNWIND_HIDDEN Registers_x86_64; +extern "C" void __libunwind_Registers_x86_64_jumpto(Registers_x86_64 *); class _LIBUNWIND_HIDDEN Registers_x86_64 { public: Registers_x86_64(); @@ -263,7 +267,7 @@ class _LIBUNWIND_HIDDEN Registers_x86_64 { v128getVectorRegister(int num) const; voidsetVectorRegister(int num, v128 value); static const char *getRegisterName(int num); - voidjumpto(); + voidjumpto() { __libunwind_Registers_x86_64_jumpto(this); } static int lastDwarfRegNum() { return _LIBUNWIND_HIGHEST_DWARF_REGISTER_X86_64; } static int getArch() { return REGISTERS_X86_64; } @@ -1771,6 +1775,8 @@ inline const char *Registers_ppc64::getRegisterName(int regNum) { #if defined(_LIBUNWIND_TARGET_AARCH64) /// Registers_arm64 holds the register state of a thread in a 64-bit arm /// process. +class _LIBUNWIND_HIDDEN Registers_arm64; +extern "C" void __libunwind_Registers_arm64_jumpto(Registers_arm64 *); class _LIBUNWIND_HIDDEN Registers_arm64 { public: Registers_arm64(); @@ -1786,7 +1792,7 @@ class _LIBUNWIND_HIDDEN Registers_arm64 { v128getVectorRegister(int num) const; voidsetVectorRegister(int num, v128 value); static const char *getRegisterName(int num); - voidjumpto(); + voidjumpto() { __libunwind_Registers_arm64_jumpto(this); } static int lastDwarfRegNum() { return _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM64; } static int getArch() { return REGISTERS_ARM64; } diff --git a/libunwind/src/UnwindRegistersRestore.S b/libunwind/src/UnwindRegistersRestore.S index 5d5443215286..d817e6dae948 100644 --- a/libunwind/src/UnwindRegistersRestore.S +++ b/libunwind/src/UnwindRegistersRestore.S @@ -13,14 +13,10 @@ #if !defined(__USING_SJLJ_EXCEPTIONS__) #if defined(__i386__) -DEFINE_LIBUNWIND_FUNCTION(_ZN9libunwind13Registers_x866jumptoEv) +DEFINE_LIBUNWIND_FUNCTION(__libunwind_Registers_x86_jumpto) # -# void libunwind::Registers_x86::jumpto() +# extern "C" void __libunwind_Registers_x86_jumpto(Registers_x86 *); # -#if defined(_WIN32) -# On windows, the 'this' pointer is passed in ecx instead of on the stack - movl %ecx, %eax -#else # On entry: # + + # +---+ @@ -30,7 +26,6 @@ DEFINE_LIBUNWIND_FUNCTION(_ZN
[libunwind] 542db87 - [libunwind] Ensure enough alignment for unw_cursor_t for SEH build configurations
Author: Martin Storsjö Date: 2020-08-22T22:48:57+03:00 New Revision: 542db87f1ac67087aeb5cf572b1f9744d482da69 URL: https://github.com/llvm/llvm-project/commit/542db87f1ac67087aeb5cf572b1f9744d482da69 DIFF: https://github.com/llvm/llvm-project/commit/542db87f1ac67087aeb5cf572b1f9744d482da69.diff LOG: [libunwind] Ensure enough alignment for unw_cursor_t for SEH build configurations When built in SEH mode, UnwindCursor contains a CONTEXT struct, which is aligned to 16 bytes in most configurations, causing the whole UnwindCursor object to have 16 byte alignment. This fixes backtraces using _Unwind_Backtrace on x86_64 mingw, where an unw_cursor_t allocated on the stack was misaligned before. This is an ABI break for this struct for this configuration, but very few callers call libunwind directly (and even fewer directly allocate an unw_cursor_t anyway). Differential Revision: https://reviews.llvm.org/D86102 Added: Modified: libunwind/include/libunwind.h libunwind/src/UnwindCursor.hpp Removed: diff --git a/libunwind/include/libunwind.h b/libunwind/include/libunwind.h index 23ef47f4ac83..6ec649a460b8 100644 --- a/libunwind/include/libunwind.h +++ b/libunwind/include/libunwind.h @@ -43,6 +43,12 @@ #define LIBUNWIND_AVAIL #endif +#if defined(_WIN32) && defined(__SEH__) + #define LIBUNWIND_CURSOR_ALIGNMENT_ATTR __attribute__((__aligned__(16))) +#else + #define LIBUNWIND_CURSOR_ALIGNMENT_ATTR +#endif + /* error codes */ enum { UNW_ESUCCESS = 0, /* no error */ @@ -68,7 +74,7 @@ typedef struct unw_context_t unw_context_t; struct unw_cursor_t { uint64_t data[_LIBUNWIND_CURSOR_SIZE]; -}; +} LIBUNWIND_CURSOR_ALIGNMENT_ATTR; typedef struct unw_cursor_t unw_cursor_t; typedef struct unw_addr_space *unw_addr_space_t; diff --git a/libunwind/src/UnwindCursor.hpp b/libunwind/src/UnwindCursor.hpp index 03e21fb87a8d..54913360ca29 100644 --- a/libunwind/src/UnwindCursor.hpp +++ b/libunwind/src/UnwindCursor.hpp @@ -530,6 +530,8 @@ UnwindCursor::UnwindCursor(unw_context_t *context, A &as) : _addressSpace(as), _unwindInfoMissing(false) { static_assert((check_fit, unw_cursor_t>::does_fit), "UnwindCursor<> does not fit in unw_cursor_t"); + static_assert((alignof(UnwindCursor) <= alignof(unw_cursor_t)), +"UnwindCursor<> requires more alignment than unw_cursor_t"); memset(&_info, 0, sizeof(_info)); memset(&_histTable, 0, sizeof(_histTable)); _dispContext.ContextRecord = &_msContext; @@ -1182,6 +1184,8 @@ UnwindCursor::UnwindCursor(unw_context_t *context, A &as) _isSignalFrame(false) { static_assert((check_fit, unw_cursor_t>::does_fit), "UnwindCursor<> does not fit in unw_cursor_t"); + static_assert((alignof(UnwindCursor) <= alignof(unw_cursor_t)), +"UnwindCursor<> requires more alignment than unw_cursor_t"); memset(&_info, 0, sizeof(_info)); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] cb6cf18 - [clang] Remove stray semicolons, fixing GCC warnings. NFC.
Author: Martin Storsjö Date: 2020-08-19T10:41:03+03:00 New Revision: cb6cf18ff5e0e5bb751e10549accc0f035f697ac URL: https://github.com/llvm/llvm-project/commit/cb6cf18ff5e0e5bb751e10549accc0f035f697ac DIFF: https://github.com/llvm/llvm-project/commit/cb6cf18ff5e0e5bb751e10549accc0f035f697ac.diff LOG: [clang] Remove stray semicolons, fixing GCC warnings. NFC. Added: Modified: clang/lib/Basic/TargetID.cpp Removed: diff --git a/clang/lib/Basic/TargetID.cpp b/clang/lib/Basic/TargetID.cpp index e3016b5c25d6..3bb895f28832 100644 --- a/clang/lib/Basic/TargetID.cpp +++ b/clang/lib/Basic/TargetID.cpp @@ -98,7 +98,7 @@ parseTargetIDWithFormatCheckingOnly(llvm::StringRef TargetID, Features = Splits.second; } return Processor; -}; +} llvm::Optional parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID, @@ -123,7 +123,7 @@ parseTargetID(const llvm::Triple &T, llvm::StringRef TargetID, return llvm::None; return Processor; -}; +} // A canonical target ID is a target ID containing a canonical processor name // and features in alphabetical order. ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang] 6170072 - Improve modeling of variable template specializations with dependent
On Tue, 11 Aug 2020, Richard Smith wrote: On Tue, 11 Aug 2020 at 00:29, Martin Storsjö wrote: On Sun, 9 Aug 2020, Richard Smith via cfe-commits wrote: > > Author: Richard Smith > Date: 2020-08-09T23:22:26-07:00 > New Revision: 617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9 > > URL:https://github.com/llvm/llvm-project/commit/617007240cbfb97c8ccf6d61b0c4ca0 bb62d43c9 > DIFF:https://github.com/llvm/llvm-project/commit/617007240cbfb97c8ccf6d61b0c4ca0 bb62d43c9.diff > > LOG: Improve modeling of variable template specializations with dependent > arguments. > > Don't build a variable template specialization declaration until its > scope and template arguments are non-dependent. > > No functionality change intended, but the AST representation is now more > consistent with how we model other templates. This did turn out to make a functional change, breaking building the dev branch of Qt. A halfway reduced example below: Thanks for reporting this! Reduced a bit more: template inline constexpr bool is_nothrow_assignable_v = true; template class QCache { void replace() noexcept(is_nothrow_assignable_v); }; We used to allow this and now reject. This code is ill-formed (no diagnostic required) by [temp.res]/8, because it has no valid instantiations, because the second template argument of is_nothrow_assignable_v is missing. So, assuming the case from which this was reduced was similarly ill-formed (which it looks like itis: https://github.com/qt/qtbase/blob/48c8322a613f58d19ad9e0262bbac437ce259 8f8/src/corelib/tools/qcache.h#L114), I think that's a (minor) quality of implementation improvement -- we now diagnose a bug that we used to miss. ICC also rejects this, although GCC does not, and all three compilers reject the corresponding case using a class template instead of a variable template. Thanks! I sent an attempt at a fix upstream at https://codereview.qt-project.org/c/qt/qtbase/+/309878. // Martin ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang] 6170072 - Improve modeling of variable template specializations with dependent
On Sun, 9 Aug 2020, Richard Smith via cfe-commits wrote: Author: Richard Smith Date: 2020-08-09T23:22:26-07:00 New Revision: 617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9 URL: https://github.com/llvm/llvm-project/commit/617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9 DIFF: https://github.com/llvm/llvm-project/commit/617007240cbfb97c8ccf6d61b0c4ca0bb62d43c9.diff LOG: Improve modeling of variable template specializations with dependent arguments. Don't build a variable template specialization declaration until its scope and template arguments are non-dependent. No functionality change intended, but the AST representation is now more consistent with how we model other templates. This did turn out to make a functional change, breaking building the dev branch of Qt. A halfway reduced example below: template struct integral_constant { static constexpr const _Tp value = __v; typedef _Tp value_type; typedef integral_constant type; __attribute__ ((__exclude_from_explicit_instantiation__)) constexpr operator value_type() const noexcept {return value;} __attribute__ ((__exclude_from_explicit_instantiation__)) constexpr value_type operator ()() const noexcept {return value;} }; template struct is_nothrow_assignable : public integral_constant {}; template inline constexpr bool is_nothrow_assignable_v = is_nothrow_assignable<_Tp, _Arg>::value; template class QCache { struct Value { T *t = nullptr; }; struct Node { Value value; void replace(const Value &t) noexcept(is_nothrow_assignable_v) { value = t; } }; }; // Martin ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a41af6e - [clang] Fix libdl linking for libclang in standalone mode
Author: Tobias Hieta Date: 2020-07-24T00:10:22+03:00 New Revision: a41af6e41e6fcf3e7030feaf24057cbe8291b748 URL: https://github.com/llvm/llvm-project/commit/a41af6e41e6fcf3e7030feaf24057cbe8291b748 DIFF: https://github.com/llvm/llvm-project/commit/a41af6e41e6fcf3e7030feaf24057cbe8291b748.diff LOG: [clang] Fix libdl linking for libclang in standalone mode Differential Revision: https://reviews.llvm.org/D81385 Added: Modified: clang/tools/libclang/CMakeLists.txt Removed: diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index 9b34682cc49b..a4077140acee 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -68,7 +68,12 @@ endif () if (HAVE_LIBDL) list(APPEND LIBS ${CMAKE_DL_LIBS}) -endif() +elseif (CLANG_BUILT_STANDALONE) + find_library(DL_LIBRARY_PATH dl) + if (DL_LIBRARY_PATH) +list(APPEND LIBS dl) + endif () +endif () option(LIBCLANG_BUILD_STATIC "Build libclang as a static library (in addition to a shared one)" OFF) ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] beeed36 - [clang] [MinGW] Link kernel32 once after the last instance of msvcrt
Author: Martin Storsjö Date: 2020-06-17T09:37:07+03:00 New Revision: beeed368b60252178f66ab117d8a96ecdc35f60e URL: https://github.com/llvm/llvm-project/commit/beeed368b60252178f66ab117d8a96ecdc35f60e DIFF: https://github.com/llvm/llvm-project/commit/beeed368b60252178f66ab117d8a96ecdc35f60e.diff LOG: [clang] [MinGW] Link kernel32 once after the last instance of msvcrt The msvcrt library isn't a pure import library; it does contain regular object files with wrappers/fallbacks, and these can require linking against kernel32. This only makes a difference when linking with ld.bfd, as lld always searches all static libraries. This matches a similar change made recently in gcc in https://gcc.gnu.org/git/?p=gcc.git;a=commitdiff;h=850533ab160ef40eccfd039e1e3b138cf26e76b8, although clang adds --start-group --end-group around these libraries if -static is specified, which gcc doesn't. But try to match gcc's linking order in any case, for consistency. Differential Revision: https://reviews.llvm.org/D80880 Added: Modified: clang/lib/Driver/ToolChains/MinGW.cpp clang/test/Driver/mingw-msvcrt.c Removed: diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index ce01c8816263..3c2ba40323d9 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -304,10 +304,13 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-lkernel32"); } - if (Args.hasArg(options::OPT_static)) + if (Args.hasArg(options::OPT_static)) { CmdArgs.push_back("--end-group"); - else + } else { AddLibGCC(Args, CmdArgs); +if (!HasWindowsApp) + CmdArgs.push_back("-lkernel32"); + } } if (!Args.hasArg(options::OPT_nostartfiles)) { diff --git a/clang/test/Driver/mingw-msvcrt.c b/clang/test/Driver/mingw-msvcrt.c index 89a8d2a94c28..bb4813ca33a5 100644 --- a/clang/test/Driver/mingw-msvcrt.c +++ b/clang/test/Driver/mingw-msvcrt.c @@ -4,6 +4,7 @@ // RUN: %clang -v -target i686-pc-windows-gnu -lucrt -### %s 2>&1 | FileCheck -check-prefix=CHECK_UCRT %s // CHECK_DEFAULT: "-lmingwex" "-lmsvcrt" "-ladvapi32" +// CHECK_DEFAULT-SAME: "-lmsvcrt" "-lkernel32" "{{.*}}crtend.o" // CHECK_MSVCR120: "-lmsvcr120" // CHECK_MSVCR120-SAME: "-lmingwex" "-ladvapi32" // CHECK_UCRTBASE: "-lucrtbase" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7b3fe96 - [clang] Don't emit warn_cxx_ms_struct when MSBitfields is enabled globally
Author: Martin Storsjö Date: 2020-06-17T09:37:07+03:00 New Revision: 7b3fe969927731c69ba4d8a428442e1e191f49b5 URL: https://github.com/llvm/llvm-project/commit/7b3fe969927731c69ba4d8a428442e1e191f49b5 DIFF: https://github.com/llvm/llvm-project/commit/7b3fe969927731c69ba4d8a428442e1e191f49b5.diff LOG: [clang] Don't emit warn_cxx_ms_struct when MSBitfields is enabled globally This diagnostic (which defaults to an error, added in 95833f33bda6c92e746e0b0007b69c2c30bfc693) was intended to clearly point out cases where the C++ ABI won't match the Microsoft C++ ABI, for cases when this is enabled via a pragma over a region of code. The MSVC compatible struct layout feature can also be enabled via a compiler option (-mms-bitfields). If enabled that way, one essentially can't compile any C++ code unless also building with -Wno-incompatible-ms-struct (which GCC doesn't support, and projects developed with GCC aren't setting). For the MinGW target, it's expected that the C++ ABI won't match the MSVC one, if this option is used for getting the struct layout to match MSVC. Differential Revision: https://reviews.llvm.org/D81794 Added: Modified: clang/lib/Sema/SemaDeclCXX.cpp clang/test/SemaCXX/ms_struct.cpp Removed: diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index f1ade752e2fe..a2b669c99125 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -6773,7 +6773,11 @@ void Sema::CheckCompletedCXXClass(Scope *S, CXXRecordDecl *Record) { // headers, sweeping up a bunch of types that the project doesn't // really rely on MSVC-compatible layout for. We must therefore // support "ms_struct except for C++ stuff" as a secondary ABI. - if (Record->isMsStruct(Context) && + // Don't emit this diagnostic if the feature was enabled as a + // language option (as opposed to via a pragma or attribute), as + // the option -mms-bitfields otherwise essentially makes it impossible + // to build C++ code, unless this diagnostic is turned off. + if (Record->isMsStruct(Context) && !Context.getLangOpts().MSBitfields && (Record->isPolymorphic() || Record->getNumBases())) { Diag(Record->getLocation(), diag::warn_cxx_ms_struct); } diff --git a/clang/test/SemaCXX/ms_struct.cpp b/clang/test/SemaCXX/ms_struct.cpp index 414b56b491c6..122819c3eead 100644 --- a/clang/test/SemaCXX/ms_struct.cpp +++ b/clang/test/SemaCXX/ms_struct.cpp @@ -1,8 +1,11 @@ -// RUN: %clang_cc1 -fsyntax-only -Wno-error=incompatible-ms-struct -verify -triple i686-apple-darwin9 -std=c++11 %s -// RUN: %clang_cc1 -fsyntax-only -Wno-error=incompatible-ms-struct -verify -triple armv7-apple-darwin9 -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_WARNING -Wno-error=incompatible-ms-struct -verify -triple i686-apple-darwin9 -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_WARNING -Wno-error=incompatible-ms-struct -verify -triple armv7-apple-darwin9 -std=c++11 %s // RUN: %clang_cc1 -fsyntax-only -DTEST_FOR_ERROR -verify -triple armv7-apple-darwin9 -std=c++11 %s +// RUN: %clang_cc1 -fsyntax-only -DNO_PRAGMA -mms-bitfields -verify -triple armv7-apple-darwin9 -std=c++11 %s +#ifndef NO_PRAGMA #pragma ms_struct on +#endif struct A { unsigned long a:4; @@ -12,7 +15,7 @@ struct A { struct B : public A { #ifdef TEST_FOR_ERROR // expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}} -#else +#elif defined(TEST_FOR_WARNING) // expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}} #endif unsigned long c:16; @@ -27,7 +30,7 @@ static_assert(__builtin_offsetof(B, d) == 12, struct C { #ifdef TEST_FOR_ERROR // expected-error@-2 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}} -#else +#elif defined(TEST_FOR_WARNING) // expected-warning@-4 {{ms_struct may not produce Microsoft-compatible layouts for classes with base classes or virtual functions}} #endif virtual void foo(); @@ -36,3 +39,6 @@ struct C { static_assert(__builtin_offsetof(C, n) == 8, "long long field in ms_struct should be 8-byte aligned"); +#if !defined(TEST_FOR_ERROR) && !defined(TEST_FOR_WARNING) +// expected-no-diagnostics +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] e3fd9dc - [clang] Enable -mms-bitfields by default for mingw targets
Author: Martin Storsjö Date: 2020-06-17T09:37:07+03:00 New Revision: e3fd9dc9734c5775dc6824d0a839702e8d43e7f6 URL: https://github.com/llvm/llvm-project/commit/e3fd9dc9734c5775dc6824d0a839702e8d43e7f6 DIFF: https://github.com/llvm/llvm-project/commit/e3fd9dc9734c5775dc6824d0a839702e8d43e7f6.diff LOG: [clang] Enable -mms-bitfields by default for mingw targets This matches GCC, which enabled -mms-bitfields by default for mingw targets in 4.7 [1]. [1] https://www.gnu.org/software/gcc/gcc-4.7/changes.html Differential Revision: https://reviews.llvm.org/D81795 Added: Modified: clang/lib/Driver/ToolChains/Clang.cpp clang/test/Driver/ms-bitfields.c Removed: diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp index 23ffc212056a..0ff8d1250242 100644 --- a/clang/lib/Driver/ToolChains/Clang.cpp +++ b/clang/lib/Driver/ToolChains/Clang.cpp @@ -4679,7 +4679,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-fforbid-guard-variables"); if (Args.hasFlag(options::OPT_mms_bitfields, options::OPT_mno_ms_bitfields, - false)) { + Triple.isWindowsGNUEnvironment())) { CmdArgs.push_back("-mms-bitfields"); } diff --git a/clang/test/Driver/ms-bitfields.c b/clang/test/Driver/ms-bitfields.c index 7bf9aaad2c96..51faa05f5855 100644 --- a/clang/test/Driver/ms-bitfields.c +++ b/clang/test/Driver/ms-bitfields.c @@ -1,4 +1,5 @@ -// RUN: %clang -### %s 2>&1 | FileCheck %s -check-prefix=NO-MSBITFIELDS +// RUN: %clang -### -target x86_64-linux-gnu %s 2>&1 | FileCheck %s -check-prefix=NO-MSBITFIELDS +// RUN: %clang -### -target x86_64-windows-gnu %s 2>&1 | FileCheck %s -check-prefix=MSBITFIELDS // RUN: %clang -### -mno-ms-bitfields -mms-bitfields %s 2>&1 | FileCheck %s -check-prefix=MSBITFIELDS // RUN: %clang -### -mms-bitfields -mno-ms-bitfields %s 2>&1 | FileCheck %s -check-prefix=NO-MSBITFIELDS ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ab4d02c - [clang] [MinGW] Fix libunwind extension
Author: Mateusz Mikuła Date: 2020-05-29T15:23:14+03:00 New Revision: ab4d02cf265982d4c03123d2f52b9d5ee8df575d URL: https://github.com/llvm/llvm-project/commit/ab4d02cf265982d4c03123d2f52b9d5ee8df575d DIFF: https://github.com/llvm/llvm-project/commit/ab4d02cf265982d4c03123d2f52b9d5ee8df575d.diff LOG: [clang] [MinGW] Fix libunwind extension Differential Revision: https://reviews.llvm.org/D79995 Added: Modified: clang/lib/Driver/ToolChains/CommonArgs.cpp clang/test/Driver/compiler-rt-unwind.c Removed: diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp index 33c43222b5f9..b2c984912154 100644 --- a/clang/lib/Driver/ToolChains/CommonArgs.cpp +++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp @@ -1235,7 +1235,14 @@ static void AddUnwindLibrary(const ToolChain &TC, const Driver &D, case ToolChain::UNW_CompilerRT: if (LGT == LibGccType::StaticLibGcc) CmdArgs.push_back("-l:libunwind.a"); -else +else if (TC.getTriple().isOSCygMing()) { + if (LGT == LibGccType::SharedLibGcc) +CmdArgs.push_back("-l:libunwind.dll.a"); + else +// Let the linker choose between libunwind.dll.a and libunwind.a +// depending on what's available, and depending on the -static flag +CmdArgs.push_back("-lunwind"); +} else CmdArgs.push_back("-l:libunwind.so"); break; } diff --git a/clang/test/Driver/compiler-rt-unwind.c b/clang/test/Driver/compiler-rt-unwind.c index 652a48c6ad78..e21916d41f93 100644 --- a/clang/test/Driver/compiler-rt-unwind.c +++ b/clang/test/Driver/compiler-rt-unwind.c @@ -48,3 +48,26 @@ // RUN: --gcc-toolchain="" \ // RUN: FileCheck --input-file=%t.err --check-prefix=RTLIB-GCC-UNWINDLIB-COMPILER_RT %s // RTLIB-GCC-UNWINDLIB-COMPILER_RT: "{{[.|\\\n]*}}--rtlib=libgcc requires --unwindlib=libgcc" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \ +// RUN: -shared-libgcc \ +// RUN: --gcc-toolchain="" \ +// RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT %s +// MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a" +// MINGW-RTLIB-COMPILER-RT-SHARED-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.dll.a" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \ +// RUN: -static-libgcc \ +// RUN: --gcc-toolchain="" \ +// RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT %s +// MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a" +// MINGW-RTLIB-COMPILER-RT-STATIC-UNWINDLIB-COMPILER-RT: "{{.*}}l:libunwind.a" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=x86_64-w64-mingw32 -rtlib=compiler-rt --unwindlib=libunwind \ +// RUN: --gcc-toolchain="" \ +// RUN: | FileCheck --check-prefix=MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT %s +// MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}libclang_rt.builtins-x86_64.a" +// MINGW-RTLIB-COMPILER-RT-UNWINDLIB-COMPILER-RT: "{{.*}}lunwind" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] ac1f7ab - [clang] [Darwin] Add reverse mappings for aarch64/aarch64_32 to darwin arch names
Author: Martin Storsjö Date: 2020-05-29T15:23:14+03:00 New Revision: ac1f7ab007e347dc4a542aa3415e6378289480f4 URL: https://github.com/llvm/llvm-project/commit/ac1f7ab007e347dc4a542aa3415e6378289480f4 DIFF: https://github.com/llvm/llvm-project/commit/ac1f7ab007e347dc4a542aa3415e6378289480f4.diff LOG: [clang] [Darwin] Add reverse mappings for aarch64/aarch64_32 to darwin arch names These are mapped in MachO::getMachOArchName already, but were missing in ToolChain::getDefaultUniversalArchName. Having these reverse mapped here fixes weird inconsistencies like -dumpmachine showing a target triple like "aarch64-apple-darwin", while "clang -target aarch64-apple-darwin" didn't use to work (ended up mapped as unknown-apple-ios). Differential Revision: https://reviews.llvm.org/D79117 Added: clang/test/Driver/darwin-arm64-target.c Modified: clang/lib/Driver/ToolChain.cpp Removed: diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index ad66e8e6b5d3..cf04fd07e2a0 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -230,9 +230,12 @@ ToolChain::getTargetAndModeFromProgramName(StringRef PN) { StringRef ToolChain::getDefaultUniversalArchName() const { // In universal driver terms, the arch name accepted by -arch isn't exactly // the same as the ones that appear in the triple. Roughly speaking, this is - // an inverse of the darwin::getArchTypeForDarwinArchName() function, but the - // only interesting special case is powerpc. + // an inverse of the darwin::getArchTypeForDarwinArchName() function. switch (Triple.getArch()) { + case llvm::Triple::aarch64: +return "arm64"; + case llvm::Triple::aarch64_32: +return "arm64_32"; case llvm::Triple::ppc: return "ppc"; case llvm::Triple::ppc64: diff --git a/clang/test/Driver/darwin-arm64-target.c b/clang/test/Driver/darwin-arm64-target.c new file mode 100644 index ..397afa288360 --- /dev/null +++ b/clang/test/Driver/darwin-arm64-target.c @@ -0,0 +1,3 @@ +// RUN: %clang -target aarch64-apple-darwin %s -miphoneos-version-min=8.0 -### 2>&1 | FileCheck %s + +// CHECK: "-cc1"{{.*}} "-triple" "arm64-apple-ios8.0.0" ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 0073c29 - [clang] Avoid linking libdl unless needed
Author: Tobias Hieta Date: 2020-05-28T21:08:00+03:00 New Revision: 0073c293a401774ac96b4b3d27f05e13f379f98e URL: https://github.com/llvm/llvm-project/commit/0073c293a401774ac96b4b3d27f05e13f379f98e DIFF: https://github.com/llvm/llvm-project/commit/0073c293a401774ac96b4b3d27f05e13f379f98e.diff LOG: [clang] Avoid linking libdl unless needed Differential Revision: https://reviews.llvm.org/D80492 Added: Modified: clang/tools/libclang/CMakeLists.txt Removed: diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index ba286b672772..9b34682cc49b 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -66,9 +66,8 @@ if (LIBCLANG_INCLUDE_CLANG_TOOLS_EXTRA) endif () endif () -find_library(DL_LIBRARY_PATH dl) -if (DL_LIBRARY_PATH) - list(APPEND LIBS dl) +if (HAVE_LIBDL) + list(APPEND LIBS ${CMAKE_DL_LIBS}) endif() option(LIBCLANG_BUILD_STATIC ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 609ef94 - [CMake] Fix building with -DBUILD_SHARED_LIBS=ON on mingw
Author: Martin Storsjö Date: 2020-05-11T23:51:14+03:00 New Revision: 609ef948387ba40e3693c2bd693d82ca34dcdc02 URL: https://github.com/llvm/llvm-project/commit/609ef948387ba40e3693c2bd693d82ca34dcdc02 DIFF: https://github.com/llvm/llvm-project/commit/609ef948387ba40e3693c2bd693d82ca34dcdc02.diff LOG: [CMake] Fix building with -DBUILD_SHARED_LIBS=ON on mingw Set the right target name in clang/examples/Attribute. Add a missing dependency in the TableGen GlobalISel sublibrary. Skip building the Bye pass plugin example on windows; plugins that should have undefined symbols that are found in the host process aren't supported on windows - this matches what was done for a unit test in bc8e44218810c0db6328b9809c959ceb7d43e3f5. Added: Modified: clang/examples/Attribute/CMakeLists.txt llvm/examples/Bye/CMakeLists.txt llvm/utils/TableGen/GlobalISel/CMakeLists.txt Removed: diff --git a/clang/examples/Attribute/CMakeLists.txt b/clang/examples/Attribute/CMakeLists.txt index 19323bb0962b..ed02f5e5992f 100644 --- a/clang/examples/Attribute/CMakeLists.txt +++ b/clang/examples/Attribute/CMakeLists.txt @@ -1,7 +1,7 @@ add_llvm_library(Attribute MODULE Attribute.cpp PLUGIN_TOOL clang) if(LLVM_ENABLE_PLUGINS AND (WIN32 OR CYGWIN)) - target_link_libraries(AnnotateFunctions ${cmake_2_8_12_PRIVATE} + target_link_libraries(Attribute ${cmake_2_8_12_PRIVATE} clangAST clangBasic clangFrontend diff --git a/llvm/examples/Bye/CMakeLists.txt b/llvm/examples/Bye/CMakeLists.txt index 3206f90d0916..362086eb1b32 100644 --- a/llvm/examples/Bye/CMakeLists.txt +++ b/llvm/examples/Bye/CMakeLists.txt @@ -2,12 +2,18 @@ if(LLVM_BYE_LINK_INTO_TOOLS) message(WARNING "Setting LLVM_BYE_LINK_INTO_TOOLS=ON only makes sense for testing purpose") endif() -add_llvm_pass_plugin(Bye - Bye.cpp - DEPENDS - intrinsics_gen - BUILDTREE_ONLY - ) +# The plugin expects to not link against the Support and Core libraries, +# but expects them to exist in the process loading the plugin. This doesn't +# work with DLLs on Windows (where a shared library can't have undefined +# references), so just skip this testcase on Windows. +if (NOT WIN32) + add_llvm_pass_plugin(Bye +Bye.cpp +DEPENDS +intrinsics_gen +BUILDTREE_ONLY + ) -install(TARGETS ${name} RUNTIME DESTINATION examples) -set_target_properties(${name} PROPERTIES FOLDER "Examples") + install(TARGETS ${name} RUNTIME DESTINATION examples) + set_target_properties(${name} PROPERTIES FOLDER "Examples") +endif() diff --git a/llvm/utils/TableGen/GlobalISel/CMakeLists.txt b/llvm/utils/TableGen/GlobalISel/CMakeLists.txt index 292a1bd639fb..25fff72d3dcf 100644 --- a/llvm/utils/TableGen/GlobalISel/CMakeLists.txt +++ b/llvm/utils/TableGen/GlobalISel/CMakeLists.txt @@ -1,5 +1,6 @@ set(LLVM_LINK_COMPONENTS Support + TableGen ) llvm_add_library(LLVMTableGenGlobalISel STATIC DISABLE_LLVM_LINK_LLVM_DYLIB ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] a0e53de - [clang] [MinGW] Add the compiler rt libdirs to the search path
Author: Martin Storsjö Date: 2020-04-29T20:35:50+03:00 New Revision: a0e53de472c5b9538884f23eb8f47c3bc734b345 URL: https://github.com/llvm/llvm-project/commit/a0e53de472c5b9538884f23eb8f47c3bc734b345 DIFF: https://github.com/llvm/llvm-project/commit/a0e53de472c5b9538884f23eb8f47c3bc734b345.diff LOG: [clang] [MinGW] Add the compiler rt libdirs to the search path This matches what is done for MSVC in b8000c0ce84541c5b5535419234fb65ce77d6756. Since that commit, compiler rt sanitizer libraries aren't linked to with absolute path on windows, but using their basenames, requiring the libdirs to be passed to the linker. This fixes undefined behaviour sanitizer on MinGW after b8000c0ce84541c5b5535419234fb65ce77d6756. Differential Revision: https://reviews.llvm.org/D79076 Added: Modified: clang/lib/Driver/ToolChains/MinGW.cpp Removed: diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp index 6139764e4601..ce01c8816263 100644 --- a/clang/lib/Driver/ToolChains/MinGW.cpp +++ b/clang/lib/Driver/ToolChains/MinGW.cpp @@ -18,6 +18,7 @@ #include "llvm/Option/ArgList.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" +#include "llvm/Support/VirtualFileSystem.h" #include using namespace clang::diag; @@ -198,6 +199,17 @@ void tools::MinGW::Linker::ConstructJob(Compilation &C, const JobAction &JA, Args.AddAllArgs(CmdArgs, options::OPT_L); TC.AddFilePathLibArgs(Args, CmdArgs); + + // Add the compiler-rt library directories if they exist to help + // the linker find the various sanitizer, builtin, and profiling runtimes. + for (const auto &LibPath : TC.getLibraryPaths()) { +if (TC.getVFS().exists(LibPath)) + CmdArgs.push_back(Args.MakeArgString("-L" + LibPath)); + } + auto CRTPath = TC.getCompilerRTPath(); + if (TC.getVFS().exists(CRTPath)) +CmdArgs.push_back(Args.MakeArgString("-L" + CRTPath)); + AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA); // TODO: Add profile stuff here ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 6fb80d9 - libclang: Add static build support for Windows
Author: Cristian Adam Date: 2020-04-25T20:19:17+03:00 New Revision: 6fb80d9383e415c35204b62569972f70ae7dcb0a URL: https://github.com/llvm/llvm-project/commit/6fb80d9383e415c35204b62569972f70ae7dcb0a DIFF: https://github.com/llvm/llvm-project/commit/6fb80d9383e415c35204b62569972f70ae7dcb0a.diff LOG: libclang: Add static build support for Windows Differential Revision: https://reviews.llvm.org/D75068 Added: Modified: clang/include/clang-c/Platform.h clang/tools/libclang/CMakeLists.txt Removed: diff --git a/clang/include/clang-c/Platform.h b/clang/include/clang-c/Platform.h index 3bb66bb0df48..67c1fff8ff78 100644 --- a/clang/include/clang-c/Platform.h +++ b/clang/include/clang-c/Platform.h @@ -18,14 +18,23 @@ LLVM_CLANG_C_EXTERN_C_BEGIN -/* MSVC DLL import/export. */ -#ifdef _MSC_VER - #ifdef _CINDEX_LIB_ -#define CINDEX_LINKAGE __declspec(dllexport) - #else -#define CINDEX_LINKAGE __declspec(dllimport) +/* Windows DLL import/export. */ +#ifndef CINDEX_NO_EXPORTS + #define CINDEX_EXPORTS +#endif +#ifdef _WIN32 + #ifdef CINDEX_EXPORTS +#ifdef _CINDEX_LIB_ + #define CINDEX_LINKAGE __declspec(dllexport) +#else + #define CINDEX_LINKAGE __declspec(dllimport) +#endif #endif -#else +#elif defined(CINDEX_EXPORTS) && defined(__GNUC__) + #define CINDEX_LINKAGE __attribute__((visibility("default"))) +#endif + +#ifndef CINDEX_LINKAGE #define CINDEX_LINKAGE #endif diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index bd0c945a5e12..bb2b14cc8e27 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -77,14 +77,18 @@ if(MSVC) set(LLVM_EXPORTED_SYMBOL_FILE) endif() -if(LLVM_ENABLE_PIC OR WIN32) +if(LLVM_ENABLE_PIC OR NOT LIBCLANG_BUILD_STATIC) set(ENABLE_SHARED SHARED) endif() -if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32) +if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) set(ENABLE_STATIC STATIC) endif() +if (WIN32 AND ENABLE_SHARED AND ENABLE_STATIC) + unset(ENABLE_STATIC) +endif() + if(WIN32) set(output_name "libclang") else() @@ -113,6 +117,14 @@ add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} INSTALL_WITH_TOOLCH Support ) +if(ENABLE_STATIC) + foreach(name libclang obj.libclang libclang_static) +if (TARGET ${name}) + target_compile_definitions(${name} PUBLIC CINDEX_NO_EXPORTS) +endif() + endforeach() +endif() + if(ENABLE_SHARED) if(WIN32) set_target_properties(libclang ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] 7ff1f55 - libclang: Add static build support for Windows
Author: Cristian Adam Date: 2020-02-20T00:05:46+02:00 New Revision: 7ff1f55a1219719f57a6f7905c26ce41d1767e4c URL: https://github.com/llvm/llvm-project/commit/7ff1f55a1219719f57a6f7905c26ce41d1767e4c DIFF: https://github.com/llvm/llvm-project/commit/7ff1f55a1219719f57a6f7905c26ce41d1767e4c.diff LOG: libclang: Add static build support for Windows Differential Revision: https://reviews.llvm.org/D74564 Added: Modified: clang/include/clang-c/Platform.h clang/tools/libclang/CMakeLists.txt Removed: diff --git a/clang/include/clang-c/Platform.h b/clang/include/clang-c/Platform.h index 3bb66bb0df48..9c15516f362f 100644 --- a/clang/include/clang-c/Platform.h +++ b/clang/include/clang-c/Platform.h @@ -18,14 +18,20 @@ LLVM_CLANG_C_EXTERN_C_BEGIN -/* MSVC DLL import/export. */ -#ifdef _MSC_VER - #ifdef _CINDEX_LIB_ -#define CINDEX_LINKAGE __declspec(dllexport) - #else -#define CINDEX_LINKAGE __declspec(dllimport) +/* Windows DLL import/export. */ +#ifdef _WIN32 + #ifdef CINDEX_EXPORTS +#ifdef _CINDEX_LIB_ + #define CINDEX_LINKAGE __declspec(dllexport) +#else + #define CINDEX_LINKAGE __declspec(dllimport) +#endif #endif -#else +#elif defined(CINDEX_EXPORTS) + #define CINDEX_LINKAGE __attribute__((visibility("default"))) +#endif + +#ifndef CINDEX_LINKAGE #define CINDEX_LINKAGE #endif diff --git a/clang/tools/libclang/CMakeLists.txt b/clang/tools/libclang/CMakeLists.txt index bd0c945a5e12..99de3b399855 100644 --- a/clang/tools/libclang/CMakeLists.txt +++ b/clang/tools/libclang/CMakeLists.txt @@ -77,11 +77,11 @@ if(MSVC) set(LLVM_EXPORTED_SYMBOL_FILE) endif() -if(LLVM_ENABLE_PIC OR WIN32) +if(LLVM_ENABLE_PIC) set(ENABLE_SHARED SHARED) endif() -if((NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) AND NOT WIN32) +if(NOT LLVM_ENABLE_PIC OR LIBCLANG_BUILD_STATIC) set(ENABLE_STATIC STATIC) endif() @@ -114,6 +114,7 @@ add_clang_library(libclang ${ENABLE_SHARED} ${ENABLE_STATIC} INSTALL_WITH_TOOLCH ) if(ENABLE_SHARED) + target_compile_definitions(libclang PUBLIC CINDEX_EXPORTS) if(WIN32) set_target_properties(libclang PROPERTIES ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r368348 - Fix up fd limit diagnosis code
Thanks for the fix, Qt does seem to build correctly now again. // Martin On Fri, 9 Aug 2019, Reid Kleckner wrote: Let me know if the problem persists after r368475. Someone else filed https://bugs.llvm.org/show_bug.cgi?id=42948 as well. On Thu, Aug 8, 2019 at 11:34 PM Martin Storsjö wrote: This change broke compiling Qt. A repro case looks like this: mkdir -p fake-qtincl/5.13.1/QtCore/private touch fake-qtincl/5.13.1/QtCore/private/qglobal_p.h touch fake-qtincl/QtCore echo "#include " > qtincl.cpp bin/clang++ -c qtincl.cpp -Ifake-qtincl -Ifake-qtincl/5.13.1 Previously this ignored the non-directory QtCore, but now clang bails out on it. (And this is code that all other major compilers tolerate, afaik.) // Martin On Thu, 8 Aug 2019, Reid Kleckner via cfe-commits wrote: > Author: rnk > Date: Thu Aug 8 14:35:03 2019 > New Revision: 368348 > > URL: http://llvm.org/viewvc/llvm-project?rev=368348&view=rev > Log: > Fix up fd limit diagnosis code > > Apparently Windows returns the "invalid argument" error code when the > path contains invalid characters such as '<'. The > test/Preprocessor/include-likely-typo.c test does this, so it was > failing after r368322. > > Also, the diagnostic requires two arguments, so add the filename. > > Modified: > cfe/trunk/lib/Lex/HeaderSearch.cpp > > Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp > URL:http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev= 368348&r1=368347&r2=368348&view=diff >=== === > --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original) > +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Aug 8 14:35:03 2019 > @@ -316,8 +316,9 @@ const FileEntry *HeaderSearch::getFileAn > // message. > std::error_code EC = File.getError(); > if (EC != std::errc::no_such_file_or_directory && > - EC != std::errc::is_a_directory) { > - Diags.Report(IncludeLoc, diag::err_cannot_open_file) << EC.message(); > + EC != std::errc::invalid_argument && EC != std::errc::is_a_directory) { > + Diags.Report(IncludeLoc, diag::err_cannot_open_file) > + << FileName << EC.message(); > } > return nullptr; > } > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r368348 - Fix up fd limit diagnosis code
This change broke compiling Qt. A repro case looks like this: mkdir -p fake-qtincl/5.13.1/QtCore/private touch fake-qtincl/5.13.1/QtCore/private/qglobal_p.h touch fake-qtincl/QtCore echo "#include " > qtincl.cpp bin/clang++ -c qtincl.cpp -Ifake-qtincl -Ifake-qtincl/5.13.1 Previously this ignored the non-directory QtCore, but now clang bails out on it. (And this is code that all other major compilers tolerate, afaik.) // Martin On Thu, 8 Aug 2019, Reid Kleckner via cfe-commits wrote: Author: rnk Date: Thu Aug 8 14:35:03 2019 New Revision: 368348 URL: http://llvm.org/viewvc/llvm-project?rev=368348&view=rev Log: Fix up fd limit diagnosis code Apparently Windows returns the "invalid argument" error code when the path contains invalid characters such as '<'. The test/Preprocessor/include-likely-typo.c test does this, so it was failing after r368322. Also, the diagnostic requires two arguments, so add the filename. Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=368348&r1=368347&r2=368348&view=diff == --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original) +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Aug 8 14:35:03 2019 @@ -316,8 +316,9 @@ const FileEntry *HeaderSearch::getFileAn // message. std::error_code EC = File.getError(); if (EC != std::errc::no_such_file_or_directory && -EC != std::errc::is_a_directory) { - Diags.Report(IncludeLoc, diag::err_cannot_open_file) << EC.message(); +EC != std::errc::invalid_argument && EC != std::errc::is_a_directory) { + Diags.Report(IncludeLoc, diag::err_cannot_open_file) + << FileName << EC.message(); } return nullptr; } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r362551 - Convert MemberExpr creation and serialization to work the same way as
This broke building of Qt when using PCH. Selfcontained repro is a bit hard to make though... // Martin On Tue, 4 Jun 2019, Richard Smith via cfe-commits wrote: Author: rsmith Date: Tue Jun 4 14:29:28 2019 New Revision: 362551 URL: http://llvm.org/viewvc/llvm-project?rev=362551&view=rev Log: Convert MemberExpr creation and serialization to work the same way as most / all other Expr subclasses. Modified: cfe/trunk/include/clang/AST/Expr.h cfe/trunk/include/clang/AST/Stmt.h cfe/trunk/lib/AST/DeclBase.cpp cfe/trunk/lib/AST/Expr.cpp cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp cfe/trunk/lib/Sema/SemaExprCXX.cpp cfe/trunk/lib/Serialization/ASTReaderStmt.cpp cfe/trunk/lib/Serialization/ASTWriterStmt.cpp Modified: cfe/trunk/include/clang/AST/Expr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Expr.h?rev=362551&r1=362550&r2=362551&view=diff == --- cfe/trunk/include/clang/AST/Expr.h (original) +++ cfe/trunk/include/clang/AST/Expr.h Tue Jun 4 14:29:28 2019 @@ -2735,6 +2735,7 @@ class MemberExpr final ASTTemplateKWAndArgsInfo, TemplateArgumentLoc> { friend class ASTReader; + friend class ASTStmtReader; friend class ASTStmtWriter; friend TrailingObjects; @@ -2769,49 +2770,38 @@ class MemberExpr final return MemberExprBits.HasTemplateKWAndArgsInfo; } -public: - MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc, - ValueDecl *memberdecl, const DeclarationNameInfo &NameInfo, - QualType ty, ExprValueKind VK, ExprObjectKind OK) - : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(), - base->isValueDependent(), base->isInstantiationDependent(), - base->containsUnexpandedParameterPack()), -Base(base), MemberDecl(memberdecl), MemberDNLoc(NameInfo.getInfo()), -MemberLoc(NameInfo.getLoc()) { -assert(memberdecl->getDeclName() == NameInfo.getName()); -MemberExprBits.IsArrow = isarrow; -MemberExprBits.HasQualifierOrFoundDecl = false; -MemberExprBits.HasTemplateKWAndArgsInfo = false; -MemberExprBits.HadMultipleCandidates = false; -MemberExprBits.OperatorLoc = operatorloc; - } - - // NOTE: this constructor should be used only when it is known that - // the member name can not provide additional syntactic info - // (i.e., source locations for C++ operator names or type source info - // for constructors, destructors and conversion operators). - MemberExpr(Expr *base, bool isarrow, SourceLocation operatorloc, - ValueDecl *memberdecl, SourceLocation l, QualType ty, - ExprValueKind VK, ExprObjectKind OK) - : Expr(MemberExprClass, ty, VK, OK, base->isTypeDependent(), - base->isValueDependent(), base->isInstantiationDependent(), - base->containsUnexpandedParameterPack()), -Base(base), MemberDecl(memberdecl), MemberDNLoc(), MemberLoc(l) { -MemberExprBits.IsArrow = isarrow; -MemberExprBits.HasQualifierOrFoundDecl = false; -MemberExprBits.HasTemplateKWAndArgsInfo = false; -MemberExprBits.HadMultipleCandidates = false; -MemberExprBits.OperatorLoc = operatorloc; - } + MemberExpr(Expr *Base, bool IsArrow, SourceLocation OperatorLoc, + ValueDecl *MemberDecl, const DeclarationNameInfo &NameInfo, + QualType T, ExprValueKind VK, ExprObjectKind OK); + MemberExpr(EmptyShell Empty) + : Expr(MemberExprClass, Empty), Base(), MemberDecl() {} - static MemberExpr *Create(const ASTContext &C, Expr *base, bool isarrow, +public: + static MemberExpr *Create(const ASTContext &C, Expr *Base, bool IsArrow, SourceLocation OperatorLoc, NestedNameSpecifierLoc QualifierLoc, -SourceLocation TemplateKWLoc, ValueDecl *memberdecl, -DeclAccessPair founddecl, +SourceLocation TemplateKWLoc, ValueDecl *MemberDecl, +DeclAccessPair FoundDecl, DeclarationNameInfo MemberNameInfo, -const TemplateArgumentListInfo *targs, QualType ty, -ExprValueKind VK, ExprObjectKind OK); +const TemplateArgumentListInfo *TemplateArgs, +QualType T, ExprValueKind VK, ExprObjectKind OK); + + /// Create an implicit MemberExpr, with no location, qualifier, template + /// arguments, and so on. + static MemberExpr *CreateImplicit(const ASTContext &C, Expr *Base, +bool IsArrow, ValueDecl *MemberDecl, +QualType T, ExprValueKind VK, +ExprObjectKind OK) { +return Create(C, Base, IsArro
Re: [PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.
FWIW, this was fixed by SVN r354201. Thanks David! // Martin On Sat, 16 Feb 2019, Martin Storsjö via cfe-commits wrote: It broke on the first commit and is broken even after all of them. // Martin On Fri, 15 Feb 2019, Yitzhak Mandelbaum wrote: Was it the complete diff or one of the intermediate commits? I accidentally committed the diff as a series of commits rather than one (squashed) commit. On Fri, Feb 15, 2019 at 4:51 PM Martin Storsjö via Phabricator wrote: mstorsjo added a comment. This broke compilation with GCC 5.4 on Ubuntu 16.04: ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:243: warning: missing terminating " character ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:3: error: missing terminating " character EXPECT_TRUE(matches( ^ ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:480:7: error: stray ‘\’ in program void z(X x) { x.m(); } ^ Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56850/new/ https://reviews.llvm.org/D56850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D56850: [ASTMatchers][NFC] Add tests for assorted `CXXMemberCallExpr` matchers.
It broke on the first commit and is broken even after all of them. // Martin On Fri, 15 Feb 2019, Yitzhak Mandelbaum wrote: Was it the complete diff or one of the intermediate commits? I accidentally committed the diff as a series of commits rather than one (squashed) commit. On Fri, Feb 15, 2019 at 4:51 PM Martin Storsjö via Phabricator wrote: mstorsjo added a comment. This broke compilation with GCC 5.4 on Ubuntu 16.04: ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:243: warning: missing terminating " character ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:474:3: error: missing terminating " character EXPECT_TRUE(matches( ^ ../tools/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp:480:7: error: stray ‘\’ in program void z(X x) { x.m(); } ^ Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D56850/new/ https://reviews.llvm.org/D56850 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute
On Thu, 2 Aug 2018, Richard Smith via cfe-commits wrote: On Thu, 2 Aug 2018, 06:10 Martin Storsjö via Phabricator via cfe-commits, wrote: mstorsjo added a comment. This change made clang to start trigger failed asserts for me (although they seem to not be reproducible with all compilers building clang), see https://bugs.llvm.org/show_bug.cgi?id=38421 for full description. Are you still seeing problems after r338478? This change is miscompiled by GCC; that revision contains a workaround. Sorry, didn't see this mail until now. Yes, I saw problems even after r338478; I applied the same fix in a different spot as well, in r338749. // Martin ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r338749 - Work around more GCC miscompiles exposed by r338464.
Hans, I think this commit should be merged to the 7.0 release branch; the first half of the GCC workaround made it in before the branch happened, but there was another identical case missing. // Martin On Thu, 2 Aug 2018, Martin Storsjo via cfe-commits wrote: Author: mstorsjo Date: Thu Aug 2 11:12:08 2018 New Revision: 338749 URL: http://llvm.org/viewvc/llvm-project?rev=338749&view=rev Log: Work around more GCC miscompiles exposed by r338464. This is the same fix as in r338478, for another occurrance of the same pattern from r338464. See gcc.gnu.org/PR86769 for details of the bug. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r334208 - [X86] Add back builtins for _mm_slli_si128/_mm_srli_si128 and similar intrinsics.
On Thu, 7 Jun 2018, Craig Topper via cfe-commits wrote: Author: ctopper Date: Thu Jun 7 10:28:03 2018 New Revision: 334208 URL: http://llvm.org/viewvc/llvm-project?rev=334208&view=rev Log: [X86] Add back builtins for _mm_slli_si128/_mm_srli_si128 and similar intrinsics. We still lower them to native shuffle IR, but we do it in CGBuiltin.cpp now. This allows us to check the target feature and ensure the immediate fits in 8 bits. FWIW, this change broke building libaom: https://bugs.chromium.org/p/aomedia/issues/detail?id=1945 In libaom, there's a macro construct like this: #define v256_shr_n_byte(a, n) \ ((n) < 16 \ ? _mm256_alignr_epi8( \ _mm256_permute2x128_si256(a, a, _MM_SHUFFLE(2, 0, 0, 1)), a, n) \ : ((n) > 16\ ? _mm256_srli_si256(\ _mm256_permute2x128_si256(a, a, _MM_SHUFFLE(2, 0, 0, 1)), \ (n)-16) \ : _mm256_permute2x128_si256(a, a, _MM_SHUFFLE(2, 0, 0, 1 Since this commit, the compilation errors out due to the _mm256_srli_si256 with invalid range, even though the toplevel ternary operator won't actually pick them to be used. Not sure if there's anything to do from the clang point of view here, I guess it's a tradeoff between having stricter parameter checks for the intrinsics, vs the convenience of piling them up in a macro like this in libaom. // Martin ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r333978 - Reimplement the bittest intrinsic family as builtins with inline asm
On Tue, 5 Jun 2018, Reid Kleckner via cfe-commits wrote: Author: rnk Date: Mon Jun 4 18:33:40 2018 New Revision: 333978 URL: http://llvm.org/viewvc/llvm-project?rev=333978&view=rev Log: Reimplement the bittest intrinsic family as builtins with inline asm We need to implement _interlockedbittestandset as a builtin for windows.h, so we might as well do the whole family. It reduces code duplication anyway. Fixes PR33188, a long standing bug in our bittest implementation encountered by Chakra. Added: cfe/trunk/test/CodeGen/bittest-intrin.c Modified: cfe/trunk/include/clang/Basic/Builtins.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Headers/intrin.h cfe/trunk/test/CodeGen/ms-intrinsics-other.c cfe/trunk/test/CodeGen/ms-intrinsics.c Modified: cfe/trunk/include/clang/Basic/Builtins.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=333978&r1=333977&r2=333978&view=diff == --- cfe/trunk/include/clang/Basic/Builtins.def (original) +++ cfe/trunk/include/clang/Basic/Builtins.def Mon Jun 4 18:33:40 2018 @@ -744,6 +744,14 @@ BUILTIN(__builtin_rindex, "c*cC*i", "Fn" LANGBUILTIN(_alloca, "v*z", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__annotation, "wC*.","n", ALL_MS_LANGUAGES) LANGBUILTIN(__assume, "vb", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittest,"UcNiC*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandcomplement, "UcNi*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandreset,"UcNi*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandset, "UcNi*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittest64, "UcWiC*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandcomplement64, "UcWi*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandreset64, "UcWi*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_bittestandset64,"UcWi*Wi", "n", ALL_MS_LANGUAGES) LIBBUILTIN(_byteswap_ushort, "UsUs", "fnc", "stdlib.h", ALL_MS_LANGUAGES) LIBBUILTIN(_byteswap_ulong, "UNiUNi", "fnc", "stdlib.h", ALL_MS_LANGUAGES) LIBBUILTIN(_byteswap_uint64, "ULLiULLi", "fnc", "stdlib.h", ALL_MS_LANGUAGES) @@ -783,7 +791,10 @@ LANGBUILTIN(_InterlockedOr, "NiNiD*Ni" LANGBUILTIN(_InterlockedXor8, "ccD*c", "n", ALL_MS_LANGUAGES) LANGBUILTIN(_InterlockedXor16, "ssD*s", "n", ALL_MS_LANGUAGES) LANGBUILTIN(_InterlockedXor, "NiNiD*Ni","n", ALL_MS_LANGUAGES) -LANGBUILTIN(_interlockedbittestandset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandreset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset, "UcNiD*Ni", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(_interlockedbittestandset64, "UcWiD*Wi", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__noop, "i.", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__popcnt16, "UsUs", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__popcnt, "UiUi", "nc", ALL_MS_LANGUAGES) Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=333978&r1=333977&r2=333978&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Jun 4 18:33:40 2018 @@ -484,6 +484,37 @@ CodeGenFunction::emitBuiltinObjectSize(c return Builder.CreateCall(F, {Ptr, Min, NullIsUnknown}); } +static RValue EmitBitTestIntrinsic(CodeGenFunction &CGF, const CallExpr *E, + char TestAnd, char Size, + bool Locked = false) { + Value *BitBase = CGF.EmitScalarExpr(E->getArg(0)); + Value *BitPos = CGF.EmitScalarExpr(E->getArg(1)); + + // Build the assembly. + SmallString<64> Asm; + raw_svector_ostream AsmOS(Asm); + if (Locked) +AsmOS << "lock "; + AsmOS << "bt"; + if (TestAnd) +AsmOS << TestAnd; + AsmOS << Size << " $2, ($1)\n\tsetc ${0:b}"; + + // Build the constraints. FIXME: We should support immediates when possible. + std::string Constraints = "=r,r,r,~{cc},~{flags},~{memory},~{fpsr}"; + llvm::IntegerType *IntType = llvm::IntegerType::get( + CGF.getLLVMContext(), + CGF.getContext().getTypeSize(E->getArg(1)->getType())); + llvm::Type *IntPtrType = IntType->getPointerTo(); + llvm::FunctionType *FTy = + llvm::FunctionType::get(CGF.Int8Ty, {IntPtrType, IntType}, false); + + llvm::InlineAsm *IA = + llvm::InlineAsm::get(FTy, Asm, Constraints, /*SideEffects=*/true); + CallSite CS = CGF.Builder.CreateCall(IA, {BitBase, BitPos}); + return RValue::get(CS.getInstruction()); +} + // Many of MSVC builtins are on both x64 and ARM; to avoid repeating code, we // handle them here. This doesn't seem thought through wrt non-x86 architectures. I'm not sure if there's any similar suitable instruction to use on ARM/AArch64, but we should
Re: Fix __attribute__((force_align_arg_pointer)) misalignment bug
Hej Henrik, On Thu, 19 Apr 2018, Henrik Gramner via cfe-commits wrote: The force_align_arg_pointer attribute was using a hardcoded 16-byte alignment value which in combination with -mstack-alignment=32 (or larger) would produce a misaligned stack which could result in crashes when accessing stack buffers using aligned AVX load/store instructions. The attached patch fixes the issue by using the "stackrealign" function attribute instead of using a hardcoded 16-byte alignment. Tested on 64-bit Linux and it works as far as I can see, unable to test on anything else though. You need to update the corresponding tests as well, run "ninja check-clang" to see that this change alters the output from test/CodeGen/function-attributes.c, breaking that test. You at least need to update it with how this patch changes the behaviour of the existing tests, but ideally also add a new test case (either in this file or as a completely new file) for the specific usecase that you had in mind (32 byte alignment). For better visibility, I'd also recommend uploading the patch at https://reviews.llvm.org (even though the official guidelines say this is optional). I don't know off-hand who would be best to add as reviewer for it though (I'm not authoritative in this area)... // Martin ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: r330244 - [MinGW] Look for a cross sysroot relative to the clang binary
Hi Douglas, I wasn't able to reproducd the issue myself, but I think I know what the issue was, and I committed a fix attempt. // Martin On Wed, 18 Apr 2018, Martin Storsjö via cfe-commits wrote: Hi Douglas, Yes, I saw it - trying to look into it right now. // Martin On Wed, 18 Apr 2018, douglas.y...@sony.com wrote: Hi Martin, Your commit is causing a few test failures on the PS4 Windows bot, can you take a look? http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16544 Failing Tests (13): Clang :: CodeGenCXX/mingw-w64-exceptions.c Clang :: Driver/clang-translation.c Clang :: Driver/cxa-atexit.cpp Clang :: Driver/default-image-name.c Clang :: Driver/fsjlj-exceptions.c Clang :: Driver/incremental-linker-compatible.c Clang :: Driver/mingw-libgcc.c Clang :: Driver/mingw-msvcrt.c Clang :: Driver/no-integrated-as-win.c Clang :: Driver/pic.c Clang :: Driver/windows-pic.cpp Clang :: Index/index-attrs.c Clang :: Index/index-attrs.cpp Douglas Yung -Original Message- From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Martin Storsjo via cfe-commits Sent: Wednesday, April 18, 2018 1:47 To: cfe-commits@lists.llvm.org Subject: r330244 - [MinGW] Look for a cross sysroot relative to the clang binary Author: mstorsjo Date: Wed Apr 18 01:47:26 2018 New Revision: 330244 URL: http://llvm.org/viewvc/llvm-project?rev=330244&view=rev Log: [MinGW] Look for a cross sysroot relative to the clang binary If found, prefer this over looking for a similar gcc later in the system path. Differential Revision: https://reviews.llvm.org/D45504 Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp cfe/trunk/lib/Driver/ToolChains/MinGW.h Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp URL: http://llvm.org/viewvc/llvm- project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=330244&r1=330243&r2=3302 44&view=diff == --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Wed Apr 18 01:47:26 2018 @@ -275,7 +275,8 @@ void toolchains::MinGW::findGccLibDir() Archs.emplace_back(getTriple().getArchName()); Archs[0] += "-w64-mingw32"; Archs.emplace_back("mingw32"); - Arch = Archs[0].str(); + if (Arch.empty()) +Arch = Archs[0].str(); // lib: Arch Linux, Ubuntu, Windows // lib64: openSUSE Linux for (StringRef CandidateLib : {"lib", "lib64"}) { @@ -302,6 +303,24 @@ llvm::ErrorOr toolchains::M return make_error_code(std::errc::no_such_file_or_directory); } +llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() { + llvm::SmallVector, 2> Subdirs; + Subdirs.emplace_back(getTriple().str()); + Subdirs.emplace_back(getTriple().getArchName()); + Subdirs[1] += "-w64-mingw32"; + Twine ClangRoot = + llvm::sys::path::parent_path(getDriver().getInstalledDir()) + + llvm::sys::path::get_separator(); + for (StringRef CandidateSubdir : Subdirs) { +Twine Subdir = ClangRoot + CandidateSubdir; +if (llvm::sys::fs::is_directory(Subdir)) { + Arch = CandidateSubdir; + return Subdir.str(); +} + } + return make_error_code(std::errc::no_such_file_or_directory); +} + toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) { @@ -309,6 +328,10 @@ toolchains::MinGW::MinGW(const Driver &D if (getDriver().SysRoot.size()) Base = getDriver().SysRoot; + // Look for /../; if found, use /.. as the + // base as it could still be a base for a gcc setup with libgcc. + else if (llvm::ErrorOr TargetSubdir = findClangRelativeSysroot()) +Base = llvm::sys::path::parent_path(TargetSubdir.get()); else if (llvm::ErrorOr GPPName = findGcc()) Base = llvm::sys::path::parent_path( llvm::sys::path::parent_path(GPPName.get())); Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h URL: http://llvm.org/viewvc/llvm- project/cfe/trunk/lib/Driver/ToolChains/MinGW.h?rev=330244&r1=330243&r2=330244 &view=diff == --- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original) +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Wed Apr 18 01:47:26 2018 @@ -96,6 +96,7 @@ private: mutable std::unique_ptr Compiler; void findGccLibDir(); llvm::ErrorOr findGcc(); + llvm::ErrorOr findClangRelativeSysroot(); }; } // end namespace toolchains ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llv
RE: r330244 - [MinGW] Look for a cross sysroot relative to the clang binary
Hi Douglas, Yes, I saw it - trying to look into it right now. // Martin On Wed, 18 Apr 2018, douglas.y...@sony.com wrote: Hi Martin, Your commit is causing a few test failures on the PS4 Windows bot, can you take a look? http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/16544 Failing Tests (13): Clang :: CodeGenCXX/mingw-w64-exceptions.c Clang :: Driver/clang-translation.c Clang :: Driver/cxa-atexit.cpp Clang :: Driver/default-image-name.c Clang :: Driver/fsjlj-exceptions.c Clang :: Driver/incremental-linker-compatible.c Clang :: Driver/mingw-libgcc.c Clang :: Driver/mingw-msvcrt.c Clang :: Driver/no-integrated-as-win.c Clang :: Driver/pic.c Clang :: Driver/windows-pic.cpp Clang :: Index/index-attrs.c Clang :: Index/index-attrs.cpp Douglas Yung -Original Message- From: cfe-commits [mailto:cfe-commits-boun...@lists.llvm.org] On Behalf Of Martin Storsjo via cfe-commits Sent: Wednesday, April 18, 2018 1:47 To: cfe-commits@lists.llvm.org Subject: r330244 - [MinGW] Look for a cross sysroot relative to the clang binary Author: mstorsjo Date: Wed Apr 18 01:47:26 2018 New Revision: 330244 URL: http://llvm.org/viewvc/llvm-project?rev=330244&view=rev Log: [MinGW] Look for a cross sysroot relative to the clang binary If found, prefer this over looking for a similar gcc later in the system path. Differential Revision: https://reviews.llvm.org/D45504 Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp cfe/trunk/lib/Driver/ToolChains/MinGW.h Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp URL: http://llvm.org/viewvc/llvm- project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=330244&r1=330243&r2=3302 44&view=diff == --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Wed Apr 18 01:47:26 2018 @@ -275,7 +275,8 @@ void toolchains::MinGW::findGccLibDir() Archs.emplace_back(getTriple().getArchName()); Archs[0] += "-w64-mingw32"; Archs.emplace_back("mingw32"); - Arch = Archs[0].str(); + if (Arch.empty()) +Arch = Archs[0].str(); // lib: Arch Linux, Ubuntu, Windows // lib64: openSUSE Linux for (StringRef CandidateLib : {"lib", "lib64"}) { @@ -302,6 +303,24 @@ llvm::ErrorOr toolchains::M return make_error_code(std::errc::no_such_file_or_directory); } +llvm::ErrorOr toolchains::MinGW::findClangRelativeSysroot() { + llvm::SmallVector, 2> Subdirs; + Subdirs.emplace_back(getTriple().str()); + Subdirs.emplace_back(getTriple().getArchName()); + Subdirs[1] += "-w64-mingw32"; + Twine ClangRoot = + llvm::sys::path::parent_path(getDriver().getInstalledDir()) + + llvm::sys::path::get_separator(); + for (StringRef CandidateSubdir : Subdirs) { +Twine Subdir = ClangRoot + CandidateSubdir; +if (llvm::sys::fs::is_directory(Subdir)) { + Arch = CandidateSubdir; + return Subdir.str(); +} + } + return make_error_code(std::errc::no_such_file_or_directory); +} + toolchains::MinGW::MinGW(const Driver &D, const llvm::Triple &Triple, const ArgList &Args) : ToolChain(D, Triple, Args), CudaInstallation(D, Triple, Args) { @@ -309,6 +328,10 @@ toolchains::MinGW::MinGW(const Driver &D if (getDriver().SysRoot.size()) Base = getDriver().SysRoot; + // Look for /../; if found, use /.. as the + // base as it could still be a base for a gcc setup with libgcc. + else if (llvm::ErrorOr TargetSubdir = findClangRelativeSysroot()) +Base = llvm::sys::path::parent_path(TargetSubdir.get()); else if (llvm::ErrorOr GPPName = findGcc()) Base = llvm::sys::path::parent_path( llvm::sys::path::parent_path(GPPName.get())); Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.h URL: http://llvm.org/viewvc/llvm- project/cfe/trunk/lib/Driver/ToolChains/MinGW.h?rev=330244&r1=330243&r2=330244 &view=diff == --- cfe/trunk/lib/Driver/ToolChains/MinGW.h (original) +++ cfe/trunk/lib/Driver/ToolChains/MinGW.h Wed Apr 18 01:47:26 2018 @@ -96,6 +96,7 @@ private: mutable std::unique_ptr Compiler; void findGccLibDir(); llvm::ErrorOr findGcc(); + llvm::ErrorOr findClangRelativeSysroot(); }; } // end namespace toolchains ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r319297 - Toolchain: Normalize dwarf, sjlj and seh eh
On Wed, 29 Nov 2017, Martin Storsjö via cfe-commits wrote: On Wed, 29 Nov 2017, Reid Kleckner wrote: On Wed, Nov 29, 2017 at 12:21 PM, Martin Storsjö wrote: On Wed, 29 Nov 2017, Martell Malone via cfe-commits wrote: Thanks for letting me know Reid. I’ll in work and won’t be able to access the repo until lunch time. (~3 hours) Feel free to revert if it is not trivial. The easy fix might be to change to == x86_64 from != x86 For is Windows in the default toolchain. That should restore the old behavior. My suggestion would be to just return None for all architectures for the default windows (msvc) case. We didn't use to set any defines to indicate EH mode there before anyway, so setting it to None should make things behave just as before, right? I did this slightly differently in r319363, but maybe that's silly. My reasoning was that `clang -cc1 -fseh-exceptions -fexceptions` in the MSVC environment should still use __CxxFrameHandler3. -fseh-exceptions indicates what format of unwind information we should use, and we're still using the normal SEH .xdata opcodes. No, I think this change makes sense - I was just about to write a comment pointing out this spot in the code but was waiting for a compile to finish before posting. Alternatively, you could view -fseh-exceptions, -fdwarf-exceptions, and -fsjlj-exceptions as choices of EH personality function, No, I don't think that'd make sense FWIW, another reason I don't think that makes sense, is that making a GNU_CPlusPlus_SEH + MSVC combination probably would require quite a bit more changes as well. When I tested the same in a build with assertions enabled, I didn't get the references to _Unwind_Resume as you did, but the compilation failed on some internal assertion. So making GNU_CPlusPlus_SEH usable with the microsoft C++ ABI would probably require a significant amount of more work, for very little value. // Martin___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r319297 - Toolchain: Normalize dwarf, sjlj and seh eh
On Wed, 29 Nov 2017, Reid Kleckner wrote: On Wed, Nov 29, 2017 at 12:21 PM, Martin Storsjö wrote: On Wed, 29 Nov 2017, Martell Malone via cfe-commits wrote: Thanks for letting me know Reid. I’ll in work and won’t be able to access the repo until lunch time. (~3 hours) Feel free to revert if it is not trivial. The easy fix might be to change to == x86_64 from != x86 For is Windows in the default toolchain. That should restore the old behavior. My suggestion would be to just return None for all architectures for the default windows (msvc) case. We didn't use to set any defines to indicate EH mode there before anyway, so setting it to None should make things behave just as before, right? I did this slightly differently in r319363, but maybe that's silly. My reasoning was that `clang -cc1 -fseh-exceptions -fexceptions` in the MSVC environment should still use __CxxFrameHandler3. -fseh-exceptions indicates what format of unwind information we should use, and we're still using the normal SEH .xdata opcodes. No, I think this change makes sense - I was just about to write a comment pointing out this spot in the code but was waiting for a compile to finish before posting. Alternatively, you could view -fseh-exceptions, -fdwarf-exceptions, and -fsjlj-exceptions as choices of EH personality function, No, I don't think that'd make sense in which case, my change is wrong, and we should do what you guys were suggesting and stop passing this from the driver. Hard to say. My point was that for the MSVC mode, this worked fine before since this was the default behaviour - avoiding passing any option (i.e. having that function return None) should be a safe way to keep things working as it did before. But then it would break again if -fseh-exceptions were passed, which I would expect to be a no-op in such a configuration. My remaining concern is mostly about why we still need the workaround for x86 in the function getting the default (returning None instead of WinEH for that case). But as long as this works and the rest of this change can settle, we can look at that later if any further change is warranted at all. // Martin___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r319297 - Toolchain: Normalize dwarf, sjlj and seh eh
On Wed, 29 Nov 2017, Martell Malone via cfe-commits wrote: Thanks for letting me know Reid. I’ll in work and won’t be able to access the repo until lunch time. (~3 hours) Feel free to revert if it is not trivial. The easy fix might be to change to == x86_64 from != x86 For is Windows in the default toolchain. That should restore the old behavior. My suggestion would be to just return None for all architectures for the default windows (msvc) case. We didn't use to set any defines to indicate EH mode there before anyway, so setting it to None should make things behave just as before, right? // Martin___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libunwind] r316745 - Express Registers_*::lastDwarfReg using _LIBUNWIND_HIGHEST_DWARF_REGISTER
On Fri, 27 Oct 2017, John Baldwin wrote: On 10/27/17 8:59 AM, Martin Storsjo via cfe-commits wrote: Author: mstorsjo Date: Fri Oct 27 00:59:01 2017 New Revision: 316745 URL: http://llvm.org/viewvc/llvm-project?rev=316745&view=rev Log: Express Registers_*::lastDwarfReg using _LIBUNWIND_HIGHEST_DWARF_REGISTER This avoids having to keep the same information duplicated in multiple places. Adjust _LIBUNWIND_HIGHEST_DWARF_REGISTER to actually have the value of the highest used register and only use the value _LIBUNWIND_HIGHEST_DWARF_REGISTER + 1 (kMaxRegisterNumber + 1) for allocating the savedRegisters array. Sorry I didn't realize it during the review, but I've just realized why using HIGHEST_DWARF_REGISTER is not correct in the various Register classes. If you are building without _LIBUNWIND_IS_NATIVE_ONLY defined, then you will end up with all of the Register classes returning the same value (119 from the end of __libunwind_config.h) instead of the architecture-specific value. This is a change in behavior, so the Registers.hpp portion of this change should perhaps be reverted. I did think of it at some point, but wasn't aware if that setup actually was too relevant. In any case - I can think of an even better way of doing this, without having to duplicate the definitions, while still keeping the individual Registers classes returning the right values - I'll post a patch in a little moment. // Martin ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D25576: Add 64-bit MS _Interlocked functions as builtins again
mstorsjo added a comment. > (should they be also on AArch64? I had problems with testing it for AArch64, > so I left it) Technically, I think they should be on AArch64 as well. But clang/LLVM probably doesn't support AArch64/Windows yet (I guess?), so testing it probably is impossible. When/if support later gets added for that, it's easy to complete these. AArch64/Windows in general isn't available yet; the Windows 10 SDK contains some arm64 tools, and the Windows 10 SDK and MSVC 2015 headers have got ifdefs using _M_ARM64, but other than that, there's no public version of Visual Studio even having a compiler for it. So until then, and when someone tries to get clang/LLVM to support it, it's probably ok to just ignore it. https://reviews.llvm.org/D25576 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24986: [MS] Implement __iso_volatile loads/stores as builtins
This revision was automatically updated to reflect the committed changes. Closed by commit rL282900: [MS] Implement __iso_volatile loads/stores as builtins (authored by mstorsjo). Changed prior to commit: https://reviews.llvm.org/D24986?vs=72988&id=73113#toc Repository: rL LLVM https://reviews.llvm.org/D24986 Files: cfe/trunk/include/clang/Basic/BuiltinsARM.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/test/CodeGen/ms-volatile-arm.c Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def === --- cfe/trunk/include/clang/Basic/BuiltinsARM.def +++ cfe/trunk/include/clang/Basic/BuiltinsARM.def @@ -115,6 +115,14 @@ LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load8, "ccCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load16, "ssCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load32, "iiCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load64, "LLiLLiCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store8, "vcD*c", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store32, "viD*i", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store64, "vLLiD*LLi", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES) LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) Index: cfe/trunk/test/CodeGen/ms-volatile-arm.c === --- cfe/trunk/test/CodeGen/ms-volatile-arm.c +++ cfe/trunk/test/CodeGen/ms-volatile-arm.c @@ -0,0 +1,13 @@ +// REQUIRES: arm-registered-target +// RUN: %clang_cc1 -triple thumbv7-win32 -emit-llvm -fms-extensions -fms-volatile -o - < %s | FileCheck %s + +void test1(int volatile *p, int v) { + __iso_volatile_store32(p, v); + // CHECK-LABEL: @test1 + // CHECK: store volatile {{.*}}, {{.*}} +} +int test2(const int volatile *p) { + return __iso_volatile_load32(p); + // CHECK-LABEL: @test2 + // CHECK: load volatile {{.*}} +} Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp === --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -4279,6 +4279,41 @@ return Builder.CreateCall(F, {StoreVal, StoreAddr}, "strex"); } + switch (BuiltinID) { + case ARM::BI__iso_volatile_load8: + case ARM::BI__iso_volatile_load16: + case ARM::BI__iso_volatile_load32: + case ARM::BI__iso_volatile_load64: { +Value *Ptr = EmitScalarExpr(E->getArg(0)); +QualType ElTy = E->getArg(0)->getType()->getPointeeType(); +CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy); +llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(), + LoadSize.getQuantity() * 8); +Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo()); +llvm::LoadInst *Load = + Builder.CreateAlignedLoad(Ptr, LoadSize); +Load->setVolatile(true); +return Load; + } + case ARM::BI__iso_volatile_store8: + case ARM::BI__iso_volatile_store16: + case ARM::BI__iso_volatile_store32: + case ARM::BI__iso_volatile_store64: { +Value *Ptr = EmitScalarExpr(E->getArg(0)); +Value *Value = EmitScalarExpr(E->getArg(1)); +QualType ElTy = E->getArg(0)->getType()->getPointeeType(); +CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy); +llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(), + StoreSize.getQuantity() * 8); +Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo()); +llvm::StoreInst *Store = + Builder.CreateAlignedStore(Value, Ptr, + StoreSize); +Store->setVolatile(true); +return Store; + } + } + if (BuiltinID == ARM::BI__builtin_arm_clrex) { Function *F = CGM.getIntrinsic(Intrinsic::arm_clrex); return Builder.CreateCall(F); Index: cfe/trunk/include/clang/Basic/BuiltinsARM.def === --- cfe/trunk/include/clang/Basic/BuiltinsARM.def +++ cfe/trunk/include/clang/Basic/BuiltinsARM.def @@ -115,6 +115,14 @@ LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load8, "ccCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load16, "ssCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load32, "iiCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load64, "LLiLLiCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store8, "vcD*c", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n",
[PATCH] D24986: [MS] Implement __iso_volatile loads/stores as builtins
mstorsjo added inline comments. > majnemer wrote in ms-volatile-arm.c:2 > You don't need -fms-volatile. Well, originally, the point was to clarify that these volatile stores end up without atomic semantics, regardless of whether -volatile:ms has been specified. The original version of this patch (with an inline implementation in intrin.h, just using a normal volatile pointer) wouldn't pass this test, but would pass if I remove this option. But if you prefer, I can leave it out. https://reviews.llvm.org/D24986 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] [Updated, 56 lines] D24986: [MS] Implement __iso_volatile loads/stores as builtins
mstorsjo updated this revision to Diff 72988. mstorsjo added a comment. Implemented using `CreateAlignedStore` and `CreateAlignedLoad` instead. I'm less confident in what this actually does though - e.g. is the `CreateBitCast` part necessary at all? I just based this on code I found in the same file calling `CreateAlignedStore`. (If I comment out the `CreateBitCast` line, it still works just as fine, at least for the unit test - but what about actual use?) Compared to the previous patch, the generated IR now lacks a `!tbaa !3` marker at the end - is that an issue? https://reviews.llvm.org/D24986 Files: include/clang/Basic/BuiltinsARM.def lib/CodeGen/CGBuiltin.cpp test/CodeGen/ms-volatile-arm.c Index: test/CodeGen/ms-volatile-arm.c === --- /dev/null +++ test/CodeGen/ms-volatile-arm.c @@ -0,0 +1,13 @@ +// REQUIRES: arm-registered-target +// RUN: %clang_cc1 -triple thumbv7-win32 -emit-llvm -fms-extensions -fms-volatile -o - < %s | FileCheck %s + +void test1(int volatile *p, int v) { + __iso_volatile_store32(p, v); + // CHECK-LABEL: @test1 + // CHECK: store volatile {{.*}}, {{.*}} +} +int test2(const int volatile *p) { + return __iso_volatile_load32(p); + // CHECK-LABEL: @test2 + // CHECK: load volatile {{.*}} +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -4279,6 +4279,41 @@ return Builder.CreateCall(F, {StoreVal, StoreAddr}, "strex"); } + switch (BuiltinID) { + case ARM::BI__iso_volatile_load8: + case ARM::BI__iso_volatile_load16: + case ARM::BI__iso_volatile_load32: + case ARM::BI__iso_volatile_load64: { +Value *Ptr = EmitScalarExpr(E->getArg(0)); +QualType ElTy = E->getArg(0)->getType()->getPointeeType(); +CharUnits LoadSize = getContext().getTypeSizeInChars(ElTy); +llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(), + LoadSize.getQuantity() * 8); +Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo()); +llvm::LoadInst *Load = + Builder.CreateAlignedLoad(Ptr, LoadSize); +Load->setVolatile(true); +return Load; + } + case ARM::BI__iso_volatile_store8: + case ARM::BI__iso_volatile_store16: + case ARM::BI__iso_volatile_store32: + case ARM::BI__iso_volatile_store64: { +Value *Ptr = EmitScalarExpr(E->getArg(0)); +Value *Value = EmitScalarExpr(E->getArg(1)); +QualType ElTy = E->getArg(0)->getType()->getPointeeType(); +CharUnits StoreSize = getContext().getTypeSizeInChars(ElTy); +llvm::Type *ITy = llvm::IntegerType::get(getLLVMContext(), + StoreSize.getQuantity() * 8); +Ptr = Builder.CreateBitCast(Ptr, ITy->getPointerTo()); +llvm::StoreInst *Store = + Builder.CreateAlignedStore(Value, Ptr, + StoreSize); +Store->setVolatile(true); +return Store; + } + } + if (BuiltinID == ARM::BI__builtin_arm_clrex) { Function *F = CGM.getIntrinsic(Intrinsic::arm_clrex); return Builder.CreateCall(F); Index: include/clang/Basic/BuiltinsARM.def === --- include/clang/Basic/BuiltinsARM.def +++ include/clang/Basic/BuiltinsARM.def @@ -115,6 +115,14 @@ LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load8, "ccCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load16, "ssCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load32, "iiCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load64, "LLiLLiCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store8, "vcD*c", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store16, "vsD*s", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store32, "viD*i", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_store64, "vLLiD*LLi", "n", ALL_MS_LANGUAGES) LANGBUILTIN(__ldrexd, "WiWiCD*", "", ALL_MS_LANGUAGES) LANGBUILTIN(_MoveFromCoprocessor, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) LANGBUILTIN(_MoveFromCoprocessor2, "UiIUiIUiIUiIUiIUi", "", ALL_MS_LANGUAGES) Index: test/CodeGen/ms-volatile-arm.c === --- /dev/null +++ test/CodeGen/ms-volatile-arm.c @@ -0,0 +1,13 @@ +// REQUIRES: arm-registered-target +// RUN: %clang_cc1 -triple thumbv7-win32 -emit-llvm -fms-extensions -fms-volatile -o - < %s | FileCheck %s + +void test1(int volatile *p, int v) { + __iso_volatile_store32(p, v); + // CHECK-LABEL: @test1 + // CHECK: store volatile {{.*}}, {{.*}} +} +int test2(const int volatile *p) { + return __iso_volatile_load32(p); + // CHECK-LABEL: @test2 + // CHECK: load volatile {{.*}} +} Index: lib/CodeGen/CGBuiltin.cpp =
Re: [PATCH] D24986: [MS] Implement __iso_volatile loads/stores as builtins
mstorsjo retitled this revision from "Headers: Add iso_volatile load/store intrinsics" to "[MS] Implement __iso_volatile loads/stores as builtins". mstorsjo updated the summary for this revision. mstorsjo updated this revision to Diff 72782. mstorsjo added a comment. Changed to implement it as builtins, as requested. I had to put this at the bottom in EmitBuiltinExpr (which returns RValues) instead of in EmitARMBuiltinExpr (which returns Value*), since the returned Value* for stores is nullptr. A nullptr return value from EmitTargetBuiltinExpr indicates that it wasn't handled, this triggered errors about the store builtins being unsupported. https://reviews.llvm.org/D24986 Files: include/clang/Basic/BuiltinsARM.def lib/CodeGen/CGBuiltin.cpp test/CodeGen/ms-volatile-arm.c Index: test/CodeGen/ms-volatile-arm.c === --- /dev/null +++ test/CodeGen/ms-volatile-arm.c @@ -0,0 +1,13 @@ +// REQUIRES: arm-registered-target +// RUN: %clang_cc1 -triple thumbv7-win32 -emit-llvm -fms-extensions -fms-volatile -o - < %s | FileCheck %s + +void test1(int volatile *p, int v) { + __iso_volatile_store32(p, v); + // CHECK-LABEL: @test1 + // CHECK: store volatile {{.*}}, {{.*}} +} +int test2(const int volatile *p) { + return __iso_volatile_load32(p); + // CHECK-LABEL: @test2 + // CHECK: load volatile {{.*}} +} Index: lib/CodeGen/CGBuiltin.cpp === --- lib/CodeGen/CGBuiltin.cpp +++ lib/CodeGen/CGBuiltin.cpp @@ -134,6 +134,36 @@ return CGF.EmitLoadOfScalar(LV, E->getExprLoc()); } +static Value *EmitVolatileStore(CodeGenFunction &CGF, const CallExpr *E) { + Value *Address = CGF.EmitScalarExpr(E->getArg(0)); + Value *Val = CGF.EmitScalarExpr(E->getArg(1)); + + LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getArg(1)->getType()); + // Call the full version of EmitStoreOfScalar directly, to override the volatile + // flag without actually setting volatile in the type. This avoids + // LValueIsSuitableForInlineAtomic picking it up and transforming it into an + // atomic store. + CGF.EmitStoreOfScalar(Val, LV.getAddress(), true, LV.getType(), +LV.getAlignmentSource(), LV.getTBAAInfo(), false, +LV.getTBAABaseType(), LV.getTBAAOffset(), +LV.isNontemporal()); + return nullptr; +} + +static Value *EmitVolatileLoad(CodeGenFunction &CGF, const CallExpr *E) { + Value *Address = CGF.EmitScalarExpr(E->getArg(0)); + + LValue LV = CGF.MakeNaturalAlignAddrLValue(Address, E->getType()); + // Call the full version of EmitLoadOfScalar directly, to override the volatile + // flag without actually setting volatile in the type. This avoids + // LValueIsSuitableForInlineAtomic picking it up and transforming it into an + // atomic load. + return CGF.EmitLoadOfScalar(LV.getAddress(), true, LV.getType(), + E->getExprLoc(), LV.getAlignmentSource(), + LV.getTBAAInfo(), LV.getTBAABaseType(), + LV.getTBAAOffset(), LV.isNontemporal()); +} + static RValue EmitBinaryAtomic(CodeGenFunction &CGF, llvm::AtomicRMWInst::BinOp Kind, const CallExpr *E) { @@ -2558,6 +2588,33 @@ return RValue::get(V); } + switch (getTarget().getTriple().getArch()) { + case llvm::Triple::arm: + case llvm::Triple::armeb: + case llvm::Triple::thumb: + case llvm::Triple::thumbeb: +switch (BuiltinID) { +case ARM::BI__iso_volatile_load8: +case ARM::BI__iso_volatile_load16: +case ARM::BI__iso_volatile_load32: +case ARM::BI__iso_volatile_load64: + return RValue::get(EmitVolatileLoad(*this, E)); +case ARM::BI__iso_volatile_store8: +case ARM::BI__iso_volatile_store16: +case ARM::BI__iso_volatile_store32: +case ARM::BI__iso_volatile_store64: + // EmitVolatileStore returns nullptr, but we want to + // return that RValue here. If handled via EmitTargetBuiltinExpr + // below, the returned Value *V will be nullptr, and we will + // continue on to declaring the builtin unsupported below, even + // though it was handled correctly. + return RValue::get(EmitVolatileStore(*this, E)); +} +break; + default: +break; + } + // See if we have a target specific builtin that needs to be lowered. if (Value *V = EmitTargetBuiltinExpr(BuiltinID, E)) return RValue::get(V); Index: include/clang/Basic/BuiltinsARM.def === --- include/clang/Basic/BuiltinsARM.def +++ include/clang/Basic/BuiltinsARM.def @@ -115,6 +115,14 @@ LANGBUILTIN(__dmb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__dsb, "vUi", "nc", ALL_MS_LANGUAGES) LANGBUILTIN(__isb, "vUi", "nc", ALL_MS_LANGUAGES) +LANGBUILTIN(__iso_volatile_load8, "ccCD*", "n", ALL_MS_LANGUAGES) +LANGBUILTIN(__
[PATCH] D24986: Headers: Add iso_volatile load/store intrinsics
mstorsjo created this revision. mstorsjo added a reviewer: majnemer. mstorsjo added a subscriber: cfe-commits. Herald added a subscriber: aemerson. This implements what is missing for PR30394, making it possible to compile C++ for ARM in MSVC mode with MSVC headers. https://reviews.llvm.org/D24986 Files: lib/Headers/intrin.h Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -1248,6 +1248,42 @@ } #endif +#if defined(__arm__) || defined(__aarch64__) +static __inline__ char __DEFAULT_FN_ATTRS +__iso_volatile_load8(const char volatile *_Src) { + return *_Src; +} +static __inline__ short __DEFAULT_FN_ATTRS +__iso_volatile_load16(const short volatile *_Src) { + return *_Src; +} +static __inline__ int __DEFAULT_FN_ATTRS +__iso_volatile_load32(const int volatile *_Src) { + return *_Src; +} +static __inline__ __int64 __DEFAULT_FN_ATTRS +__iso_volatile_load64(const __int64 volatile *_Src) { + return *_Src; +} + +static __inline__ void __DEFAULT_FN_ATTRS +__iso_volatile_store8(char volatile *_Dest, char _Value) { + *_Dest = _Value; +} +static __inline__ void __DEFAULT_FN_ATTRS +__iso_volatile_store16(short volatile *_Dest, short _Value) { + *_Dest = _Value; +} +static __inline__ void __DEFAULT_FN_ATTRS +__iso_volatile_store32(int volatile *_Dest, int _Value) { + *_Dest = _Value; +} +static __inline__ void __DEFAULT_FN_ATTRS +__iso_volatile_store64(__int64 volatile *_Dest, __int64 _Value) { + *_Dest = _Value; +} +#endif + #ifdef __cplusplus } #endif Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -1248,6 +1248,42 @@ } #endif +#if defined(__arm__) || defined(__aarch64__) +static __inline__ char __DEFAULT_FN_ATTRS +__iso_volatile_load8(const char volatile *_Src) { + return *_Src; +} +static __inline__ short __DEFAULT_FN_ATTRS +__iso_volatile_load16(const short volatile *_Src) { + return *_Src; +} +static __inline__ int __DEFAULT_FN_ATTRS +__iso_volatile_load32(const int volatile *_Src) { + return *_Src; +} +static __inline__ __int64 __DEFAULT_FN_ATTRS +__iso_volatile_load64(const __int64 volatile *_Src) { + return *_Src; +} + +static __inline__ void __DEFAULT_FN_ATTRS +__iso_volatile_store8(char volatile *_Dest, char _Value) { + *_Dest = _Value; +} +static __inline__ void __DEFAULT_FN_ATTRS +__iso_volatile_store16(short volatile *_Dest, short _Value) { + *_Dest = _Value; +} +static __inline__ void __DEFAULT_FN_ATTRS +__iso_volatile_store32(int volatile *_Dest, int _Value) { + *_Dest = _Value; +} +static __inline__ void __DEFAULT_FN_ATTRS +__iso_volatile_store64(__int64 volatile *_Dest, __int64 _Value) { + *_Dest = _Value; +} +#endif + #ifdef __cplusplus } #endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics
mstorsjo added a comment. Ping, can someone commit this one now? https://reviews.llvm.org/D24609 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics
mstorsjo added a comment. Can someone commit this patch now after it has been rebased? https://reviews.llvm.org/D24609 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics
mstorsjo updated the summary for this revision. mstorsjo updated this revision to Diff 72025. mstorsjo added a comment. Rebased on top of the latest master https://reviews.llvm.org/D24609 Files: lib/Headers/intrin.h Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -490,6 +490,23 @@ long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_SEQ_CST); return (_PrevVal >> _BitPos) & 1; } +#if defined(__arm__) || defined(__aarch64__) +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) { + long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_ACQUIRE); + return (_PrevVal >> _BitPos) & 1; +} +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_interlockedbittestandset_nf(long volatile *_BitBase, long _BitPos) { + long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_RELAXED); + return (_PrevVal >> _BitPos) & 1; +} +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_interlockedbittestandset_rel(long volatile *_BitBase, long _BitPos) { + long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_RELEASE); + return (_PrevVal >> _BitPos) & 1; +} +#endif #ifdef __x86_64__ static __inline__ unsigned char __DEFAULT_FN_ATTRS _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask) { @@ -533,64 +550,521 @@ __atomic_fetch_or(_BitBase, 1ll << _BitPos, __ATOMIC_SEQ_CST); return (_PrevVal >> _BitPos) & 1; } +#endif /**\ |* Interlocked Exchange Add \**/ +#if defined(__arm__) || defined(__aarch64__) +static __inline__ char __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd8_acq(char volatile *_Addend, char _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); +} +static __inline__ char __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd8_nf(char volatile *_Addend, char _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ char __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd8_rel(char volatile *_Addend, char _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ short __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd16_acq(short volatile *_Addend, short _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); +} +static __inline__ short __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd16_nf(short volatile *_Addend, short _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ short __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd16_rel(short volatile *_Addend, short _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELEASE); +} +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd_acq(long volatile *_Addend, long _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); +} +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd_nf(long volatile *_Addend, long _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELEASE); +} +#endif +#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) static __inline__ __int64 __DEFAULT_FN_ATTRS _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value) { return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); } +#endif +#if defined(__arm__) || defined(__aarch64__) +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, __int64 _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); +} +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd64_nf(__int64 volatile *_Addend, __int64 _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd64_rel(__int64 volatile *_Addend, __int64 _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELEASE); +} +#endif /**\ |* Interlocked Exchange Sub \**/ +#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) static __inline__ __int64 __DEFAULT_FN_ATTRS _InterlockedExchangeSub64(__int64 volatile *_Subend, __int64 _Value) { return __atomic_fetch_sub(_Subend, _Value, __ATOMIC_SEQ_CST); } +#endif /**\ |* Interlocked Increment \**/ +#if defined(__ar
Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics
mstorsjo added a comment. Thanks! Can you/someone commit it? https://reviews.llvm.org/D24609 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics
mstorsjo added inline comments. Comment at: lib/Headers/intrin.h:504 @@ +503,3 @@ +_interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) { + long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_ACQUIRE); + return (_PrevVal >> _BitPos) & 1; compnerd wrote: > mstorsjo wrote: > > compnerd wrote: > > > Perhaps we should add static asserts that _BitPos is within limits for > > > the signed shift. > > Sure, although I guess that also goes for the existing inline functions as > > well? > > > > Which kind of assert would be suitable for that here? As far as I see, > > static_assert is C++ only, while this header also can be used from C. > > > > If I try to add _Static_assert, which is usable in C, I get the following > > error when compiling: > > > > intrin.h:499:18: error: > > static_assert expression is not an integral constant expression > > _Static_assert(_BitPos < 32, "_BitPos out of range"); > > > > This even when I don't actually use the inline function anywhere, just > > including intrin.h. > Yeah, we would have to use `_Static_assert`, but that requires C11. It is > possible to emulate it, but probably not worth the effort. I am worried > though that we could introduce undefined behavior with an incorrect parameter. Sure, there's probably such a risk. But this issue already exists - an almost identical _interlockedbittestandset function already exists in the header - I'm just adding new copies of it with different atomic semantics (__ATOMIC_ACQUIRE etc). So I'd ask if we can deal with that issue separately from this patch. https://reviews.llvm.org/D24609 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D24609: [ARM] Add missing Interlocked intrinsics
mstorsjo added inline comments. Comment at: lib/Headers/intrin.h:504 @@ +503,3 @@ +_interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) { + long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_ACQUIRE); + return (_PrevVal >> _BitPos) & 1; compnerd wrote: > Perhaps we should add static asserts that _BitPos is within limits for the > signed shift. Sure, although I guess that also goes for the existing inline functions as well? Which kind of assert would be suitable for that here? As far as I see, static_assert is C++ only, while this header also can be used from C. If I try to add _Static_assert, which is usable in C, I get the following error when compiling: intrin.h:499:18: error: static_assert expression is not an integral constant expression _Static_assert(_BitPos < 32, "_BitPos out of range"); This even when I don't actually use the inline function anywhere, just including intrin.h. Comment at: lib/Headers/intrin.h:517 @@ -501,1 +516,3 @@ +} +#endif #ifdef __x86_64__ compnerd wrote: > Are the names supposed to be all lower case? Yes, these ones (for some reason) are all lower case: https://msdn.microsoft.com/en-us/library/646k06sz.aspx https://reviews.llvm.org/D24609 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D24609: [ARM] Add missing Interlocked intrinsics
mstorsjo created this revision. mstorsjo added a reviewer: compnerd. mstorsjo added a subscriber: cfe-commits. Herald added subscribers: samparker, rengolin, aemerson. On ARM, there are multiple versions of each of the intrinsics, with acquire/relaxed/release barrier semantics. The 64 bit versions that so far were within "ifdef __x86_64__" also are fit for arm - I think the reason why they were in ifdefs is that winnt.h have got inline versions of them for, within ifdef _M_IX86. The versions without a width suffix (32 bit) are currently provided as builtins instead of as inline functions here. The _acq/_nf/_rel suffixed ones of those are provided as inline functions here, since they should only be available on certain archs (arm/aarch64). This is necessary in order to compile C++ code for ARM in MSVC mode. https://reviews.llvm.org/D24609 Files: lib/Headers/intrin.h Index: lib/Headers/intrin.h === --- lib/Headers/intrin.h +++ lib/Headers/intrin.h @@ -498,6 +498,23 @@ long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_SEQ_CST); return (_PrevVal >> _BitPos) & 1; } +#if defined(__arm__) || defined(__aarch64__) +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_interlockedbittestandset_acq(long volatile *_BitBase, long _BitPos) { + long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_ACQUIRE); + return (_PrevVal >> _BitPos) & 1; +} +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_interlockedbittestandset_nf(long volatile *_BitBase, long _BitPos) { + long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_RELAXED); + return (_PrevVal >> _BitPos) & 1; +} +static __inline__ unsigned char __DEFAULT_FN_ATTRS +_interlockedbittestandset_rel(long volatile *_BitBase, long _BitPos) { + long _PrevVal = __atomic_fetch_or(_BitBase, 1l << _BitPos, __ATOMIC_RELEASE); + return (_PrevVal >> _BitPos) & 1; +} +#endif #ifdef __x86_64__ static __inline__ unsigned char __DEFAULT_FN_ATTRS _BitScanForward64(unsigned long *_Index, unsigned __int64 _Mask) { @@ -554,16 +571,70 @@ _InterlockedExchangeAdd8(char volatile *_Addend, char _Value) { return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); } +#if defined(__arm__) || defined(__aarch64__) +static __inline__ char __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd8_acq(char volatile *_Addend, char _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); +} +static __inline__ char __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd8_nf(char volatile *_Addend, char _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ char __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd8_rel(char volatile *_Addend, char _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +#endif static __inline__ short __DEFAULT_FN_ATTRS _InterlockedExchangeAdd16(short volatile *_Addend, short _Value) { return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); } -#ifdef __x86_64__ +#if defined(__arm__) || defined(__aarch64__) +static __inline__ short __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd16_acq(short volatile *_Addend, short _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); +} +static __inline__ short __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd16_nf(short volatile *_Addend, short _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ short __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd16_rel(short volatile *_Addend, short _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELEASE); +} +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd_acq(long volatile *_Addend, long _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); +} +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd_nf(long volatile *_Addend, long _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ long __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd_rel(long volatile *_Addend, long _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELEASE); +} +#endif +#if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) static __inline__ __int64 __DEFAULT_FN_ATTRS _InterlockedExchangeAdd64(__int64 volatile *_Addend, __int64 _Value) { return __atomic_fetch_add(_Addend, _Value, __ATOMIC_SEQ_CST); } #endif +#if defined(__arm__) || defined(__aarch64__) +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd64_acq(__int64 volatile *_Addend, __int64 _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_ACQUIRE); +} +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd64_nf(__int64 volatile *_Addend, __int64 _Value) { + return __atomic_fetch_add(_Addend, _Value, __ATOMIC_RELAXED); +} +static __inline__ __int64 __DEFAULT_FN_ATTRS +_InterlockedExchangeAdd64_rel(__int64 volatile *_Addend, __int64 _Va
Re: [PATCH] D22774: [MSVC] Add ARM support to intrin.h for MSVC compatibility
mstorsjo added a comment. Can someone commit this for me? https://reviews.llvm.org/D22774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22774: [MSVC] Add ARM support to intrin.h for MSVC compatibility
mstorsjo added a comment. In https://reviews.llvm.org/D22774#507014, @compnerd wrote: > Why `include_next` the header if not on Windows? Mostly because intrin.h uses the same logic. Normally, there's probably no such system header in other SDKs, but say if you happen to have a custom one named like that (on a non-windows platform unaware that windows happens to have a system header named like that) and clang's builtin header gets picked first, include the next one in the include directory chain instead - i.e. pretend like this one doesn't exist. (That is, either pick the one you want, or error out saying it isn't found.) I don't mind particularly much though, I just picked this logic since intrin.h was using it as well. Just having the header be `#ifdef _MSC_VER {content} #endif`, or `#ifndef _MSC_VER #error #else {content} #endif` also would be fine for me. https://reviews.llvm.org/D22774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22774: [MSVC] Add ARM support to intrin.h for MSVC compatibility
mstorsjo added a comment. Ping @compnerd https://reviews.llvm.org/D22774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22774: [MSVC] Add ARM support to intrin.h for MSVC compatibility
mstorsjo added a comment. Ping - any reply from @compnerd? In any case, feel free to formulate the ifdefs whichever way you want on commit as well (since I don't have commit access), as long as the included test passes. https://reviews.llvm.org/D22774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D22774: [MSVC] Add ARM support to intrin.h for MSVC compatibility
mstorsjo added inline comments. Comment at: lib/Headers/armintr.h:26 @@ +25,3 @@ +#ifndef _MSC_VER +#include_next +#else compnerd wrote: > Hmm, why not do __has_header instead? armv7-windows-itanium won't define > `_MSC_VER` but you may have the header from the SDK. Hmm, so you mean like this? ``` #if __has_include_next() #include_next #else // Normal file content typedef enum ... ``` That would cause use in armv7-windows-msvc mode to use the SDK's armintr.h instead of ours - which as far as I know also is fine. (The issue I'm mainly fixing is that including `` is expected to bring in this, but currently it doesn't.) I'm not sure I follow your argument completely though - armv7-windows-itanium doesn't define `_MSC_VER`, and thus would already try to include the next armintr.h, which would be picked up from the SDK if it exists there. https://reviews.llvm.org/D22774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits