r330310 - OpenBSD add C++ runtime in a driver's standpoint
Author: dberris Date: Wed Apr 18 23:55:30 2018 New Revision: 330310 URL: http://llvm.org/viewvc/llvm-project?rev=330310&view=rev Log: OpenBSD add C++ runtime in a driver's standpoint Summary: - Since 6.2 release, on supporters platforms clang is shipped with both libcxx and libcxxabi. Reviewers: dberris, alekseyshl, EricWF Reviewed By: dberris Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D45662 Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp cfe/trunk/lib/Driver/ToolChains/OpenBSD.h Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp?rev=330310&r1=330309&r2=330310&view=diff == --- cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.cpp Wed Apr 18 23:55:30 2018 @@ -259,6 +259,14 @@ OpenBSD::OpenBSD(const Driver &D, const getFilePaths().push_back("/usr/lib"); } +void OpenBSD::AddCXXStdlibLibArgs(const ArgList &Args, + ArgStringList &CmdArgs) const { + bool Profiling = Args.hasArg(options::OPT_pg); + + CmdArgs.push_back(Profiling ? "-lc++_p" : "-lc++"); + CmdArgs.push_back(Profiling ? "-lc++abi_p" : "-lc++abi"); +} + Tool *OpenBSD::buildAssembler() const { return new tools::openbsd::Assembler(*this); } Modified: cfe/trunk/lib/Driver/ToolChains/OpenBSD.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/OpenBSD.h?rev=330310&r1=330309&r2=330310&view=diff == --- cfe/trunk/lib/Driver/ToolChains/OpenBSD.h (original) +++ cfe/trunk/lib/Driver/ToolChains/OpenBSD.h Wed Apr 18 23:55:30 2018 @@ -58,6 +58,8 @@ public: bool IsMathErrnoDefault() const override { return false; } bool IsObjCNonFragileABIDefault() const override { return true; } bool isPIEDefault() const override { return true; } + void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, + llvm::opt::ArgStringList &CmdArgs) const override; unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override { return 2; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45152: [MinGW] Add option for disabling looking for a mingw gcc in PATH
mstorsjo abandoned this revision. mstorsjo added a comment. https://reviews.llvm.org/D45504 fixed the same issue in a better way. Repository: rC Clang https://reviews.llvm.org/D45152 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D42922: [CUDA] Register relocatable GPU binaries
Hahnfeld added a comment. Ping https://reviews.llvm.org/D42922 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang-tools-extra] r330245 - [clang-tidy] Fix clang-tidy doesn't read .clangtidy configuration file.
Hi, On 04/18/2018 10:54 AM, Haojian Wu via cfe-commits wrote: Author: hokein Date: Wed Apr 18 01:54:28 2018 New Revision: 330245 URL: http://llvm.org/viewvc/llvm-project?rev=330245&view=rev Log: [clang-tidy] Fix clang-tidy doesn't read .clangtidy configuration file. Summary: Fix https://bugs.llvm.org/show_bug.cgi?id=34900. Reviewers: alexfh Reviewed By: alexfh Subscribers: JonasToth, klimek, xazax.hun, cfe-commits Differential Revision: https://reviews.llvm.org/D45697 Added: clang-tools-extra/trunk/test/clang-tidy/read_file_config.cpp Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp?rev=330245&r1=330244&r2=330245&view=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.cpp Wed Apr 18 01:54:28 2018 @@ -204,9 +204,12 @@ ConfigOptionsProvider::getRawOptions(llv FileOptionsProvider::FileOptionsProvider( const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &DefaultOptions, -const ClangTidyOptions &OverrideOptions) +const ClangTidyOptions &OverrideOptions, +llvm::IntrusiveRefCntPtr VFS) : DefaultOptionsProvider(GlobalOptions, DefaultOptions), - OverrideOptions(OverrideOptions) { + OverrideOptions(OverrideOptions), FS(std::move(VFS)) { + if (!FS) +FS = vfs::getRealFileSystem(); ConfigHandlers.emplace_back(".clang-tidy", parseConfiguration); } @@ -224,14 +227,19 @@ FileOptionsProvider::FileOptionsProvider std::vector FileOptionsProvider::getRawOptions(StringRef FileName) { DEBUG(llvm::dbgs() << "Getting options for file " << FileName << "...\n"); + assert(FS && "FS must be set."); + + llvm::SmallString<128> AbsoluteFilePath(FileName); + if (std::error_code ec = FS->makeAbsolute(AbsoluteFilePath)) +return {}; This causes a compilation warning: ../tools/clang/tools/extra/clang-tidy/ClangTidyOptions.cpp:233:23: error: unused variable 'ec' [-Werror,-Wunused-variable] if (std::error_code ec = FS->makeAbsolute(AbsoluteFilePath)) ^ 1 error generated. Regards, Mikael std::vector RawOptions = - DefaultOptionsProvider::getRawOptions(FileName); + DefaultOptionsProvider::getRawOptions(AbsoluteFilePath.str()); OptionsSource CommandLineOptions(OverrideOptions, OptionsSourceTypeCheckCommandLineOption); // Look for a suitable configuration file in all parent directories of the // file. Start with the immediate parent directory and move up. - StringRef Path = llvm::sys::path::parent_path(FileName); + StringRef Path = llvm::sys::path::parent_path(AbsoluteFilePath.str()); for (StringRef CurrentPath = Path; !CurrentPath.empty(); CurrentPath = llvm::sys::path::parent_path(CurrentPath)) { llvm::Optional Result; Modified: clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h?rev=330245&r1=330244&r2=330245&view=diff == --- clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h (original) +++ clang-tools-extra/trunk/clang-tidy/ClangTidyOptions.h Wed Apr 18 01:54:28 2018 @@ -13,7 +13,9 @@ #include "llvm/ADT/Optional.h" #include "llvm/ADT/StringMap.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/IntrusiveRefCntPtr.h" #include "llvm/Support/ErrorOr.h" +#include "clang/Basic/VirtualFileSystem.h" #include #include #include @@ -221,7 +223,8 @@ public: /// whatever options are read from the configuration file. FileOptionsProvider(const ClangTidyGlobalOptions &GlobalOptions, const ClangTidyOptions &DefaultOptions, - const ClangTidyOptions &OverrideOptions); + const ClangTidyOptions &OverrideOptions, + llvm::IntrusiveRefCntPtr FS = nullptr); /// \brief Initializes the \c FileOptionsProvider instance with a custom set /// of configuration file handlers. @@ -255,6 +258,7 @@ protected: llvm::StringMap CachedOptions; ClangTidyOptions OverrideOptions; ConfigFileHandlers ConfigHandlers; + llvm::IntrusiveRefCntPtr FS; }; /// \brief Parses LineFilter from JSON and stores it to the \p Options. Modified: clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp?rev=330245&r1=330244&r2=330245&view=diff =
[PATCH] D44670: [CXX] Templates specialization visibility can be wrong
doug.gregor accepted this revision. doug.gregor added a comment. This revision is now accepted and ready to land. LGTM, thanks Repository: rC Clang https://reviews.llvm.org/D44670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45774: [analyzer] cover more cases where a Loc can be bound to constants
MTC added a comment. Test files for `initialization` missing? : ) Repository: rC Clang https://reviews.llvm.org/D45774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r330305 - Fix test from r330245 on Windows.
Author: dyung Date: Wed Apr 18 16:58:05 2018 New Revision: 330305 URL: http://llvm.org/viewvc/llvm-project?rev=330305&view=rev Log: Fix test from r330245 on Windows. Modified: clang-tools-extra/trunk/test/clang-tidy/read_file_config.cpp Modified: clang-tools-extra/trunk/test/clang-tidy/read_file_config.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/read_file_config.cpp?rev=330305&r1=330304&r2=330305&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/read_file_config.cpp (original) +++ clang-tools-extra/trunk/test/clang-tidy/read_file_config.cpp Wed Apr 18 16:58:05 2018 @@ -1,7 +1,7 @@ // RUN: mkdir -p %T/read-file-config/ // RUN: cp %s %T/read-file-config/test.cpp // RUN: echo 'Checks: "-*,modernize-use-nullptr"' > %T/read-file-config/.clang-tidy -// RUN: echo '[{"command": "cc -c -o test.o test.cpp", "directory": "%T/read-file-config", "file": "%T/read-file-config/test.cpp"}]' > %T/read-file-config/compile_commands.json +// RUN: echo '[{"command": "cc -c -o test.o test.cpp", "directory": "%/T/read-file-config", "file": "%/T/read-file-config/test.cpp"}]' > %T/read-file-config/compile_commands.json // RUN: clang-tidy %T/read-file-config/test.cpp | not grep "warning: .*\[clang-analyzer-deadcode.DeadStores\]$" // RUN: clang-tidy -checks="-*,clang-analyzer-*" %T/read-file-config/test.cpp | grep "warning: .*\[clang-analyzer-deadcode.DeadStores\]$" ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330304 - [CodeGen] Do not push a destructor cleanup for a struct that doesn't
Author: ahatanak Date: Wed Apr 18 16:33:15 2018 New Revision: 330304 URL: http://llvm.org/viewvc/llvm-project?rev=330304&view=rev Log: [CodeGen] Do not push a destructor cleanup for a struct that doesn't have a non-trivial destructor. This fixes a bug introduced in r328731 where CodeGen emits calls to synthesized destructors for non-trivial C structs in C++ mode when the struct passed to EmitCallArg doesn't have a non-trivial destructor. Under Microsoft's ABI, ASTContext::isParamDestroyedInCallee currently always returns true, so it's necessary to check whether the struct has a non-trivial destructor before pushing a cleanup in EmitCallArg. This fixes PR37146. Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=330304&r1=330303&r2=330304&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Wed Apr 18 16:33:15 2018 @@ -3541,13 +3541,20 @@ void CodeGenFunction::EmitCallArg(CallAr else Slot = CreateAggTemp(type, "agg.tmp"); -Slot.setExternallyDestructed(); +bool DestroyedInCallee = true, NeedsEHCleanup = true; +if (const auto *RD = type->getAsCXXRecordDecl()) + DestroyedInCallee = RD->hasNonTrivialDestructor(); +else + NeedsEHCleanup = needsEHCleanup(type.isDestructedType()); + +if (DestroyedInCallee) + Slot.setExternallyDestructed(); EmitAggExpr(E, Slot); RValue RV = Slot.asRValue(); args.add(RV, type); -if (type->getAsCXXRecordDecl() || needsEHCleanup(type.isDestructedType())) { +if (DestroyedInCallee && NeedsEHCleanup) { // Create a no-op GEP between the placeholder and the cleanup so we can // RAUW it successfully. It also serves as a marker of the first // instruction where the cleanup is active. Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp?rev=330304&r1=330303&r2=330304&view=diff == --- cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp (original) +++ cfe/trunk/test/CodeGenCXX/microsoft-abi-eh-cleanups.cpp Wed Apr 18 16:33:15 2018 @@ -313,3 +313,27 @@ class_0::class_0() { // WIN32: br label %[[SKIP_VBASE]] // WIN32: [[SKIP_VBASE]] } + +namespace PR37146 { +// Check that IRGen doesn't emit calls to synthesized destructors for +// non-trival C structs. + +// WIN32: define dso_local void @"?test@PR37146@@YAXXZ"() +// WIN32: call void @llvm.memset.p0i8.i32( +// WIN32: call i32 @"?getS@PR37146@@YA?AUS@1@XZ"( +// WIN32: call void @"?func@PR37146@@YAXUS@1@0@Z"( +// WIN32-NEXT: ret void +// WIN32-NEXT: {{^}$}} + +struct S { + int f; +}; + +void func(S, S); +S getS(); + +void test() { + func(getS(), S()); +} + +} ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330303 - [MS] Fix unprototyped thunk emission for incomplete return types
Author: rnk Date: Wed Apr 18 16:21:32 2018 New Revision: 330303 URL: http://llvm.org/viewvc/llvm-project?rev=330303&view=rev Log: [MS] Fix unprototyped thunk emission for incomplete return types Fixes PR37161 Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp cfe/trunk/test/CodeGenCXX/ms-thunks-unprototyped.cpp Modified: cfe/trunk/lib/CodeGen/CGVTables.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGVTables.cpp?rev=330303&r1=330302&r2=330303&view=diff == --- cfe/trunk/lib/CodeGen/CGVTables.cpp (original) +++ cfe/trunk/lib/CodeGen/CGVTables.cpp Wed Apr 18 16:21:32 2018 @@ -233,11 +233,15 @@ void CodeGenFunction::StartThunk(llvm::F const CXXMethodDecl *MD = cast(GD.getDecl()); QualType ThisType = MD->getThisType(getContext()); const FunctionProtoType *FPT = MD->getType()->getAs(); - QualType ResultType = CGM.getCXXABI().HasThisReturn(GD) -? ThisType -: CGM.getCXXABI().hasMostDerivedReturn(GD) - ? CGM.getContext().VoidPtrTy - : FPT->getReturnType(); + QualType ResultType; + if (IsUnprototyped) +ResultType = CGM.getContext().VoidTy; + else if (CGM.getCXXABI().HasThisReturn(GD)) +ResultType = ThisType; + else if (CGM.getCXXABI().hasMostDerivedReturn(GD)) +ResultType = CGM.getContext().VoidPtrTy; + else +ResultType = FPT->getReturnType(); FunctionArgList FunctionArgs; // Create the implicit 'this' parameter declaration. Modified: cfe/trunk/test/CodeGenCXX/ms-thunks-unprototyped.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ms-thunks-unprototyped.cpp?rev=330303&r1=330302&r2=330303&view=diff == --- cfe/trunk/test/CodeGenCXX/ms-thunks-unprototyped.cpp (original) +++ cfe/trunk/test/CodeGenCXX/ms-thunks-unprototyped.cpp Wed Apr 18 16:21:32 2018 @@ -24,11 +24,28 @@ struct B : virtual A { struct C : B { int c; }; C c; +// Do the same thing, but with an incomplete return type. +struct B1 { virtual DoNotInstantiate f() = 0; }; +struct B2 { virtual DoNotInstantiate f() = 0; }; +struct S : B1, B2 { DoNotInstantiate f() override; }; +S s; + +// CHECK: @"??_7S@@6BB2@@@" = linkonce_odr unnamed_addr constant +// CHECK-SAME: void (%struct.S*, ...)* @"?f@S@@W7EAA?AU?$DoNotInstantiate@X@@XZ" + // CHECK: @"??_7C@@6B@" = linkonce_odr unnamed_addr constant // CHECK-SAME: void (%struct.B*, ...)* @"?foo@B@@W7EAAXUIncomplete@@@Z" // CHECK-SAME: void (%struct.B*, ...)* @"?bar@B@@W7EAAXU?$DoNotInstantiate@H@@@Z" // CHECK-SAME: i32 (i8*, i32)* @"?baz@B@@W7EAAHU?$InstantiateLater@H@@@Z" + +// CHECK-LABEL: define linkonce_odr dso_local void @"?f@S@@W7EAA?AU?$DoNotInstantiate@X@@XZ"(%struct.S* %this, ...) +// CHECK: %[[THIS_ADJ_i8:[^ ]*]] = getelementptr i8, i8* {{.*}}, i32 -8 +// CHECK: %[[THIS_ADJ:[^ ]*]] = bitcast i8* %[[THIS_ADJ_i8]] to %struct.S* +// CHECK: musttail call void (%struct.S*, ...) {{.*}}@"?f@S@@UEAA?AU?$DoNotInstantiate@X@@XZ" +// CHECK-SAME: (%struct.S* %[[THIS_ADJ]], ...) +// CHECK: ret void + // The thunks should have a -8 adjustment. // CHECK-LABEL: define linkonce_odr dso_local void @"?foo@B@@W7EAAXUIncomplete@@@Z"(%struct.B* %this, ...) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen
Charusso updated this revision to Diff 143025. Charusso marked an inline comment as done. Charusso added a comment. Everything fixed. Thanks you @lebedev.ri for the early comments, I forgot to submit my comment. https://reviews.llvm.org/D45050 Files: clang-tidy/bugprone/BugproneTidyModule.cpp clang-tidy/bugprone/CMakeLists.txt clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp clang-tidy/bugprone/NotNullTerminatedResultCheck.h docs/ReleaseNotes.rst docs/clang-tidy/checks/bugprone-not-null-terminated-result.rst docs/clang-tidy/checks/list.rst test/clang-tidy/bugprone-not-null-terminated-result-strlen-before-cxx11.cpp test/clang-tidy/bugprone-not-null-terminated-result-strlen-cxx11.cpp test/clang-tidy/bugprone-not-null-terminated-result-wcslen-before-cxx11.cpp test/clang-tidy/bugprone-not-null-terminated-result-wcslen-cxx11.cpp Index: test/clang-tidy/bugprone-not-null-terminated-result-wcslen-cxx11.cpp === --- /dev/null +++ test/clang-tidy/bugprone-not-null-terminated-result-wcslen-cxx11.cpp @@ -0,0 +1,153 @@ +// RUN: %check_clang_tidy %s bugprone-not-null-terminated-result %t -- -- -std=c++11 + +typedef unsigned int size_t; +typedef int errno_t; +size_t wcslen(const wchar_t *); +wchar_t *wcschr(const wchar_t *, int); +errno_t *wcsncpy_s(wchar_t *, const wchar_t *, size_t); + +void *alloca(size_t); +void *calloc(size_t, size_t); +void *malloc(size_t); +void *realloc(void *, size_t); + +void *wmemcpy(void *, const void *, size_t); +errno_t wmemcpy_s(void *, size_t, const void *, size_t); +void *wmemchr(const void *, int, size_t); +void *wmemmove(void *, const void *, size_t); +errno_t wmemmove_s(void *, size_t, const void *, size_t); +void *wmemset(void *, int, size_t); + +int wcsncmp(const wchar_t *, const wchar_t *, size_t); +size_t wcsxfrm(wchar_t *, const wchar_t *, size_t); + +namespace std { +using ::wcsncpy_s; +using ::wmemcpy; +using ::wcslen; +} + +void bad_alloca(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)alloca(wcslen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'alloca' is insufficient to hold the null terminator [bugprone-not-null-terminated-result] + // CHECK-FIXES: alloca(wcslen(src) + 1); +} + +void good_alloca(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)alloca(wcslen(src) + 1); +} + +void bad_calloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)calloc(wcslen(src), sizeof(wchar_t)); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'calloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result] + // CHECK-FIXES: calloc((wcslen(src) + 1), sizeof(wchar_t)); +} + +void good_calloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)calloc((wcslen(src) + 1), sizeof(wchar_t)); +} + +void bad_malloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)malloc(wcslen(src) * 2); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'malloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result] + // CHECK-FIXES: malloc((wcslen(src) * 2) + 1); +} + +void good_malloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)malloc((wcslen(src) * 2) + 1); +} + +void bad_realloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)realloc(dest, (wcslen(dest) + wcslen(src))); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: memory allocated by 'realloc' is insufficient to hold the null terminator [bugprone-not-null-terminated-result] + // CHECK-FIXES: realloc(dest, (wcslen(dest) + (wcslen(src) + 1))); +} + +void good_realloc(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)realloc(dest, (wcslen(dest) + (wcslen(src) + 1))); +} + +void bad_wmemcpy(wchar_t *dest, const wchar_t *src) { + std::wmemcpy(dest, src, std::wcslen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy' is not null-terminated [bugprone-not-null-terminated-result] + // CHECK-FIXES: std::wcsncpy_s(dest, src, std::wcslen(src)); +} + +void good_wmemcpy_cxx11(wchar_t *dest, const wchar_t *src) { + std::wcsncpy_s(dest, src, std::wcslen(src)); +} + +void bad_wmemcpy_s(wchar_t *dest, const wchar_t *src) { + wmemcpy_s(dest, wcslen(dest), src, wcslen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: the result from calling 'wmemcpy_s' is not null-terminated [bugprone-not-null-terminated-result] + // CHECK-FIXES: wcsncpy_s(dest, src, wcslen(src)); +} + +void good_wmemcpy_s(wchar_t *dest, const wchar_t *src) { + wcsncpy_s(dest, src, wcslen(src)); +} + +void bad_wmemchr(wchar_t *dest, const wchar_t *src) { + dest = (wchar_t *)wmemchr(src, '\0', wcslen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: the result from calling 'wmemchr' is not null-terminated [bugprone-not-null-terminated-result] + // CHECK-FIXES: wcschr(src, '\0'); +} + +void good_wmemchr(wchar_t *dest, const wchar_t *src) { + dest = wcschr(src, '\0'); +} + +voi
[PATCH] D45050: [clang-tidy] New checker for not null-terminated result caused by strlen or wcslen
Charusso marked 14 inline comments as done. Charusso added inline comments. Comment at: clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp:226 +DiagnosticBuilder &Diag) { + if (getLangOpts().CPlusPlus11) { +StringRef NewFuncName = (Name[0] != 'w') ? "strncpy_s" : "wcsncpy_s"; aaron.ballman wrote: > What about C? The `else` part would fire. Comment at: test/clang-tidy/bugprone-not-null-terminated-result-strlen-before-cxx11.cpp:11 +void bad_memcpy(char *dest, const char *src) { + memcpy(dest, src, strlen(src)); + // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: 'memcpy' function's result is not null-terminated [bugprone-not-null-terminated-result] lebedev.ri wrote: > What about these functions, but in `std::` namespace? It is covered in `test/clang-tidy/bugprone-not-null-terminated-result-strlen-cxx11.cpp`, the test make sure my rename function doesn't touch the `std::` part. https://reviews.llvm.org/D45050 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45611: [analyzer] Fix filename in cross-file HTML report
vlad.tsyrklevich accepted this revision. vlad.tsyrklevich added a comment. This revision is now accepted and ready to land. This LGTM, but 1) you should add a test, probably just need to another CHECK to test/Coverage/html-multifile-diagnostics.c from https://reviews.llvm.org/D30406, and 2) someone from the analyzer team should sign off on it too. Repository: rC Clang https://reviews.llvm.org/D45611 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45254: [X86][WAITPKG] WaitPKG intrinsics
craig.topper added inline comments. Comment at: lib/Headers/waitpkgintrin.h:41 +static __inline__ __UINT8_TYPE__ __DEFAULT_FN_ATTRS +_umwait (__UINT32_TYPE__ __CONTROL, __UINT64_TYPE__ __COUNTER) +{ I think we should use "unsigned int" and "unsigned long long" explciitly. I think that's the prevailing behavior in the rest of our headers. Also change the argument names to lower case. I think that's also pretty standard. https://reviews.llvm.org/D45254 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py
alexfh added a comment. Thank you for the contribution! Please update the documentation accordingly (http://clang.llvm.org/extra/clang-tidy/#testing-checks). > // RUN: %check_clang_tidy %s misc-unused-using-decls %t > -check_suffix=-FLAG_1-- I don't know whether it makes sense to endorse (or even allow) the use of underscore in the check suffix. The mix of underscores and dashes looks ugly and is prone to errors. Comment at: test/clang-tidy/check_clang_tidy.cpp:16 +// CHECK-FIXES-NOT: using a::B;$ \ No newline at end of file Fix "No newline at end of file" Comment at: test/clang-tidy/check_clang_tidy.py:45 parser.add_argument('-assume-filename') + parser.add_argument('-check_suffix', default='') parser.add_argument('input_file_name') Please use dash as a separator as in other arguments. Comment at: test/clang-tidy/check_clang_tidy.py:77 + + check_fixes_prefix = 'CHECK-FIXES' + args.check_suffix + check_messages_prefix = 'CHECK-MESSAGES' + args.check_suffix Maybe the script should add a dash when check_suffix is not empty, so that one could use -check-suffix=FLAG instead of -check-suffix=-FLAG? Comment at: test/clang-tidy/check_clang_tidy.py:102 + + print "\n\n\n>>>",input_text, "<<-\n\n" Looks like debug output. Remove? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45776 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45223: [CUDA] Set LLVM calling convention for CUDA kernel
yaxunl added a comment. In https://reviews.llvm.org/D45223#1071452, @tra wrote: > AFAICT this is the replacement for https://reviews.llvm.org/D44747. LGTM. Yes. Thanks. https://reviews.llvm.org/D45223 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45068: [NVPTX, CUDA] Added support for m8n32k16 and m32n8k16 variants of wmma instructions.
This revision was automatically updated to reflect the committed changes. Closed by commit rL330296: [NVPTX, CUDA] Added support for m8n32k16 and m32n8k16 variants of wmma… (authored by tra, committed by ). Changed prior to commit: https://reviews.llvm.org/D45068?vs=143003&id=143005#toc Repository: rL LLVM https://reviews.llvm.org/D45068 Files: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Driver/ToolChains/Cuda.cpp cfe/trunk/test/CodeGen/builtins-nvptx-sm_70.cu llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td llvm/trunk/lib/Target/NVPTX/NVPTX.td llvm/trunk/lib/Target/NVPTX/NVPTXISelLowering.cpp llvm/trunk/lib/Target/NVPTX/NVPTXInstrInfo.td llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td llvm/trunk/test/CodeGen/NVPTX/wmma.py Index: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def === --- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def +++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def @@ -18,11 +18,18 @@ # define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif +#pragma push_macro("SM_70") +#define SM_70 "sm_70|sm_71" #pragma push_macro("SM_60") -#define SM_60 "sm_60|sm_61|sm_62|sm_70|sm_71" +#define SM_60 "sm_60|sm_61|sm_62|" SM_70 +#pragma push_macro("PTX61") +#define PTX61 "ptx61" #pragma push_macro("PTX60") -#define PTX60 "ptx60|ptx61" +#define PTX60 "ptx60|" PTX61 + +#pragma push_macro("AND") +#define AND(a, b) a "," b // Special Registers @@ -698,19 +705,46 @@ BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "") // Builtins to support WMMA instructions on sm_70 -TARGET_BUILTIN(__hmma_m16n16k16_ld_a, "vi*iC*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_ld_b, "vi*iC*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f16, "vi*iC*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f32, "vf*fC*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_st_c_f16, "vi*i*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_st_c_f32, "vf*f*UiIi", "", PTX60) - -TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", PTX60) +TARGET_BUILTIN(__hmma_m16n16k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_st_c_f16, "vi*i*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_st_c_f32, "vf*f*UiIi", "", AND(SM_70,PTX60)) + +TARGET_BUILTIN(__hmma_m32n8k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_st_c_f16, "vi*i*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_st_c_f32, "vf*f*UiIi", "", AND(SM_70,PTX61)) + +TARGET_BUILTIN(__hmma_m8n32k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_st_c_f16, "vi*i*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_st_c_f32, "vf*f*UiIi", "", AND(SM_70,PTX61)) + +TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX60)) + +TARGET_BUILTIN(__hmma_m32n8k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) + +TARGET_BUILTIN(__hmma_m8n32k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) #undef BUILTIN #undef TARGET_BUILTIN +#pragma pop_macro("AND") #pragma pop_macro("SM_60") +#pragma pop_macro("SM_70") #pragma pop_macro("PTX60") +#pragma pop_macro("PTX61") Index: cfe/trunk/test/CodeGe
r330296 - [NVPTX, CUDA] Added support for m8n32k16 and m32n8k16 variants of wmma instructions.
Author: tra Date: Wed Apr 18 14:51:48 2018 New Revision: 330296 URL: http://llvm.org/viewvc/llvm-project?rev=330296&view=rev Log: [NVPTX, CUDA] Added support for m8n32k16 and m32n8k16 variants of wmma instructions. The new instructions were added added for sm_70+ GPUs in CUDA-9.1. Differential Revision: https://reviews.llvm.org/D45068 Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/Driver/ToolChains/Cuda.cpp cfe/trunk/test/CodeGen/builtins-nvptx-sm_70.cu Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=330296&r1=330295&r2=330296&view=diff == --- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original) +++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Wed Apr 18 14:51:48 2018 @@ -18,11 +18,18 @@ # define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE) BUILTIN(ID, TYPE, ATTRS) #endif +#pragma push_macro("SM_70") +#define SM_70 "sm_70|sm_71" #pragma push_macro("SM_60") -#define SM_60 "sm_60|sm_61|sm_62|sm_70|sm_71" +#define SM_60 "sm_60|sm_61|sm_62|" SM_70 +#pragma push_macro("PTX61") +#define PTX61 "ptx61" #pragma push_macro("PTX60") -#define PTX60 "ptx60|ptx61" +#define PTX60 "ptx60|" PTX61 + +#pragma push_macro("AND") +#define AND(a, b) a "," b // Special Registers @@ -698,19 +705,46 @@ BUILTIN(__nvvm_ldg_f4, "E4fE4fC*", "") BUILTIN(__nvvm_ldg_d2, "E2dE2dC*", "") // Builtins to support WMMA instructions on sm_70 -TARGET_BUILTIN(__hmma_m16n16k16_ld_a, "vi*iC*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_ld_b, "vi*iC*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f16, "vi*iC*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f32, "vf*fC*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_st_c_f16, "vi*i*UiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_st_c_f32, "vf*f*UiIi", "", PTX60) - -TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", PTX60) -TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", PTX60) +TARGET_BUILTIN(__hmma_m16n16k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_st_c_f16, "vi*i*UiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_st_c_f32, "vf*f*UiIi", "", AND(SM_70,PTX60)) + +TARGET_BUILTIN(__hmma_m32n8k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_st_c_f16, "vi*i*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_st_c_f32, "vf*f*UiIi", "", AND(SM_70,PTX61)) + +TARGET_BUILTIN(__hmma_m8n32k16_ld_a, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_ld_b, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_ld_c_f16, "vi*iC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_ld_c_f32, "vf*fC*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_st_c_f16, "vi*i*UiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_st_c_f32, "vf*f*UiIi", "", AND(SM_70,PTX61)) + +TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX60)) +TARGET_BUILTIN(__hmma_m16n16k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX60)) + +TARGET_BUILTIN(__hmma_m32n8k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m32n8k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) + +TARGET_BUILTIN(__hmma_m8n32k16_mma_f16f16, "vi*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_mma_f32f16, "vf*iC*iC*iC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_mma_f32f32, "vf*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) +TARGET_BUILTIN(__hmma_m8n32k16_mma_f16f32, "vi*iC*iC*fC*IiIi", "", AND(SM_70,PTX61)) #undef BUILTIN #undef TARGET_BUILTIN +#pragma pop_macro("AND") #pragma pop_macro("SM_60") +#pragma pop_macro("SM_70") #pragma pop_macro("PTX60") +#pragma pop_macro("PTX61") Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.or
[PATCH] D45068: [NVPTX, CUDA] Added support for m8n32k16 and m32n8k16 variants of wmma instructions.
tra updated this revision to Diff 143003. tra added a comment. Updated the way we specify TARGET_BUILTIN feature constraints https://reviews.llvm.org/D45068 Files: clang/include/clang/Basic/BuiltinsNVPTX.def clang/lib/CodeGen/CGBuiltin.cpp clang/lib/Driver/ToolChains/Cuda.cpp clang/test/CodeGen/builtins-nvptx-sm_70.cu llvm/include/llvm/IR/IntrinsicsNVVM.td llvm/lib/Target/NVPTX/NVPTX.td llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp llvm/lib/Target/NVPTX/NVPTXInstrInfo.td llvm/lib/Target/NVPTX/NVPTXIntrinsics.td llvm/test/CodeGen/NVPTX/wmma.py Index: llvm/test/CodeGen/NVPTX/wmma.py === --- llvm/test/CodeGen/NVPTX/wmma.py +++ llvm/test/CodeGen/NVPTX/wmma.py @@ -2,7 +2,7 @@ # generates correct instructions for them. # RUN: python %s > %t.ll -# RUN: llc < %t.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx60 | FileCheck %t.ll +# RUN: llc < %t.ll -march=nvptx64 -mcpu=sm_70 -mattr=+ptx61 | FileCheck %t.ll from itertools import product from string import Template @@ -36,33 +36,36 @@ check_f16_4 = "{{%s}}" % ", *".join(["%hh[0-9]+"] * 4) check_f32_8 = "{{%s}}" % ", *".join(["%f[0-9]+"] * 8) +known_geoms = ["m16n16k16", "m8n32k16", "m32n8k16"] + def gen_wmma_load_tests(): load_template = """ declare ${ret_ty} @${intrinsic}(i8 ${as}* %src ${extra_args}); ; CHECK-LABEL: .func {{.*}}test_${function}( define ${ret_ty} @test_${function}(i8 ${as}* %src ${extra_args}) { -; CHECK ${instruction} +; CHECK: ${instruction} ; CHECK: {${check_result}} ; CHECK: [%rd{{[0-9]+}}]${stride_pattern} %v0 = call ${ret_ty} @${intrinsic}(i8 ${as}* %src ${extra_args}); ret ${ret_ty} %v0; } ; CHECK-LABEL: .func{{.*}}test_${function}_o( define ${ret_ty} @test_${function}_o(i8 ${as}* %src ${extra_args}) { -; CHECK ${instruction} +; CHECK: ${instruction} ; CHECK: {${check_result}} ; CHECK: [%rd{{[0-9]+}}+128]${stride_pattern} %src1 = getelementptr i8, i8 ${as}* %src, i32 128; %v0 = call ${ret_ty} @${intrinsic}(i8 ${as}* %src1 ${extra_args}); ret ${ret_ty} %v0; } """ intrinsic_template = "llvm.nvvm.wmma.${geom}.load.${abc}.${layout}${stride}.${itype}.${pspace}" - instruction_template = "wmma.load.${abc}.sync.${geom}.${layout}${space}.${itype}" + instruction_template = "wmma.load.${abc}.sync.${layout}.${geom}${space}.${itype}" - for abc, layout, space, stride, itype in product( + for geom, abc, layout, space, stride, itype in product( + known_geoms, "abc", ["row","col"], ["",".shared",".global"], @@ -77,7 +80,7 @@ "itype" : itype, "pspace" : get_pspace(space), "as" : "addrspace(%d)" % get_aspace(space), -"geom" : "m16n16k16", +"geom" : geom, } if itype == "f32" and abc != "c": @@ -112,27 +115,28 @@ ; CHECK-LABEL: .func {{.*}}test_${function}( define void @test_${function}(i8 ${as}* %src, ${args}${extra_args}) { -; CHECK ${instruction} {{.*}}[%rd{{[0-9+]}} +; CHECK: ${instruction} {{.*}}[%rd{{[0-9+]}} ; CHECK: {${check_args}} ; CHECK: ${stride_pattern} call void @${intrinsic}(i8 ${as}* %src, ${args} ${extra_args}); ret void } ; CHECK-LABEL: .func{{.*}}test_${function}_o( define void @test_${function}_o(i8 ${as}* %src, ${args}${extra_args}) { -; CHECK ${instruction} {{.*}}[%rd{{[0-9+]}}+128] +; CHECK: ${instruction} {{.*}}[%rd{{[0-9+]}}+128] ; CHECK: ${check_args} ; CHECK: ${stride_pattern} %src1 = getelementptr i8, i8 ${as}* %src, i32 128; call void @${intrinsic}(i8 ${as}* %src1, ${args}${extra_args}); ret void } """ intrinsic_template = "llvm.nvvm.wmma.${geom}.store.${abc}.${layout}${stride}.${itype}.${pspace}" - instruction_template = "wmma.store.${abc}.sync.${geom}.${layout}${space}.${itype}" + instruction_template = "wmma.store.${abc}.sync.${layout}.${geom}${space}.${itype}" - for abc, layout, space, stride, itype in product( + for geom, abc, layout, space, stride, itype in product( + known_geoms, "d", ["row","col"], ["",".shared",".global"], @@ -147,7 +151,7 @@ "itype" : itype, "pspace" : get_pspace(space), "as" : "addrspace(%d)" % get_aspace(space), -"geom" : "m16n16k16", +"geom" : geom, } test_params = params @@ -174,20 +178,21 @@ ; CHECK-LABEL: .func {{.*}}test_${function}( define ${ret_ty} @test_${function}( ${args}) { -; CHECK ${instruction} {{.*}}[%rd{{[0-9+]}} -; CHECK ${check_d} -; CHECK ${check_ab} -; CHECK ${check_ab} -; CHECK ${check_c} +; CHECK: ${instruction} +; CHECK-NEXT: ${check_d} +; CHECK-NEXT: ${check_ab} +; CHECK-NEXT: ${check_ab} +; CHECK-NEXT: ${check_c} %r = call ${ret_ty} @${intrinsic}( ${args}); ret ${ret_ty} %r; } """ intrinsic_template = "llvm.nvvm.wmma.${geom}.mma.${alayout}.${blayout}.${dtype}.${ctype}${satf}" instruction_template = "wmma.mma.sync.${alayout}.${blayout}.${geom}.${dtype}.${ctype}${satf}" - for alayout, blayout, ctype
[PATCH] D45720: [X86] Lowering PACK*S (pack with saturation) intrinsics to native IR (clang side)
craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D45720 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45223: [CUDA] Set LLVM calling convention for CUDA kernel
tra accepted this revision. tra added a comment. This revision is now accepted and ready to land. AFAICT this is the replacement for https://reviews.llvm.org/D44747. LGTM. https://reviews.llvm.org/D45223 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45223: [CUDA] Set LLVM calling convention for CUDA kernel
yaxunl updated this revision to Diff 143001. yaxunl retitled this revision from "[CUDA] Fix overloading resolution failure due to kernel calling convention" to "[CUDA] Set LLVM calling convention for CUDA kernel". yaxunl edited the summary of this revision. yaxunl added a comment. Use CodeGen approach. https://reviews.llvm.org/D45223 Files: lib/CodeGen/CodeGenModule.cpp lib/CodeGen/TargetInfo.cpp lib/CodeGen/TargetInfo.h test/CodeGenCUDA/kernel-amdgcn.cu Index: test/CodeGenCUDA/kernel-amdgcn.cu === --- /dev/null +++ test/CodeGenCUDA/kernel-amdgcn.cu @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s +#include "Inputs/cuda.h" + +// CHECK: define amdgpu_kernel void @_ZN1A6kernelEv +class A { +public: + static __global__ void kernel(){} +}; + +// CHECK: define void @_Z10non_kernelv +__device__ void non_kernel(){} + +// CHECK: define amdgpu_kernel void @_Z6kerneli +__global__ void kernel(int x) { + non_kernel(); +} + +// CHECK: define amdgpu_kernel void @_Z11EmptyKernelIvEvv +template +__global__ void EmptyKernel(void) {} + +struct Dummy { + /// Type definition of the EmptyKernel kernel entry point + typedef void (*EmptyKernelPtr)(); + EmptyKernelPtr Empty() { return EmptyKernel; } +}; + +// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_ +template +__global__ void template_kernel(T x) {} + +void launch(void *f); + +int main() { + Dummy D; + launch((void*)A::kernel); + launch((void*)kernel); + launch((void*)template_kernel); + launch((void*)D.Empty()); + return 0; +} Index: lib/CodeGen/TargetInfo.h === --- lib/CodeGen/TargetInfo.h +++ lib/CodeGen/TargetInfo.h @@ -301,6 +301,8 @@ /// mangled name of functions declared within an extern "C" region and marked /// as 'used', and having internal linkage. virtual bool shouldEmitStaticExternCAliases() const { return true; } + + virtual void setCUDAKernelCallingConvention(llvm::Function *F) const {} }; } // namespace CodeGen Index: lib/CodeGen/TargetInfo.cpp === --- lib/CodeGen/TargetInfo.cpp +++ lib/CodeGen/TargetInfo.cpp @@ -7652,6 +7652,7 @@ llvm::Function *BlockInvokeFunc, llvm::Value *BlockLiteral) const override; bool shouldEmitStaticExternCAliases() const override; + void setCUDAKernelCallingConvention(llvm::Function *F) const override; }; } @@ -7787,6 +7788,11 @@ return false; } +void AMDGPUTargetCodeGenInfo::setCUDAKernelCallingConvention( +llvm::Function *F) const { + F->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL); +} + //===--===// // SPARC v8 ABI Implementation. // Based on the SPARC Compliance Definition version 2.4.1. Index: lib/CodeGen/CodeGenModule.cpp === --- lib/CodeGen/CodeGenModule.cpp +++ lib/CodeGen/CodeGenModule.cpp @@ -3608,6 +3608,9 @@ MaybeHandleStaticInExternC(D, Fn); + if (D->hasAttr()) +getTargetCodeGenInfo().setCUDAKernelCallingConvention(Fn); + maybeSetTrivialComdat(*D, *Fn); CodeGenFunction(*this).GenerateCode(D, Fn, FI); Index: test/CodeGenCUDA/kernel-amdgcn.cu === --- /dev/null +++ test/CodeGenCUDA/kernel-amdgcn.cu @@ -0,0 +1,41 @@ +// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s +#include "Inputs/cuda.h" + +// CHECK: define amdgpu_kernel void @_ZN1A6kernelEv +class A { +public: + static __global__ void kernel(){} +}; + +// CHECK: define void @_Z10non_kernelv +__device__ void non_kernel(){} + +// CHECK: define amdgpu_kernel void @_Z6kerneli +__global__ void kernel(int x) { + non_kernel(); +} + +// CHECK: define amdgpu_kernel void @_Z11EmptyKernelIvEvv +template +__global__ void EmptyKernel(void) {} + +struct Dummy { + /// Type definition of the EmptyKernel kernel entry point + typedef void (*EmptyKernelPtr)(); + EmptyKernelPtr Empty() { return EmptyKernel; } +}; + +// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_ +template +__global__ void template_kernel(T x) {} + +void launch(void *f); + +int main() { + Dummy D; + launch((void*)A::kernel); + launch((void*)kernel); + launch((void*)template_kernel); + launch((void*)D.Empty()); + return 0; +} Index: lib/CodeGen/TargetInfo.h === --- lib/CodeGen/TargetInfo.h +++ lib/CodeGen/TargetInfo.h @@ -301,6 +301,8 @@ /// mangled name of functions declared within an extern "C" region and marked /// as 'used', and having internal linkage. virtual bool shouldEmitStaticExternCAliases() const { return true; } + + virtual void setCUDAKernelCallingConvention(llvm::Function *F)
[PATCH] D45223: [CUDA] Fix overloading resolution failure due to kernel calling convention
yaxunl added a comment. In https://reviews.llvm.org/D45223#1071358, @rjmccall wrote: > Yes, I'm sorry, I think you're right. I had misunderstood the language > problem when I suggested going down this road. In https://reviews.llvm.org/D45223#1071358, @rjmccall wrote: > Yes, I'm sorry, I think you're right. I had misunderstood the language > problem when I suggested going down this road. Never mind. I will update the diff for CodeGen approach. https://reviews.llvm.org/D45223 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
JonasToth added inline comments. Comment at: clang-tidy/utils/ASTUtils.cpp:226 + + // If 'Exp' is bound to a non-const reference, check all declRefExpr to that. + const auto Refs = match( What about transitive references and pointers? It seems that only references are checked, but if a pointer is taken through that reference and vice versa, is that tracked correctly? Comment at: clang-tidy/utils/ASTUtils.cpp:233 + conditionalOperator(anyOf( + hasTrueExpression(equalsNode(&Exp)), + hasFalseExpression(equalsNode(&Exp)), If the `Exp` is an array, that will not match array subscript? Are there other similar cases? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] r330286 - add extra acronyms for objc property names
Author: wizard Date: Wed Apr 18 13:09:10 2018 New Revision: 330286 URL: http://llvm.org/viewvc/llvm-project?rev=330286&view=rev Log: add extra acronyms for objc property names Summary: This is to support general acronyms in Objective-C like 2G/3G/4G/... and coordinates X, Y, Z and W. Reviewers: benhamilton Reviewed By: benhamilton Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D45750 Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Modified: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp?rev=330286&r1=330285&r2=330286&view=diff == --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp (original) +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp Wed Apr 18 13:09:10 2018 @@ -39,6 +39,7 @@ enum NamingStyle { /// /// Keep this list sorted. constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = { +"[2-9]G", "ACL", "API", "ARGB", @@ -93,8 +94,12 @@ constexpr llvm::StringLiteral DefaultSpe "VOIP", "VPN", "VR", +"W", "WAN", +"X", "XML", +"Y", +"Z", }; /// For now we will only fix 'CamelCase' or 'abc_CamelCase' property to Modified: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m?rev=330286&r1=330285&r2=330286&view=diff == --- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m (original) +++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Wed Apr 18 13:09:10 2018 @@ -17,6 +17,8 @@ @property(strong, nonatomic) NSString *supportURLsCamelCase; @property(strong, nonatomic) NSString *supportURLCamelCase; @property(strong, nonatomic) NSString *VCsPluralToAdd; +@property(assign, nonatomic) int centerX; +@property(assign, nonatomic) int enable2GBackgroundFetch; @end @interface Foo (Bar) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330284 - [OPENMP] Fix -Wunused-lambda-capture. NFC
Author: maskray Date: Wed Apr 18 12:32:01 2018 New Revision: 330284 URL: http://llvm.org/viewvc/llvm-project?rev=330284&view=rev Log: [OPENMP] Fix -Wunused-lambda-capture. NFC Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=330284&r1=330283&r2=330284&view=diff == --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original) +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Apr 18 12:32:01 2018 @@ -11991,6 +11991,7 @@ static bool checkMapConflicts( "Map clause expression with no components!"); assert(StackComponents.back().getAssociatedDeclaration() == VD && "Map clause expression with unexpected base!"); +(void)VD; // The whole expression in the stack. const Expr *RE = StackComponents.front().getAssociatedExpression(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness
JonasToth updated this revision to Diff 142991. JonasToth added a comment. - [Misc] mark false positives Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/ConstCheck.cpp clang-tidy/cppcoreguidelines/ConstCheck.h clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp docs/ReleaseNotes.rst docs/clang-tidy/checks/cppcoreguidelines-const.rst docs/clang-tidy/checks/list.rst test/clang-tidy/cppcoreguidelines-const-handles.cpp test/clang-tidy/cppcoreguidelines-const-values.cpp Index: test/clang-tidy/cppcoreguidelines-const-values.cpp === --- /dev/null +++ test/clang-tidy/cppcoreguidelines-const-values.cpp @@ -0,0 +1,433 @@ +// RUN: %check_clang_tidy %s cppcoreguidelines-const %t \ +// RUN: -config='{CheckOptions: \ +// RUN: [{key: "cppcoreguidelines-const.AnalyzeValues", value: 1},\ +// RUN: {key: "cppcoreguidelines-const.AnalyzeHandles", value: 0},\ +// RUN: {key: "cppcoreguidelines-const.WarnPointersAsValues", value: 1}]}' \ +// RUN: -- + +// --- Provide test samples for primitive builtins - +// - every 'p_*' variable is a 'potential_const_*' variable +// - every 'np_*' variable is a 'non_potential_const_*' variable + +bool global; +char np_global = 0; // globals can't be known to be const + +namespace foo { +int scoped; +float np_scoped = 1; // namespace variables are like globals +} // namespace foo + +void some_function(double, wchar_t); + +void some_function(double np_arg0, wchar_t np_arg1) { + int p_local0 = 2; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + + int np_local0; + const int np_local1 = 42; + + unsigned int np_local2 = 3; + np_local2 <<= 4; + + int np_local3 = 4; + ++np_local3; + int np_local4 = 4; + np_local4++; + + int np_local5 = 4; + --np_local5; + int np_local6 = 4; + np_local6--; +} + +void some_lambda_environment_capture_all_by_reference(double np_arg0) { + int np_local0 = 0; + int p_local0 = 1; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + + int np_local2; + const int np_local3 = 2; + + // Capturing all variables by reference prohibits making them const. + [&]() { ++np_local0; }; + + int p_local1 = 0; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const +} + +void some_lambda_environment_capture_all_by_value(double np_arg0) { + int np_local0 = 0; + int p_local0 = 1; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + + int np_local1; + const int np_local2 = 2; + + // Capturing by value has no influence on them. + [=]() { (void)p_local0; }; + + np_local0 += 10; +} + +void function_inout_pointer(int *inout); +void function_in_pointer(const int *in); + +void some_pointer_taking(int *out) { + int p_local0 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + const int *const p0_p_local0 = &p_local0; + int *const p1_p_local0 = &p_local0; + + int np_local0 = 42; + function_inout_pointer(&np_local0); + + // Prevents const. + int np_local1 = 42; + out = &np_local1; // This returns and invalid address, its just about the AST + + int p_local1 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const + const int *const p0_p_local1 = &p_local1; + + int p_local2 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared const + function_in_pointer(&p_local2); +} + +void function_inout_ref(int &inout); +void function_in_ref(const int &in); + +void some_reference_taking() { + // FIXME False positive + int np_local0 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'np_local0' of type 'int' can be declared const + const int &r0_np_local0 = np_local0; + int &r1_np_local0 = np_local0; + r1_np_local0 = 43; + const int &r2_np_local0 = r1_np_local0; + + int np_local1 = 42; + function_inout_ref(np_local1); + + int p_local0 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + const int &r0_p_local0 = p_local0; + + int p_local1 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const + function_in_ref(p_local1); +} + +double *non_const_pointer_return() { + double p_local0 = 0.0; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const + double np_local0 = 24.4; + + return &np_local0; +} + +const double *const_pointer_return() { + double p_local0 = 0.0; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const + double p_local1 = 24.4; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: va
[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness
JonasToth added a comment. @shuaiwang I implemented the check on top of you utility function. It does fail right now (concentrating on values only for now). I added a `FIXME` for all false positives/negatives for the values test cases. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45444: [clang-tidy] WIP: implement new check for const-correctness
JonasToth updated this revision to Diff 142988. JonasToth added a comment. - [Feature] refactor check to use a utility function to determine constness Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45444 Files: clang-tidy/cppcoreguidelines/CMakeLists.txt clang-tidy/cppcoreguidelines/ConstCheck.cpp clang-tidy/cppcoreguidelines/ConstCheck.h clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp docs/ReleaseNotes.rst docs/clang-tidy/checks/cppcoreguidelines-const.rst docs/clang-tidy/checks/list.rst test/clang-tidy/cppcoreguidelines-const-handles.cpp test/clang-tidy/cppcoreguidelines-const-values.cpp Index: test/clang-tidy/cppcoreguidelines-const-values.cpp === --- /dev/null +++ test/clang-tidy/cppcoreguidelines-const-values.cpp @@ -0,0 +1,418 @@ +// RUN: %check_clang_tidy %s cppcoreguidelines-const %t \ +// RUN: -config='{CheckOptions: \ +// RUN: [{key: "cppcoreguidelines-const.AnalyzeValues", value: 1},\ +// RUN: {key: "cppcoreguidelines-const.AnalyzeHandles", value: 0},\ +// RUN: {key: "cppcoreguidelines-const.WarnPointersAsValues", value: 1}]}' \ +// RUN: -- + +// --- Provide test samples for primitive builtins - +// - every 'p_*' variable is a 'potential_const_*' variable +// - every 'np_*' variable is a 'non_potential_const_*' variable + +bool global; +char np_global = 0; // globals can't be known to be const + +namespace foo { +int scoped; +float np_scoped = 1; // namespace variables are like globals +} // namespace foo + +void some_function(double, wchar_t); + +void some_function(double np_arg0, wchar_t np_arg1) { + int p_local0 = 2; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + + int np_local0; + const int np_local1 = 42; + + unsigned int np_local2 = 3; + np_local2 <<= 4; + + int np_local3 = 4; + ++np_local3; + int np_local4 = 4; + np_local4++; + + int np_local5 = 4; + --np_local5; + int np_local6 = 4; + np_local6--; +} + +void some_lambda_environment_capture_all_by_reference(double np_arg0) { + int np_local0 = 0; + int p_local0 = 1; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + + int np_local2; + const int np_local3 = 2; + + // Capturing all variables by reference prohibits making them const. + [&]() { ++np_local0; }; + + int p_local1 = 0; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const +} + +void some_lambda_environment_capture_all_by_value(double np_arg0) { + int np_local0 = 0; + int p_local0 = 1; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + + int np_local1; + const int np_local2 = 2; + + // Capturing by value has no influence on them. + [=]() { (void)p_local0; }; + + np_local0 += 10; +} + +void function_inout_pointer(int *inout); +void function_in_pointer(const int *in); + +void some_pointer_taking(int *out) { + int p_local0 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + const int *const p0_p_local0 = &p_local0; + int *const p1_p_local0 = &p_local0; + + int np_local0 = 42; + function_inout_pointer(&np_local0); + + // Prevents const. + int np_local1 = 42; + out = &np_local1; // This returns and invalid address, its just about the AST + + int p_local1 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const + const int *const p0_p_local1 = &p_local1; + + int p_local2 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local2' of type 'int' can be declared const + function_in_pointer(&p_local2); +} + +void function_inout_ref(int &inout); +void function_in_ref(const int &in); + +void some_reference_taking() { + int np_local0 = 42; + const int &r0_np_local0 = np_local0; + int &r1_np_local0 = np_local0; + r1_np_local0 = 43; + const int &r2_np_local0 = r1_np_local0; + + int np_local1 = 42; + function_inout_ref(np_local1); + + int p_local0 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'int' can be declared const + const int &r0_p_local0 = p_local0; + + int p_local1 = 42; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'int' can be declared const + function_in_ref(p_local1); +} + +double *non_const_pointer_return() { + double p_local0 = 0.0; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const + double np_local0 = 24.4; + + return &np_local0; +} + +const double *const_pointer_return() { + double p_local0 = 0.0; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local0' of type 'double' can be declared const + double p_local1 = 24.4; + // CHECK-MESSAGES: [[@LINE-1]]:3: warning: variable 'p_local1' of type 'double' can be declared const + return &p_local1; +} + +
[PATCH] D45223: [CUDA] Fix overloading resolution failure due to kernel calling convention
rjmccall added a comment. Yes, I'm sorry, I think you're right. I had misunderstood the language problem when I suggested going down this road. https://reviews.llvm.org/D45223 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45750: add extra acronyms for objc property names
This revision was automatically updated to reflect the committed changes. Closed by commit rL330286: add extra acronyms for objc property names (authored by Wizard, committed by ). Herald added a subscriber: llvm-commits. Repository: rL LLVM https://reviews.llvm.org/D45750 Files: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -39,6 +39,7 @@ /// /// Keep this list sorted. constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = { +"[2-9]G", "ACL", "API", "ARGB", @@ -93,8 +94,12 @@ "VOIP", "VPN", "VR", +"W", "WAN", +"X", "XML", +"Y", +"Z", }; /// For now we will only fix 'CamelCase' or 'abc_CamelCase' property to Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m === --- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m +++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m @@ -17,6 +17,8 @@ @property(strong, nonatomic) NSString *supportURLsCamelCase; @property(strong, nonatomic) NSString *supportURLCamelCase; @property(strong, nonatomic) NSString *VCsPluralToAdd; +@property(assign, nonatomic) int centerX; +@property(assign, nonatomic) int enable2GBackgroundFetch; @end @interface Foo (Bar) Index: clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tools-extra/trunk/clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -39,6 +39,7 @@ /// /// Keep this list sorted. constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = { +"[2-9]G", "ACL", "API", "ARGB", @@ -93,8 +94,12 @@ "VOIP", "VPN", "VR", +"W", "WAN", +"X", "XML", +"Y", +"Z", }; /// For now we will only fix 'CamelCase' or 'abc_CamelCase' property to Index: clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m === --- clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m +++ clang-tools-extra/trunk/test/clang-tidy/objc-property-declaration.m @@ -17,6 +17,8 @@ @property(strong, nonatomic) NSString *supportURLsCamelCase; @property(strong, nonatomic) NSString *supportURLCamelCase; @property(strong, nonatomic) NSString *VCsPluralToAdd; +@property(assign, nonatomic) int centerX; +@property(assign, nonatomic) int enable2GBackgroundFetch; @end @interface Foo (Bar) ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45750: add extra acronyms for objc property names
Wizard added inline comments. Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:42 constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = { +"[2-9]G", "ACL", benhamilton wrote: > Probably should just make this: > > "\\d+G" > It seems llvm::Regex does not recognize \d somehow. I tried \\d+ does not work for the test. Will keep [2-9]G for now. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45750: add extra acronyms for objc property names
Wizard updated this revision to Diff 142985. Wizard marked 2 inline comments as done. Wizard added a comment. resolve comments Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45750 Files: clang-tidy/objc/PropertyDeclarationCheck.cpp test/clang-tidy/objc-property-declaration.m Index: test/clang-tidy/objc-property-declaration.m === --- test/clang-tidy/objc-property-declaration.m +++ test/clang-tidy/objc-property-declaration.m @@ -17,6 +17,8 @@ @property(strong, nonatomic) NSString *supportURLsCamelCase; @property(strong, nonatomic) NSString *supportURLCamelCase; @property(strong, nonatomic) NSString *VCsPluralToAdd; +@property(assign, nonatomic) int centerX; +@property(assign, nonatomic) int enable2GBackgroundFetch; @end @interface Foo (Bar) Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -39,6 +39,7 @@ /// /// Keep this list sorted. constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = { +"[2-9]G", "ACL", "API", "ARGB", @@ -93,8 +94,12 @@ "VOIP", "VPN", "VR", +"W", "WAN", +"X", "XML", +"Y", +"Z", }; /// For now we will only fix 'CamelCase' or 'abc_CamelCase' property to Index: test/clang-tidy/objc-property-declaration.m === --- test/clang-tidy/objc-property-declaration.m +++ test/clang-tidy/objc-property-declaration.m @@ -17,6 +17,8 @@ @property(strong, nonatomic) NSString *supportURLsCamelCase; @property(strong, nonatomic) NSString *supportURLCamelCase; @property(strong, nonatomic) NSString *VCsPluralToAdd; +@property(assign, nonatomic) int centerX; +@property(assign, nonatomic) int enable2GBackgroundFetch; @end @interface Foo (Bar) Index: clang-tidy/objc/PropertyDeclarationCheck.cpp === --- clang-tidy/objc/PropertyDeclarationCheck.cpp +++ clang-tidy/objc/PropertyDeclarationCheck.cpp @@ -39,6 +39,7 @@ /// /// Keep this list sorted. constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = { +"[2-9]G", "ACL", "API", "ARGB", @@ -93,8 +94,12 @@ "VOIP", "VPN", "VR", +"W", "WAN", +"X", "XML", +"Y", +"Z", }; /// For now we will only fix 'CamelCase' or 'abc_CamelCase' property to ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
JonasToth added a comment. Another note: https://github.com/llvm-mirror/clang-tools-extra/blob/master/clang-tidy/utils/DeclRefExprUtils.cpp There is a `isOnlyUsedAsConst` with a slick implementation, using a set difference. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
yaxunl updated this revision to Diff 142978. yaxunl marked an inline comment as done. yaxunl added a comment. Revised by Artem's comments. https://reviews.llvm.org/D44984 Files: include/clang/Basic/IdentifierTable.h include/clang/Basic/LangOptions.def include/clang/Frontend/FrontendOptions.h include/clang/Frontend/LangStandards.def lib/CodeGen/CGCUDANV.cpp lib/Frontend/CompilerInvocation.cpp lib/Frontend/FrontendActions.cpp lib/Frontend/InitPreprocessor.cpp lib/Sema/SemaCUDA.cpp lib/Sema/SemaDecl.cpp test/CodeGenCUDA/device-stub.cu Index: test/CodeGenCUDA/device-stub.cu === --- test/CodeGenCUDA/device-stub.cu +++ test/CodeGenCUDA/device-stub.cu @@ -1,8 +1,11 @@ // RUN: echo "GPU binary would be here" > %t -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - | FileCheck %s -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s \ +// RUN: -fcuda-include-gpubinary %t -o - -DNOGLOBALS \ // RUN: | FileCheck %s -check-prefix=NOGLOBALS -// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - | FileCheck %s -check-prefix=NOGPUBIN +// RUN: %clang_cc1 -triple x86_64-linux-gnu -emit-llvm %s -o - \ +// RUN: | FileCheck %s -check-prefix=NOGPUBIN #include "Inputs/cuda.h" @@ -77,10 +80,14 @@ // Test that we've built a function to register kernels and global vars. // CHECK: define internal void @__cuda_register_globals // CHECK: call{{.*}}cudaRegisterFunction(i8** %0, {{.*}}kernelfunc -// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}device_var{{.*}}i32 0, i32 4, i32 0, i32 0 -// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}constant_var{{.*}}i32 0, i32 4, i32 1, i32 0 -// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_device_var{{.*}}i32 1, i32 4, i32 0, i32 0 -// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}}i32 1, i32 4, i32 1, i32 0 +// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}device_var{{.*}} +// CHECK-DAG-SAME: i32 0, i32 4, i32 0, i32 0 +// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}constant_var{{.*}} +// CHECK-DAG-SAME: i32 0, i32 4, i32 1, i32 0 +// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_device_var{{.*}} +// CHECK-DAG-SAME: i32 1, i32 4, i32 0, i32 0 +// CHECK-DAG: call{{.*}}cudaRegisterVar(i8** %0, {{.*}}ext_constant_var{{.*}} +// CHECK-DAG-SAME: i32 1, i32 4, i32 1, i32 0 // CHECK: ret void // Test that we've built contructor.. Index: lib/Sema/SemaDecl.cpp === --- lib/Sema/SemaDecl.cpp +++ lib/Sema/SemaDecl.cpp @@ -9048,11 +9048,13 @@ if (getLangOpts().CUDA) { IdentifierInfo *II = NewFD->getIdentifier(); -if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() && +if (II && +II->isStr(getLangOpts().HIP ? "hipConfigureCall" +: "cudaConfigureCall") && +!NewFD->isInvalidDecl() && NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { if (!R->getAs()->getReturnType()->isScalarType()) Diag(NewFD->getLocation(), diag::err_config_scalar_return); - Context.setcudaConfigureCallDecl(NewFD); } Index: lib/Sema/SemaCUDA.cpp === --- lib/Sema/SemaCUDA.cpp +++ lib/Sema/SemaCUDA.cpp @@ -42,8 +42,9 @@ SourceLocation GGGLoc) { FunctionDecl *ConfigDecl = Context.getcudaConfigureCallDecl(); if (!ConfigDecl) -return ExprError(Diag(oc, diag::err_undeclared_var_use) - << "cudaConfigureCall"); +return ExprError( +Diag(oc, diag::err_undeclared_var_use) +<< (getLangOpts().HIP ? "hipConfigureCall" : "cudaConfigureCall")); QualType ConfigQTy = ConfigDecl->getType(); DeclRefExpr *ConfigDR = new (Context) Index: lib/Frontend/InitPreprocessor.cpp === --- lib/Frontend/InitPreprocessor.cpp +++ lib/Frontend/InitPreprocessor.cpp @@ -463,8 +463,10 @@ // Not "standard" per se, but available even with the -undef flag. if (LangOpts.AsmPreprocessor) Builder.defineMacro("__ASSEMBLER__"); - if (LangOpts.CUDA) + if (LangOpts.CUDA && !LangOpts.HIP) Builder.defineMacro("__CUDA__"); + if (LangOpts.HIP) +Builder.defineMacro("__HIP__"); } /// Initialize the predefined C++ language feature test macros defined in Index: lib/Frontend/FrontendActions.cpp === --- lib/Frontend/FrontendActions.cpp +++ lib/Frontend/FrontendActions.cpp @@ -733,6 +733,7 @@ case InputKind::ObjCXX:
[PATCH] D44984: [HIP] Add hip input kind and codegen for kernel launching
yaxunl marked 4 inline comments as done. yaxunl added inline comments. Comment at: lib/Frontend/InitPreprocessor.cpp:466-467 Builder.defineMacro("__ASSEMBLER__"); if (LangOpts.CUDA) Builder.defineMacro("__CUDA__"); + if (LangOpts.HIP) tra wrote: > Is `__CUDA__` supposed to be set during HIP compilation? My guess is that > `__HIP__` and `__CUDA__` should be mutually exclusive. > You do set LangOpts.CUDA during HIP compilation, so this should be changed to > `if (CUDA && ! HIP)` HIP documentation does not require `__CUDA__` to be defined. Will make changes as you suggested. https://reviews.llvm.org/D44984 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45783: [DEBUGINFO, NVPTX] Render `-no-cuda-debug` LLVM option when required.
ABataev created this revision. ABataev added reviewers: tra, jlebar, echristo. Herald added a subscriber: JDevlieghere. When emission of the lineinfo is requested for the NVPTX, render the LLVM `-no-cuda-debug` option to disable emission of the `debug` option in the `.target` directive. Required for the correct work of the ptxas tool, which does not allow emission of the optimized code in presence of the `debug` option. Repository: rC Clang https://reviews.llvm.org/D45783 Files: lib/Driver/ToolChains/Cuda.cpp test/Driver/cuda-dwarf-2.cu test/Driver/openmp-offload-gpu.c Index: test/Driver/openmp-offload-gpu.c === --- test/Driver/openmp-offload-gpu.c +++ test/Driver/openmp-offload-gpu.c @@ -182,6 +182,8 @@ // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \ // RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s +// LINE_TABLE: "-triple" "nvptx64-nvidia-cuda" +// LINE_TABLE-SAME: "-mllvm" "-no-cuda-debug" // NO_DEBUG: ptxas // LINE_TABLE: "-lineinfo" // NO_DEBUG-NOT: "-g" Index: test/Driver/cuda-dwarf-2.cu === --- test/Driver/cuda-dwarf-2.cu +++ test/Driver/cuda-dwarf-2.cu @@ -15,6 +15,8 @@ // RUN: %clang -### -target x86_64-linux-gnu -c --cuda-gpu-arch=sm_20 %s -gline-tables-only -O2 --cuda-noopt-device-debug 2>&1 | \ // RUN: FileCheck %s -check-prefix NO_DEBUG -check-prefix LINE_TABLE +// LINE_TABLE: "-triple" "nvptx64-nvidia-cuda" +// LINE_TABLE-SAME: "-mllvm" "-no-cuda-debug" // NO_DEBUG: ptxas // NO_DEBUG-NOT: "-g" // LINE_TABLE: "-lineinfo" Index: lib/Driver/ToolChains/Cuda.cpp === --- lib/Driver/ToolChains/Cuda.cpp +++ lib/Driver/ToolChains/Cuda.cpp @@ -283,23 +283,26 @@ } // anonymous namespace static DebugInfoKind mustEmitDebugInfo(const ArgList &Args) { - Arg *A = Args.getLastArg(options::OPT_O_Group); - if (Args.hasFlag(options::OPT_cuda_noopt_device_debug, - options::OPT_no_cuda_noopt_device_debug, - !A || A->getOption().matches(options::OPT_O0))) { -if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) { - const Option &Opt = A->getOption(); - if (Opt.matches(options::OPT_gN_Group)) { -if (Opt.matches(options::OPT_g0) || Opt.matches(options::OPT_ggdb0)) - return NoDebug; -if (Opt.matches(options::OPT_gline_tables_only) || -Opt.matches(options::OPT_ggdb1)) - return LineTableOnly; - } - return FullDebug; + const Arg *OptArg = Args.getLastArg(options::OPT_O_Group); + DebugInfoKind DIKind = NoDebug; + if (const Arg *DebugArg = Args.getLastArg(options::OPT_g_Group)) { +DIKind = FullDebug; +const Option &Opt = DebugArg->getOption(); +if (Opt.matches(options::OPT_gN_Group)) { + if (Opt.matches(options::OPT_g0) || Opt.matches(options::OPT_ggdb0)) +DIKind = NoDebug; + else if (Opt.matches(options::OPT_gline_tables_only) || + Opt.matches(options::OPT_ggdb1)) +DIKind = LineTableOnly; } } - return NoDebug; + if (Args.hasFlag(options::OPT_cuda_noopt_device_debug, + options::OPT_no_cuda_noopt_device_debug, + !OptArg || OptArg->getOption().matches(options::OPT_O0))) +return DIKind; + // If --no-cuda-noopt-device-debug is provided and O>0 and debug info + // requested - generate lineinfo. + return DIKind == NoDebug ? NoDebug : LineTableOnly; } void NVPTX::Assembler::ConstructJob(Compilation &C, const JobAction &JA, @@ -634,6 +637,13 @@ CC1Args.push_back("+ptx42"); } + // Disable emission of the `debug` option in the `.target` if the lineinfo is + // requested. + if (mustEmitDebugInfo(DriverArgs) == LineTableOnly) { +CC1Args.push_back("-mllvm"); +CC1Args.push_back("-no-cuda-debug"); + } + if (DeviceOffloadingKind == Action::OFK_OpenMP) { SmallVector LibraryPaths; // Add path to lib and/or lib64 folders. Index: test/Driver/openmp-offload-gpu.c === --- test/Driver/openmp-offload-gpu.c +++ test/Driver/openmp-offload-gpu.c @@ -182,6 +182,8 @@ // RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \ // RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s +// LINE_TABLE: "-triple" "nvptx64-nvidia-cuda" +// LINE_TABLE-SAME: "-mllvm" "-no-cuda-debug" // NO_DEBUG: ptxas // LINE_TABLE: "-lineinfo" // NO_DEBUG-NOT: "-g" Index: test/Driver/cuda-dwarf-2.cu === --- test/Driver/cuda-dwarf-2.cu +++ test/Driver/cuda-dwarf-2.cu @@ -15,6 +15,8 @@ // RUN
[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
JonasToth added inline comments. Comment at: clang-tidy/utils/ASTUtils.h:31 + +enum ExprModificationKind { + EMK_NotModified, /// The Expr is neither modified nor escaped. Maybe you could add an `Unknown` kind, e.g. if the expression is not found or similar. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45779: [ARM] Remove redundant #if in test
smeenai accepted this revision. smeenai added a comment. This revision is now accepted and ready to land. LGTM; it's an obvious NFC patch. Repository: rC Clang https://reviews.llvm.org/D45779 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330280 - [CUDA] added missing __ldg(const signed char *)
Author: tra Date: Wed Apr 18 11:33:43 2018 New Revision: 330280 URL: http://llvm.org/viewvc/llvm-project?rev=330280&view=rev Log: [CUDA] added missing __ldg(const signed char *) Differential Revision: https://reviews.llvm.org/D45780 Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=330280&r1=330279&r2=330280&view=diff == --- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original) +++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Wed Apr 18 11:33:43 2018 @@ -277,6 +277,9 @@ inline __device__ long long __ldg(const inline __device__ unsigned char __ldg(const unsigned char *ptr) { return __nvvm_ldg_uc(ptr); } +inline __device__ signed char __ldg(const signed char *ptr) { + return __nvvm_ldg_uc((const unsigned char *)ptr); +} inline __device__ unsigned short __ldg(const unsigned short *ptr) { return __nvvm_ldg_us(ptr); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45780: [CUDA] added missing __ldg(const signed char *)
This revision was automatically updated to reflect the committed changes. Closed by commit rC330280: [CUDA] added missing __ldg(const signed char *) (authored by tra, committed by ). Changed prior to commit: https://reviews.llvm.org/D45780?vs=142970&id=142974#toc Repository: rC Clang https://reviews.llvm.org/D45780 Files: lib/Headers/__clang_cuda_intrinsics.h Index: lib/Headers/__clang_cuda_intrinsics.h === --- lib/Headers/__clang_cuda_intrinsics.h +++ lib/Headers/__clang_cuda_intrinsics.h @@ -277,6 +277,9 @@ inline __device__ unsigned char __ldg(const unsigned char *ptr) { return __nvvm_ldg_uc(ptr); } +inline __device__ signed char __ldg(const signed char *ptr) { + return __nvvm_ldg_uc((const unsigned char *)ptr); +} inline __device__ unsigned short __ldg(const unsigned short *ptr) { return __nvvm_ldg_us(ptr); } Index: lib/Headers/__clang_cuda_intrinsics.h === --- lib/Headers/__clang_cuda_intrinsics.h +++ lib/Headers/__clang_cuda_intrinsics.h @@ -277,6 +277,9 @@ inline __device__ unsigned char __ldg(const unsigned char *ptr) { return __nvvm_ldg_uc(ptr); } +inline __device__ signed char __ldg(const signed char *ptr) { + return __nvvm_ldg_uc((const unsigned char *)ptr); +} inline __device__ unsigned short __ldg(const unsigned short *ptr) { return __nvvm_ldg_us(ptr); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45780: [CUDA] added missing __ldg(const signed char *)
tra created this revision. tra added a reviewer: jlebar. Herald added a subscriber: sanjoy. Until now we only had variants for 'char' and 'unsigned char'. In C++ 'char' 'unsigned char' and 'signed char' are three different types and we need overloads for all of them. https://reviews.llvm.org/D45780 Files: clang/lib/Headers/__clang_cuda_intrinsics.h Index: clang/lib/Headers/__clang_cuda_intrinsics.h === --- clang/lib/Headers/__clang_cuda_intrinsics.h +++ clang/lib/Headers/__clang_cuda_intrinsics.h @@ -277,6 +277,9 @@ inline __device__ unsigned char __ldg(const unsigned char *ptr) { return __nvvm_ldg_uc(ptr); } +inline __device__ signed char __ldg(const signed char *ptr) { + return __nvvm_ldg_uc((const unsigned char *)ptr); +} inline __device__ unsigned short __ldg(const unsigned short *ptr) { return __nvvm_ldg_us(ptr); } Index: clang/lib/Headers/__clang_cuda_intrinsics.h === --- clang/lib/Headers/__clang_cuda_intrinsics.h +++ clang/lib/Headers/__clang_cuda_intrinsics.h @@ -277,6 +277,9 @@ inline __device__ unsigned char __ldg(const unsigned char *ptr) { return __nvvm_ldg_uc(ptr); } +inline __device__ signed char __ldg(const signed char *ptr) { + return __nvvm_ldg_uc((const unsigned char *)ptr); +} inline __device__ unsigned short __ldg(const unsigned short *ptr) { return __nvvm_ldg_us(ptr); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D39053: [Bitfield] Add more cases to making the bitfield a separate location
mgrang added a comment. With this patch we get ~1800 bytes improvement on one of our internal codebases. I also ran spec2000/spec2006 validations (for RISCV) and there were no regressions. There were also no code size improvements seen in spec. https://reviews.llvm.org/D39053 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330279 - [HIP] Add driver input type for HIP
Author: yaxunl Date: Wed Apr 18 11:25:03 2018 New Revision: 330279 URL: http://llvm.org/viewvc/llvm-project?rev=330279&view=rev Log: [HIP] Add driver input type for HIP Patch by Greg Rodgers. Revised by Yaxun Liu. Differential Revision: https://reviews.llvm.org/D45489 Modified: cfe/trunk/include/clang/Driver/Types.def cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/Types.cpp Modified: cfe/trunk/include/clang/Driver/Types.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Types.def?rev=330279&r1=330278&r2=330279&view=diff == --- cfe/trunk/include/clang/Driver/Types.def (original) +++ cfe/trunk/include/clang/Driver/Types.def Wed Apr 18 11:25:03 2018 @@ -46,6 +46,9 @@ TYPE("cl", CL, TYPE("cuda-cpp-output", PP_CUDA, INVALID, "cui", "u") TYPE("cuda", CUDA, PP_CUDA, "cu","u") TYPE("cuda", CUDA_DEVICE, PP_CUDA, "cu","") +TYPE("hip-cpp-output", PP_HIP, INVALID, "cui", "u") +TYPE("hip", HIP, PP_HIP, "cu","u") +TYPE("hip", HIP_DEVICE, PP_HIP, "cu","") TYPE("objective-c-cpp-output", PP_ObjC, INVALID, "mi","u") TYPE("objc-cpp-output", PP_ObjC_Alias, INVALID,"mi","u") TYPE("objective-c", ObjC, PP_ObjC, "m", "u") Modified: cfe/trunk/lib/Driver/Driver.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=330279&r1=330278&r2=330279&view=diff == --- cfe/trunk/lib/Driver/Driver.cpp (original) +++ cfe/trunk/lib/Driver/Driver.cpp Wed Apr 18 11:25:03 2018 @@ -2257,9 +2257,10 @@ class OffloadingActionBuilder final { assert(!GpuArchList.empty() && "We should have at least one GPU architecture."); -// If the host input is not CUDA, we don't need to bother about this -// input. -if (IA->getType() != types::TY_CUDA) { +// If the host input is not CUDA or HIP, we don't need to bother about +// this input. +if (IA->getType() != types::TY_CUDA && +IA->getType() != types::TY_HIP) { // The builder will ignore this input. IsActive = false; return ABRT_Inactive; @@ -2272,9 +2273,12 @@ class OffloadingActionBuilder final { return ABRT_Success; // Replicate inputs for each GPU architecture. -for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) - CudaDeviceActions.push_back(C.MakeAction( - IA->getInputArg(), types::TY_CUDA_DEVICE)); +auto Ty = IA->getType() == types::TY_HIP ? types::TY_HIP_DEVICE + : types::TY_CUDA_DEVICE; +for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) { + CudaDeviceActions.push_back( + C.MakeAction(IA->getInputArg(), Ty)); +} return ABRT_Success; } Modified: cfe/trunk/lib/Driver/Types.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Types.cpp?rev=330279&r1=330278&r2=330279&view=diff == --- cfe/trunk/lib/Driver/Types.cpp (original) +++ cfe/trunk/lib/Driver/Types.cpp Wed Apr 18 11:25:03 2018 @@ -102,6 +102,9 @@ bool types::isAcceptedByClang(ID Id) { case TY_CL: case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE: + case TY_HIP: + case TY_PP_HIP: + case TY_HIP_DEVICE: case TY_ObjC: case TY_PP_ObjC: case TY_PP_ObjC_Alias: case TY_CXX: case TY_PP_CXX: case TY_ObjCXX: case TY_PP_ObjCXX: case TY_PP_ObjCXX_Alias: @@ -141,6 +144,9 @@ bool types::isCXX(ID Id) { case TY_ObjCXXHeader: case TY_PP_ObjCXXHeader: case TY_CXXModule: case TY_PP_CXXModule: case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE: + case TY_HIP: + case TY_PP_HIP: + case TY_HIP_DEVICE: return true; } } @@ -166,6 +172,9 @@ bool types::isCuda(ID Id) { case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE: + case TY_HIP: + case TY_PP_HIP: + case TY_HIP_DEVICE: return true; } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45489: [HIP] Add input type for HIP
This revision was automatically updated to reflect the committed changes. Closed by commit rL330279: [HIP] Add driver input type for HIP (authored by yaxunl, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D45489?vs=141851&id=142972#toc Repository: rL LLVM https://reviews.llvm.org/D45489 Files: cfe/trunk/include/clang/Driver/Types.def cfe/trunk/lib/Driver/Driver.cpp cfe/trunk/lib/Driver/Types.cpp Index: cfe/trunk/include/clang/Driver/Types.def === --- cfe/trunk/include/clang/Driver/Types.def +++ cfe/trunk/include/clang/Driver/Types.def @@ -46,6 +46,9 @@ TYPE("cuda-cpp-output", PP_CUDA, INVALID, "cui", "u") TYPE("cuda", CUDA, PP_CUDA, "cu","u") TYPE("cuda", CUDA_DEVICE, PP_CUDA, "cu","") +TYPE("hip-cpp-output", PP_HIP, INVALID, "cui", "u") +TYPE("hip", HIP, PP_HIP, "cu","u") +TYPE("hip", HIP_DEVICE, PP_HIP, "cu","") TYPE("objective-c-cpp-output", PP_ObjC, INVALID, "mi","u") TYPE("objc-cpp-output", PP_ObjC_Alias, INVALID,"mi","u") TYPE("objective-c", ObjC, PP_ObjC, "m", "u") Index: cfe/trunk/lib/Driver/Driver.cpp === --- cfe/trunk/lib/Driver/Driver.cpp +++ cfe/trunk/lib/Driver/Driver.cpp @@ -2257,9 +2257,10 @@ assert(!GpuArchList.empty() && "We should have at least one GPU architecture."); -// If the host input is not CUDA, we don't need to bother about this -// input. -if (IA->getType() != types::TY_CUDA) { +// If the host input is not CUDA or HIP, we don't need to bother about +// this input. +if (IA->getType() != types::TY_CUDA && +IA->getType() != types::TY_HIP) { // The builder will ignore this input. IsActive = false; return ABRT_Inactive; @@ -2272,9 +2273,12 @@ return ABRT_Success; // Replicate inputs for each GPU architecture. -for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) - CudaDeviceActions.push_back(C.MakeAction( - IA->getInputArg(), types::TY_CUDA_DEVICE)); +auto Ty = IA->getType() == types::TY_HIP ? types::TY_HIP_DEVICE + : types::TY_CUDA_DEVICE; +for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) { + CudaDeviceActions.push_back( + C.MakeAction(IA->getInputArg(), Ty)); +} return ABRT_Success; } Index: cfe/trunk/lib/Driver/Types.cpp === --- cfe/trunk/lib/Driver/Types.cpp +++ cfe/trunk/lib/Driver/Types.cpp @@ -102,6 +102,9 @@ case TY_CL: case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE: + case TY_HIP: + case TY_PP_HIP: + case TY_HIP_DEVICE: case TY_ObjC: case TY_PP_ObjC: case TY_PP_ObjC_Alias: case TY_CXX: case TY_PP_CXX: case TY_ObjCXX: case TY_PP_ObjCXX: case TY_PP_ObjCXX_Alias: @@ -141,6 +144,9 @@ case TY_ObjCXXHeader: case TY_PP_ObjCXXHeader: case TY_CXXModule: case TY_PP_CXXModule: case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE: + case TY_HIP: + case TY_PP_HIP: + case TY_HIP_DEVICE: return true; } } @@ -166,6 +172,9 @@ case TY_CUDA: case TY_PP_CUDA: case TY_CUDA_DEVICE: + case TY_HIP: + case TY_PP_HIP: + case TY_HIP_DEVICE: return true; } } Index: cfe/trunk/include/clang/Driver/Types.def === --- cfe/trunk/include/clang/Driver/Types.def +++ cfe/trunk/include/clang/Driver/Types.def @@ -46,6 +46,9 @@ TYPE("cuda-cpp-output", PP_CUDA, INVALID, "cui", "u") TYPE("cuda", CUDA, PP_CUDA, "cu","u") TYPE("cuda", CUDA_DEVICE, PP_CUDA, "cu","") +TYPE("hip-cpp-output", PP_HIP, INVALID, "cui", "u") +TYPE("hip", HIP, PP_HIP, "cu","u") +TYPE("hip", HIP_DEVICE, PP_HIP, "cu","") TYPE("objective-c-cpp-output", PP_ObjC, INVALID, "mi","u") TYPE("objc-cpp-output", PP_ObjC_Alias, INVALID,"mi","u") TYPE("objective-c", ObjC, PP_ObjC, "m", "u") Index: cfe/trunk/lib/Driver/Driver.cpp === --- cfe/trunk/lib/Driver/Driver.cpp +++ cfe/trunk/lib/Driver/Driver.cpp @@ -2257,9 +2257,10 @@ assert(!GpuArchList.empty() && "We should have at least one GPU architecture."); -// If the host inpu
[PATCH] D45779: [ARM] Remove redundant #if in test
strager created this revision. strager added a reviewer: cfe-commits. Herald added subscribers: chrib, kristof.beyls, javed.absar. Both sides of this #if #include the same file. Drop the #if, leaving only the #include. This commit should not change behaviour. Repository: rC Clang https://reviews.llvm.org/D45779 Files: test/CodeGen/arm-aapcs-vfp.c Index: test/CodeGen/arm-aapcs-vfp.c === --- test/CodeGen/arm-aapcs-vfp.c +++ test/CodeGen/arm-aapcs-vfp.c @@ -17,11 +17,7 @@ // RUN: -ffreestanding \ // RUN: -emit-llvm -w -o - %s | FileCheck -check-prefix=CHECK64 %s -#ifdef __arm64__ #include -#else -#include -#endif struct homogeneous_struct { float f[2]; Index: test/CodeGen/arm-aapcs-vfp.c === --- test/CodeGen/arm-aapcs-vfp.c +++ test/CodeGen/arm-aapcs-vfp.c @@ -17,11 +17,7 @@ // RUN: -ffreestanding \ // RUN: -emit-llvm -w -o - %s | FileCheck -check-prefix=CHECK64 %s -#ifdef __arm64__ #include -#else -#include -#endif struct homogeneous_struct { float f[2]; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45489: [HIP] Add input type for HIP
yaxunl added a comment. In https://reviews.llvm.org/D45489#1071177, @tra wrote: > In https://reviews.llvm.org/D45489#1071044, @yaxunl wrote: > > > In https://reviews.llvm.org/D45489#1070929, @yaxunl wrote: > > > > > In https://reviews.llvm.org/D45489#1070470, @tra wrote: > > > > > > > I'm getting confused about the order of the patches. > > > > The patch stack phabricator displays in this patch is different > > > > compared to the stack in https://reviews.llvm.org/D44984. Which one > > > > should I trust? > > > > > > > > > Sorry I think I may misunderstand the parent/child relation between > > > reviews. I thought a review depends on its parent reviews, i.e., parent > > > reviews should be committed first. Is that correct? Thanks. > > > > > > I think it is just visual difference. The relations are the same. > > > Would it be possible to arrange the changes in order in which you apply them > in the tree you are working on? If I want to try (partially) apply your > parches in my tree, it would help to know that what I get matches your setup. > Patch relationships as they are right now make intended order ambiguous. I reordered them as a simple linear relation. In the stack display, the patches should be applied from bottom to top. https://reviews.llvm.org/D45489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
JonasToth added a comment. I was thinking about that too. - We can extract all `DeclRefExpr` for the modifiying expressions and add dependencies. Such analysis is definitly interesting, but should maybe be added later. Having an internal `Expr` : `Modified?` mapping would suffice, too. The `isExprModified` will then first check if it is calculated and start calculation if not found. Am 18.04.2018 um 19:32 schrieb Eugene Zelenko via Phabricator: > Eugene.Zelenko added a comment. > > In https://reviews.llvm.org/D45679#1071116, @JonasToth wrote: > >> You are doing a great job and i learn new stuff :) >> >> - What do you think about having these functions in a class? Now, we need to >> recalculate and reanalyze the scope for every variable, multiple times >> (reference tracking). It would be nice to do it as lazy as possible and >> memorize the results. Especially addressing the use-case for the >> const-check, storing that a reference is not modified will save a lot of >> work = performance > > It may be reasonable to have variables/data members dependencies graph and > mark them as constant/non constant. > > Repository: > > rCTE Clang Tools Extra > > https://reviews.llvm.org/D45679 Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45489: [HIP] Add input type for HIP
tra added a comment. In https://reviews.llvm.org/D45489#1071044, @yaxunl wrote: > In https://reviews.llvm.org/D45489#1070929, @yaxunl wrote: > > > In https://reviews.llvm.org/D45489#1070470, @tra wrote: > > > > > I'm getting confused about the order of the patches. > > > The patch stack phabricator displays in this patch is different compared > > > to the stack in https://reviews.llvm.org/D44984. Which one should I trust? > > > > > > Sorry I think I may misunderstand the parent/child relation between > > reviews. I thought a review depends on its parent reviews, i.e., parent > > reviews should be committed first. Is that correct? Thanks. > > > I think it is just visual difference. The relations are the same. Would it be possible to arrange the changes in order in which you apply them in the tree you are working on? If I want to try (partially) apply your parches in my tree, it would help to know that what I get matches your setup. Patch relationships as they are right now make intended order ambiguous. https://reviews.llvm.org/D45489 ___ 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.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits m
[PATCH] D44604: Make stdarg.h compatible with FreeBSD
bsdjhb added a comment. FWIW, I ended up fixing FreeBSD to only use in freestanding environments and always use in userland which makes this patch no longer necessary. (Only one place needed to be fixed.) Repository: rC Clang https://reviews.llvm.org/D44604 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330277 - [MinGW] Try to fix asan testing after r330244
Author: mstorsjo Date: Wed Apr 18 10:34:29 2018 New Revision: 330277 URL: http://llvm.org/viewvc/llvm-project?rev=330277&view=rev Log: [MinGW] Try to fix asan testing after r330244 Twines shouldn't be stored as they can refer to temporaries. Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Modified: cfe/trunk/lib/Driver/ToolChains/MinGW.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/MinGW.cpp?rev=330277&r1=330276&r2=330277&view=diff == --- cfe/trunk/lib/Driver/ToolChains/MinGW.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/MinGW.cpp Wed Apr 18 10:34:29 2018 @@ -308,14 +308,13 @@ llvm::ErrorOr toolchains::M 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(); + StringRef ClangRoot = + llvm::sys::path::parent_path(getDriver().getInstalledDir()); + StringRef Sep = llvm::sys::path::get_separator(); for (StringRef CandidateSubdir : Subdirs) { -Twine Subdir = ClangRoot + CandidateSubdir; -if (llvm::sys::fs::is_directory(Subdir)) { +if (llvm::sys::fs::is_directory(ClangRoot + Sep + CandidateSubdir)) { Arch = CandidateSubdir; - return Subdir.str(); + return (ClangRoot + Sep + CandidateSubdir).str(); } } return make_error_code(std::errc::no_such_file_or_directory); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
Eugene.Zelenko added a comment. In https://reviews.llvm.org/D45679#1071116, @JonasToth wrote: > You are doing a great job and i learn new stuff :) > > - What do you think about having these functions in a class? Now, we need to > recalculate and reanalyze the scope for every variable, multiple times > (reference tracking). It would be nice to do it as lazy as possible and > memorize the results. Especially addressing the use-case for the const-check, > storing that a reference is not modified will save a lot of work = performance It may be reasonable to have variables/data members dependencies graph and mark them as constant/non constant. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44670: [CXX] Templates specialization visibility can be wrong
steven_wu added inline comments. Comment at: lib/AST/Decl.cpp:1078 +for (const auto *RD : + spec->getSpecializedTemplate()->getTemplatedDecl()->redecls()) { + auto Vis = getVisibilityOf(RD, kind); doug.gregor wrote: > Do we want to look at *all* redeclarations, or only those declarations that > precede the declaration that we found? The latter seems more correct, but > IIRC visibility has often been able to "look forward" to declarations that > come later in the translation unit. I agree the latter is more correct. Update the patch. Repository: rC Clang https://reviews.llvm.org/D44670 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44670: [CXX] Templates specialization visibility can be wrong
steven_wu updated this revision to Diff 142961. steven_wu added a comment. Address review feedback Repository: rC Clang https://reviews.llvm.org/D44670 Files: lib/AST/Decl.cpp test/CodeGenCXX/visibility-pr36810.cpp Index: test/CodeGenCXX/visibility-pr36810.cpp === --- /dev/null +++ test/CodeGenCXX/visibility-pr36810.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s + +namespace std { +template +class __attribute__((__type_visibility__("default"))) shared_ptr { + template friend class shared_ptr; +}; +} +struct dict; +#ifndef UNDEF_G +std::shared_ptr g; +#endif +class __attribute__((visibility("default"))) Bar; +template > +class __attribute__((visibility("default"))) i { + std::shared_ptr foo() const; +}; + +// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv +template <> std::shared_ptr i<>::foo() const { + return std::shared_ptr(); +} Index: lib/AST/Decl.cpp === --- lib/AST/Decl.cpp +++ lib/AST/Decl.cpp @@ -1092,9 +1092,18 @@ // If there wasn't explicit visibility there, and this is a // specialization of a class template, check for visibility // on the pattern. - if (const auto *spec = dyn_cast(ND)) -return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(), - kind); + if (const auto *spec = dyn_cast(ND)) { +// Walk all the template decl till this point to see if there are +// explicit visibility attributes. +const auto *TD = spec->getSpecializedTemplate()->getTemplatedDecl(); +while (TD != nullptr) { + auto Vis = getVisibilityOf(TD, kind); + if (Vis != None) +return Vis; + TD = TD->getPreviousDecl(); +} +return None; + } // Use the most recent declaration. if (!IsMostRecent && !isa(ND)) { Index: test/CodeGenCXX/visibility-pr36810.cpp === --- /dev/null +++ test/CodeGenCXX/visibility-pr36810.cpp @@ -0,0 +1,23 @@ +// RUN: %clang_cc1 -triple x86_64-apple-macosx -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-apple-macosx -DUNDEF_G -std=c++11 -fvisibility hidden -emit-llvm -o - %s -O2 -disable-llvm-passes | FileCheck %s + +namespace std { +template +class __attribute__((__type_visibility__("default"))) shared_ptr { + template friend class shared_ptr; +}; +} +struct dict; +#ifndef UNDEF_G +std::shared_ptr g; +#endif +class __attribute__((visibility("default"))) Bar; +template > +class __attribute__((visibility("default"))) i { + std::shared_ptr foo() const; +}; + +// CHECK: define void @_ZNK1iISt10shared_ptrI3BarEE3fooEv +template <> std::shared_ptr i<>::foo() const { + return std::shared_ptr(); +} Index: lib/AST/Decl.cpp === --- lib/AST/Decl.cpp +++ lib/AST/Decl.cpp @@ -1092,9 +1092,18 @@ // If there wasn't explicit visibility there, and this is a // specialization of a class template, check for visibility // on the pattern. - if (const auto *spec = dyn_cast(ND)) -return getVisibilityOf(spec->getSpecializedTemplate()->getTemplatedDecl(), - kind); + if (const auto *spec = dyn_cast(ND)) { +// Walk all the template decl till this point to see if there are +// explicit visibility attributes. +const auto *TD = spec->getSpecializedTemplate()->getTemplatedDecl(); +while (TD != nullptr) { + auto Vis = getVisibilityOf(TD, kind); + if (Vis != None) +return Vis; + TD = TD->getPreviousDecl(); +} +return None; + } // Use the most recent declaration. if (!IsMostRecent && !isa(ND)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41648: [clang-tidy] implement cppcoreguidelines macro rules
JonasToth added a comment. >> OpenCV isn't clean either, here the results: >> >> Filter: >> `ASSERT*|ALL*|CAL*|CC*|CALC*|calc*|CL*|cl*|CUDA*|CV*|cv*|EXPECT*|GTEST*|FUNCTOR*|HAVE*|ICV*|IPL*|IPP*|ipp*|__itt*|ITT*|JAS*|jas*|MESSAGE*|MAX*|OCL*|opengl*|OPENCV*|TYP*` > > This one worries me a bit more because of patterns like `cl*` and `calc*` -- > those seem like they're not uncommon and the pattern may silence otherwise > valid diagnostics. The macros are worriesome. Instead of using proper function overloading or similar constructs, they defined macros that replace function names + arguments. I would say, these macros were laziness, because C++ provides the proper language tools to deal with the missing overloading capabilities for C functions. I removed them because some many macros did exist. >> - it is possible to reduce macro usage to a minimal amount, and the complex >> macros like AST stuff can be filtered with the regex. Furthermore, >> restricting all macros to a "macro namespace" is possible for sure. > > I'm not certain I understand what you mean by "macro namespace". Can you > clarify? With "macro namespace" i mean a common prefix for macros, like `LLVM_UNREACHABLE`, `DEBUG_..`. > I'm still a bit worried about using regex to filter the results. It seems > like any real world project is going to require somewhere between a > reasonable and an unreasonable amount of configuration to reduce the noise. > Perhaps as a first pass, however, it will suffice. Hopefully we can add other > heuristics to reduce the false positives as we see patterns emerge from real > world usage. It was hard to find reasonable patterns. I definitely saw the usage that is not supposed to happen, like simulating inline functions, overloading, ... >> Things I would like to add to the check: >> >> - my little filtering script is valuable for developers, that want to >> address the macro issue. It should be added to the docs and everyone can >> make something based on that. It will be linux centered. > > Why does the usage need to be limited to Linux? I created small `sed` scripts with a chain of `uniq` and `sort`, so it will be UNIX, but windows falls short i guess. >> - enforcing ALL_CAPS, including its usage > > What does "including its usage" mean? The usage of the macro in code. That means not only definition of the macro is replaced, but all occurences. This can only be done if *all* macros are treated the same. Otherwise different TU, different transformation. >> Code transformation has the problems of scope and potentially breaking code >> badly, because clang-tidy wasn't run over all of the code. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D41648 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D43689: [analyzer] Disable constructor inlining when lifetime extension through fields occurs.
chh added a comment. This change caused an assertion failure in ExprEngineCXX.cpp: https://bugs.llvm.org/show_bug.cgi?id=37166 Repository: rC Clang https://reviews.llvm.org/D43689 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45685: [Sema] Add -wtest global flag that silences -Wself-assign for overloaded operators.
brooksmoses added a comment. Thanks for the summary, John. To confirm, I found two examples of bugs involving local variables, as well as the field-based examples. And, indeed, all of the false positives were in unit tests. Repository: rC Clang https://reviews.llvm.org/D45685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45777: [UnitTests] NFC/build-perf: Break up nontrivial compile jobs
davezarzycki created this revision. davezarzycki added reviewers: arphaman, sberg, delesley, james.dennett, jdennett, klimek. Herald added a subscriber: mgorny. RecursiveASTVisitorTest.cpp is one of the longest compile jobs and a build bottleneck on many-core machines. This patch breaks that file and some peer files up into smaller files to increase build concurrency and overall rebuild performance. Repository: rC Clang https://reviews.llvm.org/D45777 Files: Tooling/CMakeLists.txt Tooling/RecursiveASTVisitorTest.cpp Tooling/RecursiveASTVisitorTestExprVisitor.cpp Tooling/RecursiveASTVisitorTests/Attr.cpp Tooling/RecursiveASTVisitorTests/CXXBoolLiteralExpr.cpp Tooling/RecursiveASTVisitorTests/CXXOperatorCallExprTraverser.cpp Tooling/RecursiveASTVisitorTests/Class.cpp Tooling/RecursiveASTVisitorTests/ConstructExpr.cpp Tooling/RecursiveASTVisitorTests/DeclRefExpr.cpp Tooling/RecursiveASTVisitorTests/ImplicitCtor.cpp Tooling/RecursiveASTVisitorTests/InitListExprPostOrder.cpp Tooling/RecursiveASTVisitorTests/InitListExprPostOrderNoQueue.cpp Tooling/RecursiveASTVisitorTests/InitListExprPreOrder.cpp Tooling/RecursiveASTVisitorTests/InitListExprPreOrderNoQueue.cpp Tooling/RecursiveASTVisitorTests/IntegerLiteral.cpp Tooling/RecursiveASTVisitorTests/LambdaDefaultCapture.cpp Tooling/RecursiveASTVisitorTests/LambdaExpr.cpp Tooling/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp Tooling/RecursiveASTVisitorTests/ParenExpr.cpp Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp unittests/Tooling/RecursiveASTVisitorTestCallVisitor.cpp unittests/Tooling/RecursiveASTVisitorTests/CXXMemberCall.cpp Index: Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp === --- /dev/null +++ Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp @@ -0,0 +1,40 @@ +//===- unittest/Tooling/RecursiveASTVisitorTests/TemplateArgumentLocTraverser.cpp -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "TestVisitor.h" + +using namespace clang; + +namespace { + +class TemplateArgumentLocTraverser + : public ExpectedLocationVisitor { +public: + bool TraverseTemplateArgumentLoc(const TemplateArgumentLoc &ArgLoc) { +std::string ArgStr; +llvm::raw_string_ostream Stream(ArgStr); +const TemplateArgument &Arg = ArgLoc.getArgument(); + +Arg.print(Context->getPrintingPolicy(), Stream); +Match(Stream.str(), ArgLoc.getLocation()); +return ExpectedLocationVisitor:: + TraverseTemplateArgumentLoc(ArgLoc); + } +}; + +TEST(RecursiveASTVisitor, VisitsClassTemplateTemplateParmDefaultArgument) { + TemplateArgumentLocTraverser Visitor; + Visitor.ExpectMatch("X", 2, 40); + EXPECT_TRUE(Visitor.runOver( +"template class X;\n" +"template class T = X> class Y;\n" +"template class T> class Y {};\n")); +} + +} // end anonymous namespace Index: Tooling/RecursiveASTVisitorTests/ParenExpr.cpp === --- /dev/null +++ Tooling/RecursiveASTVisitorTests/ParenExpr.cpp @@ -0,0 +1,30 @@ +//===- unittest/Tooling/RecursiveASTVisitorTests/ParenExpr.cpp ===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "TestVisitor.h" + +using namespace clang; + +namespace { + +class ParenExprVisitor : public ExpectedLocationVisitor { +public: + bool VisitParenExpr(ParenExpr *Parens) { +Match("", Parens->getExprLoc()); +return true; + } +}; + +TEST(RecursiveASTVisitor, VisitsParensDuringDataRecursion) { + ParenExprVisitor Visitor; + Visitor.ExpectMatch("", 1, 9); + EXPECT_TRUE(Visitor.runOver("int k = (4) + 9;\n")); +} + +} // end anonymous namespace Index: Tooling/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp === --- /dev/null +++ Tooling/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp @@ -0,0 +1,74 @@ +//===- unittest/Tooling/RecursiveASTVisitorTests/NestedNameSpecifiers.cpp -===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// + +#include "TestVisitor.h" + +using namespace clang; + +namespace { + +// Check to ensure that nested name specifiers are visited. +class NestedNameSpecifiersVisitor +: public ExpectedLocationVisitor { +public: + bool VisitRecordTypeLoc(Recor
[PATCH] D45679: [clang-tidy] Add a helper function isModified, that checks whether an expression is modified within a statement.
JonasToth added a comment. You are doing a great job and i learn new stuff :) Inspired by the analysis tool in clangs repo: - What do you think about having these functions in a class? Now, we need to recalculate and reanalyze the scope for every variable, multiple times (reference tracking). It would be nice to do it as lazy as possible and memorize the results. Especially addressing the use-case for the const-check, storing that a reference is not modified will save a lot of work = performance - Do we need to distinguish between `Espaced` and `Modified`? Having only two states will simplify some calculations (`e.g. if (std::none_of(Expr, isModified) return EMK_Const`) - i think the multiple analysis sections could be functions on their own. If you create a class for the check, these should be private methods or helpers. At the moment, some sections are hard to understand and some simplifications could be made. - what do you think creating a real `ModificationReport` that is stored per `Expr`? That can be helpful for a check like `readability-complex-modification`, dependency analysis and others. The `Chain` is in that direction, but not consistent from what i see. Storing this chain in the potential `ModificationAnalyzer` class would be superb. Comment at: clang-tidy/utils/ASTUtils.cpp:125 + const auto AsNonConstRefArg = + anyOf(callExpr(NonConstRefParam), cxxConstructExpr(NonConstRefParam)); + I am suprised that `callExpr` does not cover constructor calls. Or is there more? Comment at: clang-tidy/utils/ASTUtils.cpp:149 + Stm, *Context); + if (const auto *S = selectFirst("mod", ModOrEsc)) { +if (Chain != nullptr) Having the history for the trivial modifications would be nice, too. I think treating all kinds of modifications is best. Comment at: clang-tidy/utils/ASTUtils.cpp:160 + + const auto isExprModified = [&](ArrayRef Results) { +for (const auto &Node : Results) { Having such a lambda is somewhat weird and redundant, because it mimics the original function. I think that should be refactored with a short discussion in the general comments if thats ok for you. Comment at: clang-tidy/utils/ASTUtils.cpp:180 + Stm, *Context); + if (const auto Kind = isExprModified(MemberExprs)) +return Kind; The implicit `NotModified` == 0 is hard to see. Maybe a transition towards a `std::any_of(Expr, isModified)` is more readable. (see general comment) Comment at: clang-tidy/utils/ASTUtils.cpp:188 + Stm, *Context); + if (const auto Kind = isExprModified(SubscriptExprs)) +return Kind; Same + code duplication. Comment at: clang-tidy/utils/ASTUtils.cpp:200 + Stm, *Context); + if (const auto Kind = isExprModified(Casts)) +return Kind; dito Comment at: clang-tidy/utils/ASTUtils.cpp:220 +Stm, *Context); +if (const auto Kind = isExprModified(Exprs)) + return Kind; This section of the code is hard to understand. Comment at: clang-tidy/utils/ASTUtils.cpp:222 + return Kind; +if (Chain != nullptr) + Chain->pop_back(); The pop is not clear to me Comment at: clang-tidy/utils/ASTUtils.cpp:246 +const auto Exprs = match( +findAll(declRefExpr(to(equalsNode(DeclNode.getNodeAs("decl" +.bind("expr")), Code duplication for finding all `declRefExpr` to that expr. Comment at: clang-tidy/utils/ASTUtils.cpp:252 +if (Chain != nullptr) + Chain->pop_back(); + } same + code duplication Comment at: unittests/clang-tidy/IsModifiedTest.cpp:138 + +TEST(IsModifiedTest, ConstOperator) { + const auto AST = tooling::buildASTFromCode( Could you please add tests for overloaded operators as free functions? Arithmetic operators can usually be free functions and take by const& or &. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45679 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D40988: Clang-format: add finer-grained options for putting all arguments on one line
uohcsemaj added a comment. ping @djasper can we make a decision here this patch? I would really like to use these new styles :( https://reviews.llvm.org/D40988 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45776: [clang-tidy] Customize FileCheck prefix in check_clang-tidy.py
zinovy.nis created this revision. zinovy.nis added a project: clang-tools-extra. Herald added subscribers: cfe-commits, xazax.hun. The patch introduces a new command line option `-check_suffix` to allow multiple %check_clang_tidy% in tests. Sample: // RUN: %check_clang_tidy %s misc-unused-using-decls %t -check_suffix=-FLAG_1-- // RUN: %check_clang_tidy %s misc-unused-using-decls %t -check_suffix=-FLAG_2 -- ... +// CHECK-MESSAGES-FLAG_1: :[[@LINE-4]]:10: warning: using decl 'B' is unused [misc-unused-using-decls] +// CHECK-MESSAGES-FLAG_2: :[[@LINE-7]]:10: warning: using decl 'A' is unused [misc-unused-using-decls] +// CHECK-FIXES-FLAG_1-NOT: using a::A;$ +// CHECK-FIXES-FLAG_2-NOT: using a::B;$ Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45776 Files: test/clang-tidy/check_clang_tidy.cpp test/clang-tidy/check_clang_tidy.py Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -42,6 +42,7 @@ parser.add_argument('-expect-clang-tidy-error', action='store_true') parser.add_argument('-resource-dir') parser.add_argument('-assume-filename') + parser.add_argument('-check_suffix', default='') parser.add_argument('input_file_name') parser.add_argument('check_name') parser.add_argument('temp_file_name') @@ -70,6 +71,12 @@ clang_tidy_extra_args.extend( ['-fobjc-abi-version=2', '-fobjc-arc']) + if args.check_suffix and not re.match('^[A-Z0-9-_]+$', args.check_suffix): +sys.exit('Only A..Z, 0..9, "-" and "_" are allowed in check suffix, but "%s" was given' % (args.check_suffix)) + + check_fixes_prefix = 'CHECK-FIXES' + args.check_suffix + check_messages_prefix = 'CHECK-MESSAGES' + args.check_suffix + # Tests should not rely on STL being available, and instead provide mock # implementations of relevant APIs. clang_tidy_extra_args.append('-nostdinc++') @@ -80,17 +87,19 @@ with open(input_file_name, 'r') as input_file: input_text = input_file.read() - has_check_fixes = input_text.find('CHECK-FIXES') >= 0 - has_check_messages = input_text.find('CHECK-MESSAGES') >= 0 + has_check_fixes = check_fixes_prefix in input_text + has_check_messages = check_messages_prefix in input_text if not has_check_fixes and not has_check_messages: -sys.exit('Neither CHECK-FIXES nor CHECK-MESSAGES found in the input') +sys.exit('Neither %s nor %s found in the input' % (check_fixes_prefix, check_messages_prefix) ) # Remove the contents of the CHECK lines to avoid CHECKs matching on # themselves. We need to keep the comments to preserve line numbers while # avoiding empty lines which could potentially trigger formatting-related # checks. - cleaned_test = re.sub('// *CHECK-[A-Z-]*:[^\r\n]*', '//', input_text) + cleaned_test = re.sub('// *CHECK-[A-Z0-9\-_]*:[^\r\n]*', '//', input_text) + + print "\n\n\n>>>",input_text, "<<-\n\n" write_file(temp_file_name, cleaned_test) @@ -128,7 +137,7 @@ try: subprocess.check_output( ['FileCheck', '-input-file=' + temp_file_name, input_file_name, - '-check-prefix=CHECK-FIXES', '-strict-whitespace'], + '-check-prefix=' + check_fixes_prefix, '-strict-whitespace'], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: print('FileCheck failed:\n' + e.output.decode()) @@ -140,7 +149,7 @@ try: subprocess.check_output( ['FileCheck', '-input-file=' + messages_file, input_file_name, - '-check-prefix=CHECK-MESSAGES', + '-check-prefix=' + check_messages_prefix, '-implicit-check-not={{warning|error}}:'], stderr=subprocess.STDOUT) except subprocess.CalledProcessError as e: Index: test/clang-tidy/check_clang_tidy.cpp === --- /dev/null +++ test/clang-tidy/check_clang_tidy.cpp @@ -0,0 +1,15 @@ +// RUN: %check_clang_tidy %s misc-unused-using-decls %t +// RUN: %check_clang_tidy %s misc-unused-using-decls %t -check_suffix=-FLAG -- -DFLAG +namespace a { class A {}; class B {};} +namespace b { +#if defined(FLAG) +using a::A; +#else +using a::B; +#endif +} +namespace c {} +// CHECK-MESSAGES: :[[@LINE-4]]:10: warning: using decl 'B' is unused [misc-unused-using-decls] +// CHECK-MESSAGES-FLAG: :[[@LINE-7]]:10: warning: using decl 'A' is unused [misc-unused-using-decls] +// CHECK-FIXES-FLAG-NOT: using a::A;$ +// CHECK-FIXES-NOT: using a::B;$ \ No newline at end of file Index: test/clang-tidy/check_clang_tidy.py === --- test/clang-tidy/check_clang_tidy.py +++ test/clang-tidy/check_clang_tidy.py @@ -42,6 +42,7 @@ parser.add_argument('-expect-clang-tidy-error', action='store_true') parser.add_argument('-resource-dir') parser.add_argument('-assume-fil
[PATCH] D42581: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.
This revision was automatically updated to reflect the committed changes. Closed by commit rL330272: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices. (authored by ABataev, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D42581?vs=132016&id=142954#toc Repository: rL LLVM https://reviews.llvm.org/D42581 Files: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp cfe/trunk/lib/Driver/ToolChains/Cuda.h cfe/trunk/test/Driver/cuda-dwarf-2.cu cfe/trunk/test/Driver/cuda-external-tools.cu cfe/trunk/test/Driver/openmp-offload-gpu.c Index: cfe/trunk/test/Driver/openmp-offload-gpu.c === --- cfe/trunk/test/Driver/openmp-offload-gpu.c +++ cfe/trunk/test/Driver/openmp-offload-gpu.c @@ -165,3 +165,51 @@ // RUN: | FileCheck -check-prefix=CHK-BCLIB-WARN %s // CHK-BCLIB-WARN: No library 'libomptarget-nvptx-sm_20.bc' found in the default clang lib directory or in LIBRARY_PATH. Expect degraded performance due to no inlining of runtime functions on target devices. + +/// Check that debug info is emitted in dwarf-2 +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --no-cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=NO_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 2>&1 \ +// RUN: | FileCheck -check-prefix=NO_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --no-cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=NO_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g0 2>&1 \ +// RUN: | FileCheck -check-prefix=NO_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb0 -O3 --cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=NO_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -gline-tables-only 2>&1 \ +// RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb1 -O2 --cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=NO_DEBUG -check-prefix=LINE_TABLE %s + +// NO_DEBUG: ptxas +// LINE_TABLE: "-lineinfo" +// NO_DEBUG-NOT: "-g" +// NO_DEBUG: nvlink +// NO_DEBUG-NOT: "-g" + +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g 2>&1 \ +// RUN: | FileCheck -check-prefix=HAS_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O0 --cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=HAS_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g -O3 --cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=HAS_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g2 2>&1 \ +// RUN: | FileCheck -check-prefix=HAS_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb2 -O0 --cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=HAS_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -g3 -O3 --cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=HAS_DEBUG %s +// RUN: %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -Xopenmp-target -march=sm_60 %s -ggdb3 -O2 --cuda-noopt-device-debug 2>&1 \ +// RUN: | FileCheck -check-prefix=HAS_DEBUG %s + +// HAS_DEBUG: "-triple" "nvptx64-nvidia-cuda" +// HAS_DEBUG-SAME: "-dwarf-version=2" +// HAS_DEBUG-SAME: "-fopenmp-is-device" +// HAS_DEBUG: ptxas +// HAS_DEBUG-SAME: "-g" +// HAS_DEBUG-SAME: "--dont-merge-basicblocks" +// HAS_DEBUG-SAME: "--return-at-end" +// HAS_DEBUG: nvlink +// HAS_DEBUG-SAME: "-g" + Index: cfe/trunk/test/Driver/cuda-external-tools.cu === --- cfe/trunk/test/Driver/cuda-external-tools.cu +++ cfe/trunk/test/Driver/cuda-external-tools.cu @@ -23,7 +23,7 @@ // RUN: | FileCheck -check-prefixes=CHECK,ARCH64,SM20,RDC %s // With debugging enabled, ptxas should be run with with no ptxas optimization
r330272 - [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices.
Author: abataev Date: Wed Apr 18 09:31:09 2018 New Revision: 330272 URL: http://llvm.org/viewvc/llvm-project?rev=330272&view=rev Log: [NVPTX] Emit debug info in DWARF-2 by default for Cuda devices. Summary: NVPTX target supports debug info in DWARF-2 format. Patch adds emission of debug info in DWARF-2 by default. Reviewers: tra, jlebar Subscribers: aprantl, JDevlieghere, cfe-commits Differential Revision: https://reviews.llvm.org/D42581 Added: cfe/trunk/test/Driver/cuda-dwarf-2.cu Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp cfe/trunk/lib/Driver/ToolChains/Cuda.h cfe/trunk/test/Driver/cuda-external-tools.cu cfe/trunk/test/Driver/openmp-offload-gpu.c Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=330272&r1=330271&r2=330272&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original) +++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Wed Apr 18 09:31:09 2018 @@ -273,6 +273,35 @@ void CudaInstallationDetector::print(raw << CudaVersionToString(Version) << "\n"; } +namespace { + /// Debug info kind. +enum DebugInfoKind { + NoDebug, /// No debug info. + LineTableOnly, /// Line tables only. + FullDebug /// Full debug info. +}; +} // anonymous namespace + +static DebugInfoKind mustEmitDebugInfo(const ArgList &Args) { + Arg *A = Args.getLastArg(options::OPT_O_Group); + if (Args.hasFlag(options::OPT_cuda_noopt_device_debug, + options::OPT_no_cuda_noopt_device_debug, + !A || A->getOption().matches(options::OPT_O0))) { +if (const Arg *A = Args.getLastArg(options::OPT_g_Group)) { + const Option &Opt = A->getOption(); + if (Opt.matches(options::OPT_gN_Group)) { +if (Opt.matches(options::OPT_g0) || Opt.matches(options::OPT_ggdb0)) + return NoDebug; +if (Opt.matches(options::OPT_gline_tables_only) || +Opt.matches(options::OPT_ggdb1)) + return LineTableOnly; + } + return FullDebug; +} + } + return NoDebug; +} + void NVPTX::Assembler::ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, @@ -304,8 +333,8 @@ void NVPTX::Assembler::ConstructJob(Comp ArgStringList CmdArgs; CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-m64" : "-m32"); - if (Args.hasFlag(options::OPT_cuda_noopt_device_debug, - options::OPT_no_cuda_noopt_device_debug, false)) { + DebugInfoKind DIKind = mustEmitDebugInfo(Args); + if (DIKind == FullDebug) { // ptxas does not accept -g option if optimization is enabled, so // we ignore the compiler's -O* options if we want debug info. CmdArgs.push_back("-g"); @@ -341,6 +370,8 @@ void NVPTX::Assembler::ConstructJob(Comp // to no optimizations, but ptxas's default is -O3. CmdArgs.push_back("-O0"); } + if (DIKind == LineTableOnly) +CmdArgs.push_back("-lineinfo"); // Pass -v to ptxas if it was passed to the driver. if (Args.hasArg(options::OPT_v)) @@ -410,6 +441,8 @@ void NVPTX::Linker::ConstructJob(Compila CmdArgs.push_back(TC.getTriple().isArch64Bit() ? "-64" : "-32"); CmdArgs.push_back(Args.MakeArgString("--create")); CmdArgs.push_back(Args.MakeArgString(Output.getFilename())); + if (mustEmitDebugInfo(Args) == FullDebug) +CmdArgs.push_back("-g"); for (const auto& II : Inputs) { auto *A = II.getAction(); @@ -461,7 +494,7 @@ void NVPTX::OpenMPLinker::ConstructJob(C CmdArgs.push_back(Output.getFilename()); } else assert(Output.isNothing() && "Invalid output."); - if (Args.hasArg(options::OPT_g_Flag)) + if (mustEmitDebugInfo(Args) == FullDebug) CmdArgs.push_back("-g"); if (Args.hasArg(options::OPT_v)) Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.h?rev=330272&r1=330271&r2=330272&view=diff == --- cfe/trunk/lib/Driver/ToolChains/Cuda.h (original) +++ cfe/trunk/lib/Driver/ToolChains/Cuda.h Wed Apr 18 09:31:09 2018 @@ -180,6 +180,8 @@ public: computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const override; + unsigned GetDefaultDwarfVersion() const override { return 2; } + const ToolChain &HostTC; CudaInstallationDetector CudaInstallation; Added: cfe/trunk/test/Driver/cuda-dwarf-2.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-dwarf-2.cu?rev=330272&view=auto == --- cfe/trunk/test/Driver/cuda-dwarf-2.cu (added) +++ cfe/trunk/test/Driver/cuda-dwarf-2.cu Wed Apr 18 09:31:09 2018 @@ -0,0 +1,47 @@ +// REQUIRES: clang-driver +// +// RUN: %cl
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
[PATCH] D44788: Add an option to support debug fission on implicit ThinLTO.
yunlian added a comment. ping? https://reviews.llvm.org/D44788 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45489: [HIP] Add input type for HIP
yaxunl added a comment. In https://reviews.llvm.org/D45489#1070929, @yaxunl wrote: > In https://reviews.llvm.org/D45489#1070470, @tra wrote: > > > I'm getting confused about the order of the patches. > > The patch stack phabricator displays in this patch is different compared > > to the stack in https://reviews.llvm.org/D44984. Which one should I trust? > > > Sorry I think I may misunderstand the parent/child relation between reviews. > I thought a review depends on its parent reviews, i.e., parent reviews should > be committed first. Is that correct? Thanks. I think it is just visual difference. The relations are the same. https://reviews.llvm.org/D45489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45774: [analyzer] cover more cases where a Loc can be bound to constants
r.stahl added a comment. Not sure how to proceed about these: - CXXDynamicCastExpr: I don't think evalCast would handle this correctly, does it? - ObjCBridgedCastExpr: I don't know ObjectiveC - CastKinds for floating point: Floats cannot yet be handled by the analyzer, right? Repository: rC Clang https://reviews.llvm.org/D45774 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45774: [analyzer] cover more cases where a Loc can be bound to constants
r.stahl created this revision. r.stahl added reviewers: NoQ, dcoughlin, xazax.hun. Herald added subscribers: cfe-commits, a.sidorin, rnkovacs, szepet, mehdi_amini. Herald added a reviewer: george.karpenkov. - SValBuilder::getConstantVal stopped processing an initialization if there are intermediate casts. Now additionally handles CStyleCastExpr, CXXConstCastExpr, CXXReinterpretCastExpr, CXXStaticCastExpr, CXXFunctionalCastExpr. Additional CastKinds are CK_NoOp and CK_IntegralToPointer - the others are already handled by EvaluateAsInt. - RegionStoreManager::getBindingForElement now resolves a constant array initialization. - RegionStoreManager::getBindingForField now resolves constant in-class initializers and constant element-wise initialization. - Added tests for all new cases. Repository: rC Clang https://reviews.llvm.org/D45774 Files: lib/StaticAnalyzer/Core/RegionStore.cpp lib/StaticAnalyzer/Core/SValBuilder.cpp test/Analysis/globals.cpp Index: test/Analysis/globals.cpp === --- test/Analysis/globals.cpp +++ test/Analysis/globals.cpp @@ -0,0 +1,101 @@ +// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s + + +static const unsigned long long scull = 0; +void static_int() +{ +*(int*)scull = 0; // expected-warning{{Dereference of null pointer}} +} + +const unsigned long long cull = 0; +void const_int() +{ +*(int*)cull = 0; // expected-warning{{Dereference of null pointer}} +} + +static int * const spc = 0; +void static_ptr() +{ +*spc = 0; // expected-warning{{Dereference of null pointer}} +} + +int * const pc = 0; +void const_ptr() +{ +*pc = 0; // expected-warning{{Dereference of null pointer}} +} + +const unsigned long long cull_nonnull = 4; +void nonnull_int() +{ +*(int*)(cull_nonnull - 4) = 0; // expected-warning{{Dereference of null pointer}} +} + +int * const pc_nonnull = (int*)sizeof(int); +void nonnull_ptr() +{ +*(pc_nonnull - 1) = 0; // expected-warning{{Dereference of null pointer}} +} + +int * const constcast = const_cast((int*)sizeof(int)); +void cast1() +{ +*(constcast - 1) = 0; // expected-warning{{Dereference of null pointer}} +} + +int * const recast = reinterpret_cast(sizeof(int)); +void cast2() +{ +*(recast - 1) = 0; // expected-warning{{Dereference of null pointer}} +} + +int * const staticcast = static_cast((int*)sizeof(int)); +void cast3() +{ +*(staticcast - 1) = 0; // expected-warning{{Dereference of null pointer}} +} + +struct Foo { int a; }; +Foo * const dyncast = dynamic_cast((Foo*)sizeof(Foo)); +void cast4() +{ +// Do not handle dynamic_cast for now, because it may change the pointer value. +(dyncast - 1)->a = 0; // no-warning +} + +typedef int * const intptrconst; +int * const funccast = intptrconst(sizeof(int)); +void cast5() +{ +*(funccast - 1) = 0; // expected-warning{{Dereference of null pointer}} +} + +struct S1 +{ +int * p; +}; +const S1 s1 = { +.p = (int*)sizeof(int) +}; +void conststruct() +{ +*(s1.p - 1) = 0; // expected-warning{{Dereference of null pointer}} +} + +struct S2 +{ +int * const p; +}; +S2 s2 = { +.p = (int*)sizeof(int) +}; +void constfield() +{ +*(s2.p - 1) = 0; // expected-warning{{Dereference of null pointer}} +} + +int * const parr[1] = { (int*)sizeof(int) }; +void constarr() +{ +*(parr[0] - 1) = 0; // expected-warning{{Dereference of null pointer}} +} Index: lib/StaticAnalyzer/Core/RegionStore.cpp === --- lib/StaticAnalyzer/Core/RegionStore.cpp +++ lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1606,7 +1606,7 @@ const MemRegion* superR = R->getSuperRegion(); // Check if the region is an element region of a string literal. - if (const StringRegion *StrR=dyn_cast(superR)) { + if (const StringRegion *StrR = dyn_cast(superR)) { // FIXME: Handle loads from strings where the literal is treated as // an integer, e.g., *((unsigned int*)"hello") QualType T = Ctx.getAsArrayType(StrR->getValueType())->getElementType(); @@ -1629,6 +1629,29 @@ char c = (i >= length) ? '\0' : Str->getCodeUnit(i); return svalBuilder.makeIntVal(c, T); } + } else if (const VarRegion *VR = dyn_cast(superR)) { +// Check if the containing array is const and has an initialized value. +const VarDecl *VD = VR->getDecl(); +// Either the array or the array element has to be const. +if (VD->getType().isConstQualified() || R->getElementType().isConstQualified()) { + if (const Expr *Init = VD->getInit()) { +if (const InitListExpr *InitList = dyn_cast(Init)) { + // The array index has to be known. + if (Optional CI = R->getIndex().getAs()) { +int64_t i = CI->getValue().getSExtValue(); +// Return unknown value if index is out of bounds. +if (i < 0 || i >= InitList->getNumInits()) { + return UnknownVal(); +} + +if (
[PATCH] D45223: [CUDA] Fix overloading resolution failure due to kernel calling convention
yaxunl added a comment. In https://reviews.llvm.org/D45223#1056187, @rjmccall wrote: > I think the appropriate place to do this is in IsStandardConversion, > immediately after the call to ResolveAddressOfOverloadedFunction. You might > want to add a general utility for getting the type-of-reference of a function > decl. We may need to resolve overloaded functions with dropped calling conventions, e.g. __global__ void EmptyKernel(float) {} __global__ void EmptyKernel(double) {} struct Dummy { /// Type definition of the EmptyKernel kernel entry point typedef void (*EmptyKernelPtr)(float); EmptyKernelPtr Empty() { return EmptyKernel; } }; In this case we have to drop the calling convention during the resolution. Since the calling convention is invisible in the AST, why don't why just do not represent it in AST? Going back to the original implementation in CodeGen: if ((getTriple().getArch() == llvm::Triple::amdgcn) && D->hasAttr()) Fn->setCallingConv(llvm::CallingConv::AMDGPU_KERNEL); It is much simpler and straightforward. Can we just reconsider implement this in CodeGen instead of Sema? https://reviews.llvm.org/D45223 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45750: add extra acronyms for objc property names
benhamilton accepted this revision. benhamilton added inline comments. This revision is now accepted and ready to land. Comment at: clang-tidy/objc/PropertyDeclarationCheck.cpp:42 constexpr llvm::StringLiteral DefaultSpecialAcronyms[] = { +"[2-9]G", "ACL", Probably should just make this: "\\d+G" Comment at: test/clang-tidy/objc-property-declaration.m:21 +@property(assign, nonatomic) int centerX; +@property(assign, nonatomic) int enbale2GBackgroundFetch; @end enbale -> enable Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45750 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45771: [Driver] Support for -save-stats in AddGoldPlugin.
fhahn created this revision. fhahn added reviewers: tejohnson, mehdi_amini, compnerd. Herald added a subscriber: emaste. fhahn added a dependency: D45531: [LTO] Add stats-file option to LTO/Config.h.. This patch updates AddGoldPlugin to pass stats-file to the Gold plugin, if -save-stats is passed. It also moves the save-stats option handling to a helper function tools::getStatsFileName. Repository: rC Clang https://reviews.llvm.org/D45771 Files: lib/Driver/ToolChains/Ananas.cpp lib/Driver/ToolChains/Clang.cpp lib/Driver/ToolChains/CloudABI.cpp lib/Driver/ToolChains/CommonArgs.cpp lib/Driver/ToolChains/CommonArgs.h lib/Driver/ToolChains/FreeBSD.cpp lib/Driver/ToolChains/Gnu.cpp test/Driver/save-stats.c Index: test/Driver/save-stats.c === --- test/Driver/save-stats.c +++ test/Driver/save-stats.c @@ -18,3 +18,11 @@ // RUN: %clang -target x86_64-apple-darwin -save-stats=bla -c %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-INVALID // CHECK-INVALID: invalid value 'bla' in '-save-stats=bla' + +// RUN: %clang -target x86_64-linux-unknown -save-stats -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO +// CHECK-LTO: "-stats-file=save-stats.stats" +// CHECK-LTO: "-o" "obj/dir{{/|}}save-stats.exe" +// CHECK-LTO: "-plugin-opt=stats-file=save-stats.stats" + +// RUN: %clang -target x86_64-linux-unknown -save-stats=obj -flto -o obj/dir/save-stats.exe %s -### 2>&1 | FileCheck %s -check-prefix=CHECK-LTO-OBJ +// CHECK-LTO-OBJ: "-plugin-opt=stats-file=obj/dir/save-stats.stats" Index: lib/Driver/ToolChains/Gnu.cpp === --- lib/Driver/ToolChains/Gnu.cpp +++ lib/Driver/ToolChains/Gnu.cpp @@ -435,8 +435,11 @@ ToolChain.AddFilePathLibArgs(Args, CmdArgs); - if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); + if (D.isUsingLTO()) { +assert(!Inputs.empty() && "Must have at least one input."); +AddGoldPlugin(ToolChain, Output, Inputs[0], Args, CmdArgs, + D.getLTOMode() == LTOK_Thin, D); + } if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle)) CmdArgs.push_back("--no-demangle"); Index: lib/Driver/ToolChains/FreeBSD.cpp === --- lib/Driver/ToolChains/FreeBSD.cpp +++ lib/Driver/ToolChains/FreeBSD.cpp @@ -231,8 +231,11 @@ Args.AddAllArgs(CmdArgs, options::OPT_Z_Flag); Args.AddAllArgs(CmdArgs, options::OPT_r); - if (D.isUsingLTO()) -AddGoldPlugin(ToolChain, Args, CmdArgs, D.getLTOMode() == LTOK_Thin, D); + if (D.isUsingLTO()) { +assert(!Inputs.empty() && "Must have at least one input."); +AddGoldPlugin(ToolChain, Output, Inputs[0], Args, CmdArgs, + D.getLTOMode() == LTOK_Thin, D); + } bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs); bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs); Index: lib/Driver/ToolChains/CommonArgs.h === --- lib/Driver/ToolChains/CommonArgs.h +++ lib/Driver/ToolChains/CommonArgs.h @@ -59,7 +59,8 @@ const JobAction &JA, const llvm::opt::ArgList &Args, const InputInfo &Output, const char *OutFile); -void AddGoldPlugin(const ToolChain &ToolChain, const llvm::opt::ArgList &Args, +void AddGoldPlugin(const ToolChain &ToolChain, const InputInfo &Output, + const InputInfo &Input, const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs, bool IsThinLTO, const Driver &D); @@ -103,6 +104,10 @@ void handleTargetFeaturesGroup(const llvm::opt::ArgList &Args, std::vector &Features, llvm::opt::OptSpecifier Group); +SmallString<128> getStatsFileName(const InputInfo &Output, + const InputInfo &Input, + const llvm::opt::ArgList &Args, + const Driver &D); } // end namespace tools } // end namespace driver Index: lib/Driver/ToolChains/CommonArgs.cpp === --- lib/Driver/ToolChains/CommonArgs.cpp +++ lib/Driver/ToolChains/CommonArgs.cpp @@ -8,14 +8,14 @@ //===--===// #include "CommonArgs.h" -#include "InputInfo.h" -#include "Hexagon.h" #include "Arch/AArch64.h" #include "Arch/ARM.h" #include "Arch/Mips.h" #include "Arch/PPC.h" #include "Arch/SystemZ.h" #include "Arch/X86.h" +#include "Hexagon.h" +#include "InputInfo.h" #include "clang/Basic/CharInfo.h" #include "clang/Basic/LangOptions.h" #include "clang/Basic/ObjCRuntime.h" @@ -42,6 +42,7 @@ #include "llvm/Option/Option.h" #include "llvm/Support/CodeGen.h" #include "llvm/Support
[PATCH] D44882: [clangd] Implementation of workspace/symbol request
hokein added inline comments. Herald added a subscriber: jkorous. Comment at: clangd/FindSymbols.cpp:117 +} +auto Path = URI::resolve(*Uri); +if (!Path) { The current URI scheme (`file`, `test`) works fine without `HintPath` because they don't use it, but for some custom URI schemes, they might rely on the `HintPath`(e.g. the path of current main file) to resolve the absolute path correctly. Maybe add a FIXME here? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D44882 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45489: [HIP] Add input type for HIP
yaxunl added a comment. In https://reviews.llvm.org/D45489#1070470, @tra wrote: > I'm getting confused about the order of the patches. > The patch stack phabricator displays in this patch is different compared to > the stack in https://reviews.llvm.org/D44984. Which one should I trust? Sorry I think I may misunderstand the parent/child relation between reviews. I thought a review depends on its parent reviews, i.e., parent reviews should be committed first. Is that correct? Thanks. https://reviews.llvm.org/D45489 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330229 - [AAch64] Add the __ARM_FEATURE_DOTPROD macro definition
Author: flyingforyou Date: Tue Apr 17 15:38:40 2018 New Revision: 330229 URL: http://llvm.org/viewvc/llvm-project?rev=330229&view=rev Log: [AAch64] Add the __ARM_FEATURE_DOTPROD macro definition This matches what GCC does. https://github.com/gcc-mirror/gcc/blob/master/gcc/config/aarch64/aarch64-c.c Differential Revision: https://reviews.llvm.org/D45544 Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp cfe/trunk/lib/Basic/Targets/AArch64.h cfe/trunk/test/Preprocessor/aarch64-target-features.c Modified: cfe/trunk/lib/Basic/Targets/AArch64.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.cpp?rev=330229&r1=330228&r2=330229&view=diff == --- cfe/trunk/lib/Basic/Targets/AArch64.cpp (original) +++ cfe/trunk/lib/Basic/Targets/AArch64.cpp Tue Apr 17 15:38:40 2018 @@ -193,6 +193,9 @@ void AArch64TargetInfo::getTargetDefines if (HasFullFP16) Builder.defineMacro("__ARM_FEATURE_FP16_SCALAR_ARITHMETIC", "1"); + if (HasDotProd) +Builder.defineMacro("__ARM_FEATURE_DOTPROD", "1"); + switch (ArchKind) { default: break; @@ -229,6 +232,7 @@ bool AArch64TargetInfo::handleTargetFeat Crypto = 0; Unaligned = 1; HasFullFP16 = 0; + HasDotProd = 0; ArchKind = llvm::AArch64::ArchKind::ARMV8A; for (const auto &Feature : Features) { @@ -248,6 +252,8 @@ bool AArch64TargetInfo::handleTargetFeat ArchKind = llvm::AArch64::ArchKind::ARMV8_2A; if (Feature == "+fullfp16") HasFullFP16 = 1; +if (Feature == "+dotprod") + HasDotProd = 1; } setDataLayout(); Modified: cfe/trunk/lib/Basic/Targets/AArch64.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AArch64.h?rev=330229&r1=330228&r2=330229&view=diff == --- cfe/trunk/lib/Basic/Targets/AArch64.h (original) +++ cfe/trunk/lib/Basic/Targets/AArch64.h Tue Apr 17 15:38:40 2018 @@ -33,6 +33,7 @@ class LLVM_LIBRARY_VISIBILITY AArch64Tar unsigned Crypto; unsigned Unaligned; unsigned HasFullFP16; + unsigned HasDotProd; llvm::AArch64::ArchKind ArchKind; static const Builtin::Info BuiltinInfo[]; Modified: cfe/trunk/test/Preprocessor/aarch64-target-features.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/aarch64-target-features.c?rev=330229&r1=330228&r2=330229&view=diff == --- cfe/trunk/test/Preprocessor/aarch64-target-features.c (original) +++ cfe/trunk/test/Preprocessor/aarch64-target-features.c Tue Apr 17 15:38:40 2018 @@ -38,6 +38,7 @@ // CHECK-NOT: __ARM_SIZEOF_MINIMAL_ENUM 1 // CHECK-NOT: __ARM_SIZEOF_WCHAR_T 2 // CHECK-NOT: __ARM_FEATURE_SVE +// CHECK-NOT: __ARM_FEATURE_DOTPROD // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-BIGENDIAN // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1 @@ -89,6 +90,9 @@ // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+sve -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-SVE %s // CHECK-SVE: __ARM_FEATURE_SVE 1 +// RUN: %clang -target aarch64-none-linux-gnu -march=armv8.2a+dotprod -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-DOTPROD %s +// CHECK-DOTPROD: __ARM_FEATURE_DOTPROD 1 + // RUN: %clang -target aarch64-none-linux-gnueabi -march=armv8.2a+fp16 -x c -E -dM %s -o - | FileCheck -match-full-lines --check-prefix=CHECK-FULLFP16-VECTOR-SCALAR %s // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_SCALAR_ARITHMETIC 1 // CHECK-FULLFP16-VECTOR-SCALAR: #define __ARM_FEATURE_FP16_VECTOR_ARITHMETIC 1 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330220 - [XRay] Add clang builtin for xray typed events.
Author: kpw Date: Tue Apr 17 14:32:43 2018 New Revision: 330220 URL: http://llvm.org/viewvc/llvm-project?rev=330220&view=rev Log: [XRay] Add clang builtin for xray typed events. Summary: A clang builtin for xray typed events. Differs from __xray_customevent(...) by the presence of a type tag that is vended by compiler-rt in typical usage. This allows xray handlers to expand logged events with their type description and plugins to process traced events based on type. This change depends on D45633 for the intrinsic definition. Reviewers: dberris, pelikan, rnk, eizan Subscribers: cfe-commits, llvm-commits Differential Revision: https://reviews.llvm.org/D45716 Added: cfe/trunk/test/CodeGen/xray-always-emit-typedevent.cpp cfe/trunk/test/CodeGen/xray-typedevent.cpp Modified: cfe/trunk/include/clang/Basic/Builtins.def cfe/trunk/include/clang/Basic/LangOptions.def cfe/trunk/include/clang/Basic/XRayInstr.h cfe/trunk/include/clang/Driver/Options.td cfe/trunk/include/clang/Driver/XRayArgs.h cfe/trunk/include/clang/Frontend/CodeGenOptions.def cfe/trunk/lib/Basic/XRayInstr.cpp cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.cpp cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/Driver/XRayArgs.cpp cfe/trunk/lib/Frontend/CompilerInvocation.cpp cfe/trunk/test/CodeGen/xray-instrumentation-bundles.cpp Modified: cfe/trunk/include/clang/Basic/Builtins.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=330220&r1=330219&r2=330220&view=diff == --- cfe/trunk/include/clang/Basic/Builtins.def (original) +++ cfe/trunk/include/clang/Basic/Builtins.def Tue Apr 17 14:32:43 2018 @@ -1455,6 +1455,7 @@ LANGBUILTIN(omp_is_initial_device, "i", // Builtins for XRay BUILTIN(__xray_customevent, "vcC*z", "") +BUILTIN(__xray_typedevent, "vzcC*z", "") // Win64-compatible va_list functions BUILTIN(__builtin_ms_va_start, "vc*&.", "nt") Modified: cfe/trunk/include/clang/Basic/LangOptions.def URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=330220&r1=330219&r2=330220&view=diff == --- cfe/trunk/include/clang/Basic/LangOptions.def (original) +++ cfe/trunk/include/clang/Basic/LangOptions.def Tue Apr 17 14:32:43 2018 @@ -281,6 +281,9 @@ LANGOPT(XRayInstrument, 1, 0, "controls LANGOPT(XRayAlwaysEmitCustomEvents, 1, 0, "controls whether to always emit intrinsic calls to " "__xray_customevent(...) builtin.") +LANGOPT(XRayAlwaysEmitTypedEvents, 1, 0, +"controls whether to always emit intrinsic calls to " +"__xray_typedevent(...) builtin.") BENIGN_LANGOPT(AllowEditorPlaceholders, 1, 0, "allow editor placeholders in source") @@ -298,4 +301,3 @@ ENUM_LANGOPT(ClangABICompat, ClangABI, 4 #undef VALUE_LANGOPT #undef COMPATIBLE_VALUE_LANGOPT #undef BENIGN_VALUE_LANGOPT - Modified: cfe/trunk/include/clang/Basic/XRayInstr.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/XRayInstr.h?rev=330220&r1=330219&r2=330220&view=diff == --- cfe/trunk/include/clang/Basic/XRayInstr.h (original) +++ cfe/trunk/include/clang/Basic/XRayInstr.h Tue Apr 17 14:32:43 2018 @@ -31,13 +31,15 @@ namespace XRayInstrKind { enum XRayInstrOrdinal : XRayInstrMask { XRIO_Function, XRIO_Custom, + XRIO_Typed, XRIO_Count }; constexpr XRayInstrMask None = 0; constexpr XRayInstrMask Function = 1U << XRIO_Function; constexpr XRayInstrMask Custom = 1U << XRIO_Custom; -constexpr XRayInstrMask All = Function | Custom; +constexpr XRayInstrMask Typed = 1U << XRIO_Typed; +constexpr XRayInstrMask All = Function | Custom | Typed; } // namespace XRayInstrKind Modified: cfe/trunk/include/clang/Driver/Options.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330220&r1=330219&r2=330220&view=diff == --- cfe/trunk/include/clang/Driver/Options.td (original) +++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 17 14:32:43 2018 @@ -1119,6 +1119,12 @@ def fxray_always_emit_customevents : Fla def fnoxray_always_emit_customevents : Flag<["-"], "fno-xray-always-emit-customevents">, Group, Flags<[CC1Option]>; +def fxray_always_emit_typedevents : Flag<["-"], "fxray-always-emit-typedevents">, Group, + Flags<[CC1Option]>, + HelpText<"Determine whether to always emit __xray_typedevent(...) calls even if the function it appears in is not always instrumented.">; +def fnoxray_always_emit_typedevents : Flag<["-"], "fno-xray-always-emit-typedevents">, Group, + Flags<[CC1Option]>; + def fxray_link_deps : Flag<["-"], "fxray-link-deps">, Group, Flags<[CC1Option]>, HelpText<"Tells clang
[PATCH] D45668: [NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only
SjoerdMeijer added a comment. Thanks James! Repository: rL LLVM https://reviews.llvm.org/D45668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45112: [MS] Emit vftable thunks for functions with incomplete prototypes
sberg added a comment. see https://bugs.llvm.org/show_bug.cgi?id=37161 "clang-cl triggers ASTContext::getASTRecordLayout Assertion `D && 'Cannot get layout of forward declarations!''" for what appears to be fallout from this change Repository: rL LLVM https://reviews.llvm.org/D45112 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45668: [NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only
jgreenhalgh added a comment. In https://reviews.llvm.org/D45668#1070878, @SjoerdMeijer wrote: > Thanks, and I am going to try to get some clarity on this doc issue. But > looks like it should be "ARMv7, ARMv8", as it used to be. Make sense to > comment on this in the commit message, if that's what you mean. These should be available whenever the float16x4_t and float16x8_t types are available. So v7/A32/A64. I have pushed this change to the docs locally; but I don't know when this will make it to public documentation, so you will just have to take my word for it when I say this is a documentation bug and it will be fixed in a future release. Repository: rL LLVM https://reviews.llvm.org/D45668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45569: [Sema] Disable built-in increment operator for bool in overload resolution in C++17
This revision was automatically updated to reflect the committed changes. Closed by commit rC330254: [Sema] Disable built-in increment operator for bool in overload resolution in… (authored by jkorous, committed by ). Changed prior to commit: https://reviews.llvm.org/D45569?vs=142167&id=142929#toc Repository: rC Clang https://reviews.llvm.org/D45569 Files: lib/Sema/SemaOverload.cpp test/SemaCXX/overloaded-builtin-operators-cxx17.cpp Index: test/SemaCXX/overloaded-builtin-operators-cxx17.cpp === --- test/SemaCXX/overloaded-builtin-operators-cxx17.cpp +++ test/SemaCXX/overloaded-builtin-operators-cxx17.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu -std=c++17 %s + +struct BoolRef { + operator bool&(); +}; + +void foo(BoolRef br) { + // C++ [over.built]p3: Increment for bool was removed in C++17. + bool b = br++; // expected-error{{cannot increment value of type 'BoolRef'}} +} \ No newline at end of file Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -7782,11 +7782,13 @@ InitArithmeticTypes(); } + // Increment is deprecated for bool since C++17. + // // C++ [over.built]p3: // - // For every pair (T, VQ), where T is an arithmetic type, and VQ - // is either volatile or empty, there exist candidate operator - // functions of the form + // For every pair (T, VQ), where T is an arithmetic type other + // than bool, and VQ is either volatile or empty, there exist + // candidate operator functions of the form // // VQ T& operator++(VQ T&); // T operator++(VQ T&, int); @@ -7805,8 +7807,12 @@ for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) { const auto TypeOfT = ArithmeticTypes[Arith]; - if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy) -continue; + if (TypeOfT == S.Context.BoolTy) { +if (Op == OO_MinusMinus) + continue; +if (Op == OO_PlusPlus && S.getLangOpts().CPlusPlus17) + continue; + } addPlusPlusMinusMinusStyleOverloads( TypeOfT, VisibleTypeConversionsQuals.hasVolatile(), Index: test/SemaCXX/overloaded-builtin-operators-cxx17.cpp === --- test/SemaCXX/overloaded-builtin-operators-cxx17.cpp +++ test/SemaCXX/overloaded-builtin-operators-cxx17.cpp @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu -std=c++17 %s + +struct BoolRef { + operator bool&(); +}; + +void foo(BoolRef br) { + // C++ [over.built]p3: Increment for bool was removed in C++17. + bool b = br++; // expected-error{{cannot increment value of type 'BoolRef'}} +} \ No newline at end of file Index: lib/Sema/SemaOverload.cpp === --- lib/Sema/SemaOverload.cpp +++ lib/Sema/SemaOverload.cpp @@ -7782,11 +7782,13 @@ InitArithmeticTypes(); } + // Increment is deprecated for bool since C++17. + // // C++ [over.built]p3: // - // For every pair (T, VQ), where T is an arithmetic type, and VQ - // is either volatile or empty, there exist candidate operator - // functions of the form + // For every pair (T, VQ), where T is an arithmetic type other + // than bool, and VQ is either volatile or empty, there exist + // candidate operator functions of the form // // VQ T& operator++(VQ T&); // T operator++(VQ T&, int); @@ -7805,8 +7807,12 @@ for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) { const auto TypeOfT = ArithmeticTypes[Arith]; - if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy) -continue; + if (TypeOfT == S.Context.BoolTy) { +if (Op == OO_MinusMinus) + continue; +if (Op == OO_PlusPlus && S.getLangOpts().CPlusPlus17) + continue; + } addPlusPlusMinusMinusStyleOverloads( TypeOfT, VisibleTypeConversionsQuals.hasVolatile(), ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r330254 - [Sema] Disable built-in increment operator for bool in overload resolution in C++17
Author: jkorous Date: Wed Apr 18 06:38:39 2018 New Revision: 330254 URL: http://llvm.org/viewvc/llvm-project?rev=330254&view=rev Log: [Sema] Disable built-in increment operator for bool in overload resolution in C++17 Following: https://llvm.org/svn/llvm-project/cfe/trunk@329804 For C++17 the wording of [over.built] p4 excluded bool: For every pair (T , vq), where T is an arithmetic type other than bool, there exist candidate operator functions of the form vq T & operator++(vq T &); T operator++(vq T &, int); Differential Revision: https://reviews.llvm.org/D45569 Added: cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp Modified: cfe/trunk/lib/Sema/SemaOverload.cpp Modified: cfe/trunk/lib/Sema/SemaOverload.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=330254&r1=330253&r2=330254&view=diff == --- cfe/trunk/lib/Sema/SemaOverload.cpp (original) +++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 18 06:38:39 2018 @@ -7782,11 +7782,13 @@ public: InitArithmeticTypes(); } + // Increment is deprecated for bool since C++17. + // // C++ [over.built]p3: // - // For every pair (T, VQ), where T is an arithmetic type, and VQ - // is either volatile or empty, there exist candidate operator - // functions of the form + // For every pair (T, VQ), where T is an arithmetic type other + // than bool, and VQ is either volatile or empty, there exist + // candidate operator functions of the form // // VQ T& operator++(VQ T&); // T operator++(VQ T&, int); @@ -7805,8 +7807,12 @@ public: for (unsigned Arith = 0; Arith < NumArithmeticTypes; ++Arith) { const auto TypeOfT = ArithmeticTypes[Arith]; - if (Op == OO_MinusMinus && TypeOfT == S.Context.BoolTy) -continue; + if (TypeOfT == S.Context.BoolTy) { +if (Op == OO_MinusMinus) + continue; +if (Op == OO_PlusPlus && S.getLangOpts().CPlusPlus17) + continue; + } addPlusPlusMinusMinusStyleOverloads( TypeOfT, VisibleTypeConversionsQuals.hasVolatile(), Added: cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp?rev=330254&view=auto == --- cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp (added) +++ cfe/trunk/test/SemaCXX/overloaded-builtin-operators-cxx17.cpp Wed Apr 18 06:38:39 2018 @@ -0,0 +1,10 @@ +// RUN: %clang_cc1 -fsyntax-only -fshow-overloads=best -verify -triple x86_64-linux-gnu -std=c++17 %s + +struct BoolRef { + operator bool&(); +}; + +void foo(BoolRef br) { + // C++ [over.built]p3: Increment for bool was removed in C++17. + bool b = br++; // expected-error{{cannot increment value of type 'BoolRef'}} +} \ No newline at end of file ___ 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 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
[PATCH] D45454: Make __gcov_flush visible outside a shared library
belleyb added a comment. @chh I had a chance to try out your proposed changes. It's not causing us any trouble. In fact, __gcov_flush() is not even used at all (at least in LLVM 5.0.1).. I can recompile llvm, compiler_rt and clang and re-run all the tests with __gcov_flush commented out! No problem. I would suggest adding a bit more documentation to __gcov_flush(), thus describing what those "special cases" are... https://reviews.llvm.org/D45454 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45668: [NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only
SjoerdMeijer added a comment. Thanks, and I am going to try to get some clarity on this doc issue. But looks like it should be "ARMv7, ARMv8", as it used to be. Make sense to comment on this in the commit message, if that's what you mean. Repository: rL LLVM https://reviews.llvm.org/D45668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name
SimeonEhrig marked 2 inline comments as done. SimeonEhrig added inline comments. Comment at: lib/CodeGen/CGCUDANV.cpp:358 + if (ModuleName.empty()) +ModuleName = ""; + rjmccall wrote: > This doesn't actually seem more useful than the empty string. We improved the implementation. If there is no module name, it will not append any suffix and the symbol is just '__cuda_module_ctor'. https://reviews.llvm.org/D44435 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D44435: CUDA ctor/dtor Module-Unique Symbol Name
SimeonEhrig updated this revision to Diff 142921. SimeonEhrig added a comment. Thank you everyone for your review comments! We addressed the inline comments and improved the description of the change set for clarity and context. Tests are updated as well. This now implements the same fix as previously received in https://reviews.llvm.org/D34059 but just for CUDA. https://reviews.llvm.org/D44435 Files: lib/CodeGen/CGCUDANV.cpp unittests/CodeGen/IncrementalProcessingTest.cpp Index: unittests/CodeGen/IncrementalProcessingTest.cpp === --- unittests/CodeGen/IncrementalProcessingTest.cpp +++ unittests/CodeGen/IncrementalProcessingTest.cpp @@ -21,9 +21,11 @@ #include "llvm/IR/Module.h" #include "llvm/Support/Host.h" #include "llvm/Support/MemoryBuffer.h" +#include "llvm/Target/TargetOptions.h" #include "gtest/gtest.h" #include +#include using namespace llvm; using namespace clang; @@ -171,4 +173,122 @@ } + +// In CUDA incremental processing, a CUDA ctor or dtor will be generated for +// every statement if a fatbinary file exists. +const char CUDATestProgram1[] = +"void cudaFunc1(){}\n"; + +const char CUDATestProgram2[] = +"void cudaFunc2(){}\n"; + +const Function* getCUDActor(llvm::Module& M) { + for (const auto& Func: M) +if (Func.hasName() && Func.getName().startswith("__cuda_module_ctor_")) + return &Func; + + return nullptr; +} + +const Function* getCUDAdtor(llvm::Module& M) { + for (const auto& Func: M) +if (Func.hasName() && Func.getName().startswith("__cuda_module_dtor_")) + return &Func; + + return nullptr; +} + +TEST(IncrementalProcessing, EmitCUDAGlobalInitFunc) { +LLVMContext Context; +CompilerInstance compiler; + +compiler.createDiagnostics(); +compiler.getLangOpts().CPlusPlus = 1; +compiler.getLangOpts().CPlusPlus11 = 1; +compiler.getLangOpts().CUDA = 1; + +compiler.getTargetOpts().Triple = llvm::Triple::normalize( +llvm::sys::getProcessTriple()); +compiler.setTarget(clang::TargetInfo::CreateTargetInfo( + compiler.getDiagnostics(), + std::make_shared( +compiler.getTargetOpts(; + +// To enable the generating of cuda host code, it's needs to set up the +// auxTriple. +llvm::Triple hostTriple(llvm::sys::getProcessTriple()); +compiler.getFrontendOpts().AuxTriple = +hostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda"; +auto targetOptions = std::make_shared(); +targetOptions->Triple = compiler.getFrontendOpts().AuxTriple; +targetOptions->HostTriple = compiler.getTarget().getTriple().str(); +compiler.setAuxTarget(clang::TargetInfo::CreateTargetInfo( +compiler.getDiagnostics(), targetOptions)); + +// A fatbinary file is necessary, that the code generator generates the ctor +// and dtor. +auto tmpFatbinFileOrError = llvm::sys::fs::TempFile::create("dummy.fatbin"); +ASSERT_TRUE((bool)tmpFatbinFileOrError); +auto tmpFatbinFile = std::move(*tmpFatbinFileOrError); +compiler.getCodeGenOpts().CudaGpuBinaryFileName = tmpFatbinFile.TmpName; + +compiler.createFileManager(); +compiler.createSourceManager(compiler.getFileManager()); +compiler.createPreprocessor(clang::TU_Prefix); +compiler.getPreprocessor().enableIncrementalProcessing(); + +compiler.createASTContext(); + +CodeGenerator* CG = +CreateLLVMCodeGen( +compiler.getDiagnostics(), +"main-module", +compiler.getHeaderSearchOpts(), +compiler.getPreprocessorOpts(), +compiler.getCodeGenOpts(), +Context); + +compiler.setASTConsumer(std::unique_ptr(CG)); +compiler.createSema(clang::TU_Prefix, nullptr); +Sema& S = compiler.getSema(); + +std::unique_ptr ParseOP(new Parser(S.getPreprocessor(), S, + /*SkipFunctionBodies*/ false)); +Parser &P = *ParseOP.get(); + +std::array, 3> M; +M[0] = IncrementalParseAST(compiler, P, *CG, nullptr); +ASSERT_TRUE(M[0]); + +M[1] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram1); +ASSERT_TRUE(M[1]); +ASSERT_TRUE(M[1]->getFunction("_Z9cudaFunc1v")); + +M[2] = IncrementalParseAST(compiler, P, *CG, CUDATestProgram2); +ASSERT_TRUE(M[2]); +ASSERT_TRUE(M[2]->getFunction("_Z9cudaFunc2v")); +// First code should not end up in second module: +ASSERT_FALSE(M[2]->getFunction("_Z9cudaFunc1v")); + +// Make sure, that cuda ctor's and dtor's exist: +const Function* CUDActor1 = getCUDActor(*M[1]); +ASSERT_TRUE(CUDActor1); + +const Function* CUDActor2 = getCUDActor(*M[2]); +ASSERT_TRUE(CUDActor2); + +const Function* CUDAdtor1 = getCUDAdtor(*M[1]); +ASSERT_TRUE(CUDAdtor1); + +const Function* CUDAdtor2 = getCUDAdtor(*M[2]); +ASSERT_TRUE(CUDAdtor2); + +// Compare the names of both ctor's and dtor's to check, that they are +//
[PATCH] D45722: [X86] Lowering SAD (sum of absolute differences) intrinsics to native IR (clang side)
mike.dvoretsky updated this revision to Diff 142914. mike.dvoretsky added a comment. Updated per comments. https://reviews.llvm.org/D45722 Files: clang/lib/CodeGen/CGBuiltin.cpp clang/test/CodeGen/avx2-builtins.c clang/test/CodeGen/avx512bw-builtins.c clang/test/CodeGen/sse2-builtins.c Index: clang/test/CodeGen/sse2-builtins.c === --- clang/test/CodeGen/sse2-builtins.c +++ clang/test/CodeGen/sse2-builtins.c @@ -893,7 +893,33 @@ __m128i test_mm_sad_epu8(__m128i A, __m128i B) { // CHECK-LABEL: test_mm_sad_epu8 - // CHECK: call <2 x i64> @llvm.x86.sse2.psad.bw(<16 x i8> %{{.*}}, <16 x i8> %{{.*}}) + // CHECK: %{{.*}} = icmp ugt <16 x i8> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = sub <16 x i8> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = sub <16 x i8> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = select <16 x i1> %{{.*}}, <16 x i8> %{{.*}}, <16 x i8> %{{.*}} + // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> undef, <2 x i32> + // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64> + // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> undef, <2 x i32> + // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64> + // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> undef, <2 x i32> + // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64> + // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> undef, <2 x i32> + // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64> + // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> undef, <2 x i32> + // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64> + // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> undef, <2 x i32> + // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64> + // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> undef, <2 x i32> + // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64> + // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <16 x i8> %{{.*}}, <16 x i8> undef, <2 x i32> + // CHECK: %{{.*}} = zext <2 x i8> %{{.*}} to <2 x i64> + // CHECK: %{{.*}} = add <2 x i64> %{{.*}}, %{{.*}} return _mm_sad_epu8(A, B); } Index: clang/test/CodeGen/avx512bw-builtins.c === --- clang/test/CodeGen/avx512bw-builtins.c +++ clang/test/CodeGen/avx512bw-builtins.c @@ -1945,7 +1945,33 @@ __m512i test_mm512_sad_epu8(__m512i __A, __m512i __B) { // CHECK-LABEL: @test_mm512_sad_epu8 - // CHECK: @llvm.x86.avx512.psad.bw.512 + // CHECK: %{{.*}} = icmp ugt <64 x i8> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = sub <64 x i8> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = sub <64 x i8> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = select <64 x i1> %{{.*}}, <64 x i8> %{{.*}}, <64 x i8> %{{.*}} + // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> undef, <8 x i32> + // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64> + // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> undef, <8 x i32> + // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64> + // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> undef, <8 x i32> + // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64> + // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> undef, <8 x i32> + // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64> + // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> undef, <8 x i32> + // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64> + // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> undef, <8 x i32> + // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64> + // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> undef, <8 x i32> + // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64> + // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}} + // CHECK: %{{.*}} = shufflevector <64 x i8> %{{.*}}, <64 x i8> undef, <8 x i32> + // CHECK: %{{.*}} = zext <8 x i8> %{{.*}} to <8 x i64> + // CHECK: %{{.*}} = add <8 x i64> %{{.*}}, %{{.*}} return _mm512_sad_epu8(__A, __B); } Index: clang/test/CodeGen/avx2-builtins.c === --- clang/test/CodeGen/avx2-builtins.c +++ clang/test/CodeGen/avx2-builtins.c @@ -943,7 +943,33 @@ __m256i test_mm256_sad_epu8(__m256i x, __m256i y) { // CHECK-LABEL: test_mm256_sad_epu8 - // CHECK: call <4 x i64> @llvm.
[PATCH] D45685: [Sema] Add -wtest global flag that silences -Wself-assign for overloaded operators.
rjmccall added a comment. Let me try to summarize where I think we are. 1. I think it’s now generally agreed that this is a useful warning — certainly for field assignments, but we also have (at least?) one example with a local variable. 2. It’s also generally agreed that this warning has a problem with unit tests and that we should provide a compiler option to suppress. 3. There isn’t really a middle-point between case-by-case suppression (by rewriting the RHS to avoid the warning) and file-by-file (compiler option) suppression. We don’t know how to distinguish the unit-test false positives from the local-variable true positive. 4. Whatever the file-by-file suppression is, it would be best for build systems to target it narrowly at their unit-test code; but we also have to acknowledge that that’s not always straightforward, and so the suppression should be narrowly-targeted on the compiler side as well, just in case the suppression does have to be more global. 5. Roman and I are suggesting that the file-by-file suppression should not be specific to this warning but instead should be a more generic way of disabling warnings that are known to be problematic in unit tests. We could then recommend that option to project owners as a single mitigation rather than forcing them to maintain a growing list of test-directed warning suppressions. 6. Using a more general mechanism seems advisable because we are already considering extending some other warnings to cover user-defined operators, and all such warnings have the potential of running afoul of unit tests. (This is something that will require careful thought because user-defined operators need not have their conventional meaning. However, any semantics-based suppression will almost certainly have different characteristics from a test-directed suppression. For example, test-directed suppression for self-assign need not suppress warnings about fields, whereas a semantics-based suppression should.) John. Repository: rC Clang https://reviews.llvm.org/D45685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D45685: [Sema] Add -wtest global flag that silences -Wself-assign for overloaded operators.
Let me try to summarize where I think we are. 1. I think it’s now generally agreed that this is a useful warning — certainly for field assignments, but we also have (at least?) one example with a local variable. 2. It’s also generally agreed that this warning has a problem with unit tests and that we should provide a compiler option to suppress. 3. There isn’t really a middle-point between case-by-case suppression (by rewriting the RHS to avoid the warning) and file-by-file (compiler option) suppression. We don’t know how to distinguish the unit-test false positives from the local-variable true positive. 4. Whatever the file-by-file suppression is, it would be best for build systems to target it narrowly at their unit-test code; but we also have to acknowledge that that’s not always straightforward, and so the suppression should be narrowly-targeted on the compiler side as well, just in case the suppression does have to be more global. 5. Roman and I are suggesting that the file-by-file suppression should not be specific to this warning but instead should be a more generic way of disabling warnings that are known to be problematic in unit tests. We could then recommend that option to project owners as a single mitigation rather than forcing them to maintain a growing list of test-directed warning suppressions. 6. Using a more general mechanism seems advisable because we are already considering extending some other warnings to cover user-defined operators, and all such warnings have the potential of running afoul of unit tests. (This is something that will require careful thought because user-defined operators need not have their conventional meaning. However, any semantics-based suppression will almost certainly have different characteristics from a test-directed suppression. For example, test-directed suppression for self-assign need not suppress warnings about fields, whereas a semantics-based suppression should.) John. On Wed, Apr 18, 2018 at 13:54 John McCall via Phabricator < revi...@reviews.llvm.org> wrote: > rjmccall added a comment. > > I'm sorry, that warning *is* in self-assign, although I'm not sure it > should be. > > > Repository: > rC Clang > > https://reviews.llvm.org/D45685 > > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45766: [Sema] Add -Wno-self-assign-overloaded
lebedev.ri created this revision. lebedev.ri added reviewers: dblaikie, aaron.ballman, thakis, rjmccall, rsmith. It seems there isn't much enthusiasm for `-wtest` https://reviews.llvm.org/D45685. This is more conservative version, which i had in the very first revision of https://reviews.llvm.org/D44883, but that 'erroneously' got removed because of the review. **Based on some [irc] discussions, it must really be documented that we want all the new diagnostics to have their own flags, to ease rollouts, transitions, etc.** Please do note that i'm only adding `-Wno-self-assign-overloaded`, but not `-Wno-self-assign-field-overloaded`, because i'm honestly not aware of any false-positives from the `-field` variant, but i can just as easily add it if wanted. https://reviews.llvm.org/D44883#1068561 Repository: rC Clang https://reviews.llvm.org/D45766 Files: docs/ReleaseNotes.rst include/clang/Basic/DiagnosticGroups.td include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaExpr.cpp test/SemaCXX/warn-self-assign-overloaded.cpp Index: test/SemaCXX/warn-self-assign-overloaded.cpp === --- test/SemaCXX/warn-self-assign-overloaded.cpp +++ test/SemaCXX/warn-self-assign-overloaded.cpp @@ -4,6 +4,12 @@ // RUN: %clang_cc1 -fsyntax-only -Wself-assign -DV2 -verify %s // RUN: %clang_cc1 -fsyntax-only -Wself-assign -DV3 -verify %s // RUN: %clang_cc1 -fsyntax-only -Wself-assign -DV4 -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-self-assign -Wself-assign-overloaded -DDUMMY -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-self-assign -Wself-assign-overloaded -DV0 -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-self-assign -Wself-assign-overloaded -DV1 -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-self-assign -Wself-assign-overloaded -DV2 -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-self-assign -Wself-assign-overloaded -DV3 -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wno-self-assign -Wself-assign-overloaded -DV4 -verify %s #ifdef DUMMY struct S {}; Index: lib/Sema/SemaExpr.cpp === --- lib/Sema/SemaExpr.cpp +++ lib/Sema/SemaExpr.cpp @@ -11497,7 +11497,7 @@ /// DiagnoseSelfAssignment - Emits a warning if a value is assigned to itself. /// This warning suppressed in the event of macro expansions. static void DiagnoseSelfAssignment(Sema &S, Expr *LHSExpr, Expr *RHSExpr, - SourceLocation OpLoc) { + SourceLocation OpLoc, bool IsBuiltin) { if (S.inTemplateInstantiation()) return; if (S.isUnevaluatedContext()) @@ -11524,9 +11524,10 @@ if (RefTy->getPointeeType().isVolatileQualified()) return; - S.Diag(OpLoc, diag::warn_self_assignment) - << LHSDeclRef->getType() - << LHSExpr->getSourceRange() << RHSExpr->getSourceRange(); + S.Diag(OpLoc, IsBuiltin ? diag::warn_self_assignment_builtin + : diag::warn_self_assignment_overloaded) + << LHSDeclRef->getType() << LHSExpr->getSourceRange() + << RHSExpr->getSourceRange(); } /// Check if a bitwise-& is performed on an Objective-C pointer. This @@ -11719,7 +11720,7 @@ OK = LHS.get()->getObjectKind(); } if (!ResultTy.isNull()) { - DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc); + DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc, true); DiagnoseSelfMove(LHS.get(), RHS.get(), OpLoc); } RecordModifiableNonNullParam(*this, LHS.get()); @@ -11817,7 +11818,7 @@ break; case BO_AndAssign: case BO_OrAssign: // fallthrough -DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc); +DiagnoseSelfAssignment(*this, LHS.get(), RHS.get(), OpLoc, true); LLVM_FALLTHROUGH; case BO_XorAssign: CompResultTy = CheckBitwiseOperands(LHS, RHS, OpLoc, Opc); @@ -12124,7 +12125,7 @@ case BO_AndAssign: case BO_OrAssign: case BO_XorAssign: -DiagnoseSelfAssignment(S, LHS, RHS, OpLoc); +DiagnoseSelfAssignment(S, LHS, RHS, OpLoc, false); CheckIdentityFieldAssignment(LHS, RHS, OpLoc, S); break; default: Index: include/clang/Basic/DiagnosticSemaKinds.td === --- include/clang/Basic/DiagnosticSemaKinds.td +++ include/clang/Basic/DiagnosticSemaKinds.td @@ -5612,9 +5612,12 @@ "operator '%0' has lower precedence than '%1'; " "'%1' will be evaluated first">, InGroup; -def warn_self_assignment : Warning< +def warn_self_assignment_builtin : Warning< "explicitly assigning value of variable of type %0 to itself">, InGroup, DefaultIgnore; +def warn_self_assignment_overloaded : Warning< + "explicitly assigning value of variable of type %0 to itself">, + InGroup, DefaultIgnore; def warn_self_move : Warning< "explicitly moving variable of type %0 to itself">, InGroup, DefaultIgnore; Index: include/clang/Basic/DiagnosticG
[PATCH] D45764: [clangd][tests] Fix delimiter handling
jkorous added a reviewer: sammccall. jkorous added a comment. Hi Sam, could you please take a look at this minor fix? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45764 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45763: [clangd][tests] Fix handling of EOF in delimited input
jkorous added a reviewer: sammccall. jkorous added a comment. Hi Sam, could you please take a look at this minor fix? Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45763 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45764: [clangd][tests] Fix delimiter handling
jkorous created this revision. jkorous added a project: clang-tools-extra. Herald added subscribers: cfe-commits, MaskRay, ioeric, jkorous-apple, ilya-biryukov. Empty line shouldn't be considered a delimiter. Following https://reviews.llvm.org/D45763 Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45764 Files: JSONRPCDispatcher.cpp clangd/spaces-in-delimited-input.test Index: clangd/spaces-in-delimited-input.test === --- /dev/null +++ clangd/spaces-in-delimited-input.test @@ -0,0 +1,13 @@ +# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck %s +# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} + +--- + +{"jsonrpc":"2.0","id":3,"method":"shutdown"} + +--- + +{"jsonrpc":"2.0","id":3,"method":"exit"} +# CHECK-NOT: JSON parse error Index: JSONRPCDispatcher.cpp === --- JSONRPCDispatcher.cpp +++ JSONRPCDispatcher.cpp @@ -278,7 +278,7 @@ continue; // found a delimiter -if (LineRef.find_first_not_of('-') == llvm::StringRef::npos) +if (LineRef.rtrim() == "---") break; JSON += Line; Index: clangd/spaces-in-delimited-input.test === --- /dev/null +++ clangd/spaces-in-delimited-input.test @@ -0,0 +1,13 @@ +# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck %s +# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} + +--- + +{"jsonrpc":"2.0","id":3,"method":"shutdown"} + +--- + +{"jsonrpc":"2.0","id":3,"method":"exit"} +# CHECK-NOT: JSON parse error Index: JSONRPCDispatcher.cpp === --- JSONRPCDispatcher.cpp +++ JSONRPCDispatcher.cpp @@ -278,7 +278,7 @@ continue; // found a delimiter -if (LineRef.find_first_not_of('-') == llvm::StringRef::npos) +if (LineRef.rtrim() == "---") break; JSON += Line; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45763: [clangd][tests] Fix handling of EOF in delimited input
jkorous created this revision. jkorous added a project: clang-tools-extra. Herald added subscribers: cfe-commits, MaskRay, ioeric, jkorous-apple, ilya-biryukov. Request in delimited input ended by EOF shouldn't be an error state. Comments should be allowed at the end of test files. Input mirroring should work for the last request in delimited test file. Repository: rCTE Clang Tools Extra https://reviews.llvm.org/D45763 Files: JSONRPCDispatcher.cpp clangd/delimited-input-comment-at-the-end.test Index: clangd/delimited-input-comment-at-the-end.test === --- /dev/null +++ clangd/delimited-input-comment-at-the-end.test @@ -0,0 +1,7 @@ +# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck %s +# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","id":3,"method":"exit"} +# CHECK-NOT: Input message terminated by EOF Index: JSONRPCDispatcher.cpp === --- JSONRPCDispatcher.cpp +++ JSONRPCDispatcher.cpp @@ -277,21 +277,19 @@ if (LineRef.startswith("#")) // comment continue; -bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos; -if (!IsDelim) // Line is part of a JSON message. - JSON += Line; -if (IsDelim) { - Out.mirrorInput( - llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON)); - return std::move(JSON); -} +// found a delimiter +if (LineRef.find_first_not_of('-') == llvm::StringRef::npos) + break; + +JSON += Line; } if (In.bad()) { log("Input error while reading message!"); return llvm::None; } else { -log("Input message terminated by EOF"); +Out.mirrorInput( +llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON)); return std::move(JSON); } } Index: clangd/delimited-input-comment-at-the-end.test === --- /dev/null +++ clangd/delimited-input-comment-at-the-end.test @@ -0,0 +1,7 @@ +# RUN: clangd -input-style=delimited -run-synchronously < %s 2>&1 | FileCheck %s +# RUN: clangd -lit-test -run-synchronously < %s 2>&1 | FileCheck %s +# +{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}} +--- +{"jsonrpc":"2.0","id":3,"method":"exit"} +# CHECK-NOT: Input message terminated by EOF Index: JSONRPCDispatcher.cpp === --- JSONRPCDispatcher.cpp +++ JSONRPCDispatcher.cpp @@ -277,21 +277,19 @@ if (LineRef.startswith("#")) // comment continue; -bool IsDelim = LineRef.find_first_not_of('-') == llvm::StringRef::npos; -if (!IsDelim) // Line is part of a JSON message. - JSON += Line; -if (IsDelim) { - Out.mirrorInput( - llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON)); - return std::move(JSON); -} +// found a delimiter +if (LineRef.find_first_not_of('-') == llvm::StringRef::npos) + break; + +JSON += Line; } if (In.bad()) { log("Input error while reading message!"); return llvm::None; } else { -log("Input message terminated by EOF"); +Out.mirrorInput( +llvm::formatv("Content-Length: {0}\r\n\r\n{1}", JSON.size(), JSON)); return std::move(JSON); } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45254: [X86][WAITPKG] WaitPKG intrinsics
GBuella updated this revision to Diff 142913. https://reviews.llvm.org/D45254 Files: include/clang/Basic/BuiltinsX86.def include/clang/Driver/Options.td lib/Basic/Targets/X86.cpp lib/Basic/Targets/X86.h lib/Headers/CMakeLists.txt lib/Headers/cpuid.h lib/Headers/waitpkgintrin.h lib/Headers/x86intrin.h test/CodeGen/waitpkg.c test/Driver/x86-target-features.c test/Preprocessor/predefined-arch-macros.c Index: test/Preprocessor/predefined-arch-macros.c === --- test/Preprocessor/predefined-arch-macros.c +++ test/Preprocessor/predefined-arch-macros.c @@ -1482,6 +1482,7 @@ // CHECK_TRM_M32: #define __SSE_MATH__ 1 // CHECK_TRM_M32: #define __SSE__ 1 // CHECK_TRM_M32: #define __SSSE3__ 1 +// CHECK_TRM_M32: #define __WAITPKG__ 1 // CHECK_TRM_M32: #define __XSAVEC__ 1 // CHECK_TRM_M32: #define __XSAVEOPT__ 1 // CHECK_TRM_M32: #define __XSAVES__ 1 @@ -1518,6 +1519,7 @@ // CHECK_TRM_M64: #define __SSE4_2__ 1 // CHECK_TRM_M64: #define __SSE__ 1 // CHECK_TRM_M64: #define __SSSE3__ 1 +// CHECK_TRM_M64: #define __WAITPKG__ 1 // CHECK_TRM_M64: #define __XSAVEC__ 1 // CHECK_TRM_M64: #define __XSAVEOPT__ 1 // CHECK_TRM_M64: #define __XSAVES__ 1 Index: test/Driver/x86-target-features.c === --- test/Driver/x86-target-features.c +++ test/Driver/x86-target-features.c @@ -144,3 +144,8 @@ // RUN: %clang -target i386-linux-gnu -mretpoline -mno-retpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RETPOLINE-EXTERNAL-THUNK %s // RETPOLINE-EXTERNAL-THUNK: "-target-feature" "+retpoline-external-thunk" // NO-RETPOLINE-EXTERNAL-THUNK: "-target-feature" "-retpoline-external-thunk" + +// RUN: %clang -target i386-linux-gnu -mwaitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=WAITPKG %s +// RUN: %clang -target i386-linux-gnu -mno-waitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WAITPKG %s +// WAITPKG: "-target-feature" "+waitpkg" +// NO-WAITPKG: "-target-feature" "-waitpkg" Index: test/CodeGen/waitpkg.c === --- /dev/null +++ test/CodeGen/waitpkg.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -target-feature +waitpkg -o - | FileCheck %s +// RUN: %clang_cc1 %s -ffreestanding -triple i386-unknown-unknown -emit-llvm -target-feature +waitpkg -o - | FileCheck %s + +#include + +#include +#include + +void test_umonitor(void *address) { + //CHECK-LABEL: @test_umonitor + //CHECK: call void @llvm.x86.umonitor(i8* %{{.*}}) + return _umonitor(address); +} + +uint8_t test_umwait(uint32_t control, uint64_t counter) { + //CHECK-LABEL: @test_umwait + //CHECK: call i8 @llvm.x86.umwait(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _umwait(control, counter); +} + +uint8_t test_tpause(uint32_t control, uint64_t counter) { + //CHECK-LABEL: @test_tpause + //CHECK: call i8 @llvm.x86.tpause(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _tpause(control, counter); +} Index: lib/Headers/x86intrin.h === --- lib/Headers/x86intrin.h +++ lib/Headers/x86intrin.h @@ -96,4 +96,8 @@ #include #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__WAITPKG__) +#include +#endif + #endif /* __X86INTRIN_H */ Index: lib/Headers/waitpkgintrin.h === --- /dev/null +++ lib/Headers/waitpkgintrin.h @@ -0,0 +1,56 @@ +/*===--- waitpkgintrin.h - WAITPKG === + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===---=== + */ +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef _WAITPKGINTRIN_H +#define _WAITPKGINTRIN_H + +/* Define the default attribu
[PATCH] D45254: [X86][WAITPKG] WaitPKG intrinsics
GBuella updated this revision to Diff 142910. GBuella added a comment. Modified the intrinsic. https://reviews.llvm.org/D45254 Files: include/clang/Basic/BuiltinsX86.def include/clang/Driver/Options.td lib/Basic/Targets/X86.cpp lib/Basic/Targets/X86.h lib/Headers/CMakeLists.txt lib/Headers/cpuid.h lib/Headers/waitpkgintrin.h lib/Headers/x86intrin.h test/CodeGen/waitpkg.c test/Driver/x86-target-features.c Index: test/Driver/x86-target-features.c === --- test/Driver/x86-target-features.c +++ test/Driver/x86-target-features.c @@ -144,3 +144,8 @@ // RUN: %clang -target i386-linux-gnu -mretpoline -mno-retpoline-external-thunk %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-RETPOLINE-EXTERNAL-THUNK %s // RETPOLINE-EXTERNAL-THUNK: "-target-feature" "+retpoline-external-thunk" // NO-RETPOLINE-EXTERNAL-THUNK: "-target-feature" "-retpoline-external-thunk" + +// RUN: %clang -target i386-linux-gnu -mwaitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=WAITPKG %s +// RUN: %clang -target i386-linux-gnu -mno-waitpkg %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-WAITPKG %s +// WAITPKG: "-target-feature" "+waitpkg" +// NO-WAITPKG: "-target-feature" "-waitpkg" Index: test/CodeGen/waitpkg.c === --- /dev/null +++ test/CodeGen/waitpkg.c @@ -0,0 +1,25 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -emit-llvm -target-feature +waitpkg -o - | FileCheck %s +// RUN: %clang_cc1 %s -ffreestanding -triple i386-unknown-unknown -emit-llvm -target-feature +waitpkg -o - | FileCheck %s + +#include + +#include +#include + +void test_umonitor(void *address) { + //CHECK-LABEL: @test_umonitor + //CHECK: call void @llvm.x86.umonitor(i8* %{{.*}}) + return _umonitor(address); +} + +uint8_t test_umwait(uint32_t control, uint64_t counter) { + //CHECK-LABEL: @test_umwait + //CHECK: call i8 @llvm.x86.umwait(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _umwait(control, counter); +} + +uint8_t test_tpause(uint32_t control, uint64_t counter) { + //CHECK-LABEL: @test_tpause + //CHECK: call i8 @llvm.x86.tpause(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _tpause(control, counter); +} Index: lib/Headers/x86intrin.h === --- lib/Headers/x86intrin.h +++ lib/Headers/x86intrin.h @@ -96,4 +96,8 @@ #include #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__WAITPKG__) +#include +#endif + #endif /* __X86INTRIN_H */ Index: lib/Headers/waitpkgintrin.h === --- /dev/null +++ lib/Headers/waitpkgintrin.h @@ -0,0 +1,56 @@ +/*===--- waitpkgintrin.h - WAITPKG === + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===---=== + */ +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef _WAITPKGINTRIN_H +#define _WAITPKGINTRIN_H + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("waitpkg"))) + +static __inline__ void __DEFAULT_FN_ATTRS +_umonitor (void * __ADDRESS) +{ + __builtin_ia32_umonitor (__ADDRESS); +} + +static __inline__ __UINT8_TYPE__ __DEFAULT_FN_ATTRS +_umwait (__UINT32_TYPE__ __CONTROL, __UINT64_TYPE__ __COUNTER) +{ + return __builtin_ia32_umwait (__CONTROL, +(unsigned int)(__COUNTER >> 32), (unsigned int)__COUNTER); +} + +static __inline__ __UINT8_TYPE__ __DEFAULT_FN_ATTRS +_tpause (__UINT32_TYPE__ __CONTROL, __UINT64_TYPE__ __COUNTER) +{ + return __builtin_ia32_tpause (__CONTROL, +(unsigned int)(__COUNTER >> 32), (unsigned int)__COUNTER); +} + +#undef __DEFAULT_FN_ATTRS + +#endif /* _WAITPKGINTRIN_H */ Index: lib/Header
r330248 - Revert r330195 "[NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only".
Author: kosarev Date: Wed Apr 18 05:02:49 2018 New Revision: 330248 URL: http://llvm.org/viewvc/llvm-project?rev=330248&view=rev Log: Revert r330195 "[NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only". Differential Revision: https://reviews.llvm.org/D45668 Modified: cfe/trunk/include/clang/Basic/arm_neon.td cfe/trunk/test/CodeGen/arm_neon_intrinsics.c Modified: cfe/trunk/include/clang/Basic/arm_neon.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=330248&r1=330247&r2=330248&view=diff == --- cfe/trunk/include/clang/Basic/arm_neon.td (original) +++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Apr 18 05:02:49 2018 @@ -398,14 +398,8 @@ def VCOMBINE : NoTestOpInst<"vcombine", // E.3.21 Splitting vectors let InstName = "vmov" in { -def VGET_HIGH : NoTestOpInst<"vget_high", "dk", "csilfUcUsUiUlPcPs", OP_HI>; -def VGET_LOW : NoTestOpInst<"vget_low", "dk", "csilfUcUsUiUlPcPs", OP_LO>; -} -let ArchGuard = "__ARM_ARCH >= 8 && defined(__aarch64__)" in { - let InstName = "vmov" in { - def VGET_HIGH_F16 : NoTestOpInst<"vget_high", "dk", "h", OP_HI>; - def VGET_LOW_F16 : NoTestOpInst<"vget_low", "dk", "h", OP_LO>; - } +def VGET_HIGH : NoTestOpInst<"vget_high", "dk", "csilhfUcUsUiUlPcPs", OP_HI>; +def VGET_LOW : NoTestOpInst<"vget_low", "dk", "csilhfUcUsUiUlPcPs", OP_LO>; } Modified: cfe/trunk/test/CodeGen/arm_neon_intrinsics.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/arm_neon_intrinsics.c?rev=330248&r1=330247&r2=330248&view=diff == --- cfe/trunk/test/CodeGen/arm_neon_intrinsics.c (original) +++ cfe/trunk/test/CodeGen/arm_neon_intrinsics.c Wed Apr 18 05:02:49 2018 @@ -3254,6 +3254,13 @@ int64x1_t test_vget_high_s64(int64x2_t a return vget_high_s64(a); } +// CHECK-LABEL: @test_vget_high_f16( +// CHECK: [[SHUFFLE_I:%.*]] = shufflevector <8 x half> %a, <8 x half> %a, <4 x i32> +// CHECK: ret <4 x half> [[SHUFFLE_I]] +float16x4_t test_vget_high_f16(float16x8_t a) { + return vget_high_f16(a); +} + // CHECK-LABEL: @test_vget_high_f32( // CHECK: [[SHUFFLE_I:%.*]] = shufflevector <4 x float> %a, <4 x float> %a, <2 x i32> // CHECK: ret <2 x float> [[SHUFFLE_I]] @@ -3553,6 +3560,13 @@ int64x1_t test_vget_low_s64(int64x2_t a) return vget_low_s64(a); } +// CHECK-LABEL: @test_vget_low_f16( +// CHECK: [[SHUFFLE_I:%.*]] = shufflevector <8 x half> %a, <8 x half> %a, <4 x i32> +// CHECK: ret <4 x half> [[SHUFFLE_I]] +float16x4_t test_vget_low_f16(float16x8_t a) { + return vget_low_f16(a); +} + // CHECK-LABEL: @test_vget_low_f32( // CHECK: [[SHUFFLE_I:%.*]] = shufflevector <4 x float> %a, <4 x float> %a, <2 x i32> // CHECK: ret <2 x float> [[SHUFFLE_I]] ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45685: [Sema] Add -wtest global flag that silences -Wself-assign for overloaded operators.
rjmccall added a comment. I'm sorry, that warning *is* in self-assign, although I'm not sure it should be. Repository: rC Clang https://reviews.llvm.org/D45685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45685: [Sema] Add -wtest global flag that silences -Wself-assign for overloaded operators.
rjmccall added a comment. The goal of having a unified option is that you can uniformly suppress warnings that don't always make sense in unit tests. It's future-proofing against the addition of other warnings (probably C++ warnings) that might not make sense for unit tests, like extending the `x &= x` warning (which is not in -Wself-assign) to user-defined operators. You don't think you would be able to take advantage of that? Because `-Wno-self-assign-overloaded-nonfield` is rather, uh, pretty precisely targeted for exactly that use case; I can't imagine why someone would use `-Wself-assign-overloaded-nofield` *positively*, or even *negatively* for any purpose besides suppressing a unit-test problem. If you can't reasonably just add this to unit tests, of course you can just add it globally, but that's just as true for `-wtest`as it would be for `-Wno-self-assign-overloaded-nonfield`, and the former seems more self-descriptive of the problem when it appears in a general CFLAGS line: you don't have a reasonable way of suppressing it for just unit tests so you have to suppress it globally. Repository: rC Clang https://reviews.llvm.org/D45685 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D41897: Fixing a crash in Sema.
jkorous-apple closed this revision. jkorous-apple added a comment. Landed as git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@322438 91177308-0d34-0410-b5e6-96231b3b80d8 https://reviews.llvm.org/D41897 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D45668: [NEON] Define vget_high_f16() and vget_low_f16() intrinsics in AArch64 mode only
kosarev added a comment. Sure, will do. Should we treat these intrinsics as ARMv8 or ARMv7/v8? Also, would you mind if I commit a comment under this differential revision explaining the situation? Repository: rL LLVM https://reviews.llvm.org/D45668 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits