Re: [PATCH] D16495: [CUDA] Use Triple::isNVPTX() instead of enumerating nvptx && nvptx64.
echristo added a comment. Probably qualifies as obvious. Also can you add some text to the assert while you're there? http://reviews.llvm.org/D16495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16495: [CUDA] Use Triple::isNVPTX() instead of enumerating nvptx && nvptx64.
Probably qualifies as obvious. Also can you add some text to the assert while you're there? On Fri, Jan 22, 2016, 5:07 PM Justin Lebar wrote: > jlebar created this revision. > jlebar added a reviewer: tra. > jlebar added subscribers: cfe-commits, jhen, echristo. > > No functional changes. > > http://reviews.llvm.org/D16495 > > Files: > lib/Driver/Tools.cpp > > Index: lib/Driver/Tools.cpp > === > --- lib/Driver/Tools.cpp > +++ lib/Driver/Tools.cpp > @@ -10651,8 +10651,7 @@ > const char *LinkingOutput) const { >const auto &TC = >static_cast(getToolChain()); > - assert(TC.getArch() == llvm::Triple::nvptx || > - TC.getArch() == llvm::Triple::nvptx64); > + assert(TC.getTriple().isNVPTX()); > >std::vector gpu_archs = >Args.getAllArgValues(options::OPT_march_EQ); > @@ -10720,8 +10719,7 @@ > const char *LinkingOutput) const { >const auto &TC = >static_cast(getToolChain()); > - assert(TC.getArch() == llvm::Triple::nvptx || > - TC.getArch() == llvm::Triple::nvptx64); > + assert(TC.getTriple().isNVPTX()); > >ArgStringList CmdArgs; >CmdArgs.push_back("--cuda"); > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15921: [analyzer] Utility to match function calls.
xazax.hun marked an inline comment as done. xazax.hun added a comment. Thank you for the fix and sorry for not noticing this. I was unlucky and the tests did pass on my machine. Repository: rL LLVM http://reviews.llvm.org/D15921 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[libcxx] r258625 - Revert "unordered_map: Reuse insert logic in emplace when possible, NFC"
Author: dexonsmith Date: Sat Jan 23 09:12:47 2016 New Revision: 258625 URL: http://llvm.org/viewvc/llvm-project?rev=258625&view=rev Log: Revert "unordered_map: Reuse insert logic in emplace when possible, NFC" This reverts commit r258575. EricWF sent me an email (no link since it was off-list) requesting to review this pre-commit instead of post-commit. Modified: libcxx/trunk/include/unordered_map Modified: libcxx/trunk/include/unordered_map URL: http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=258625&r1=258624&r2=258625&view=diff == --- libcxx/trunk/include/unordered_map (original) +++ libcxx/trunk/include/unordered_map Sat Jan 23 09:12:47 2016 @@ -922,32 +922,8 @@ public: #ifndef _LIBCPP_HAS_NO_VARIADICS template -pair emplace(_Args&&... __args) -{return __emplace_dispatch(std::forward<_Args>(__args)...);} +pair emplace(_Args&&... __args); -private: -template -pair __emplace_dispatch(_Arg&& __arg) -{ -typedef is_constructible __constructible; -return __emplace_insert_if_constructible(std::forward<_Arg>(__arg), - __constructible()); -} -template -pair __emplace_dispatch(_Arg1&& __arg1, _Args&&... __args) -{return __emplace_impl(std::forward<_Arg1>(__arg1), std::forward<_Args>(__args)...);} - -template -pair __emplace_insert_if_constructible(_Arg&& __arg, false_type) -{return __emplace_impl(std::forward<_Arg>(__arg));} -template -pair __emplace_insert_if_constructible(_Arg&& __arg, true_type) -{return insert(std::forward<_Arg>(__arg));} - -template -pair __emplace_impl(_Args&&... __args); - -public: template _LIBCPP_INLINE_VISIBILITY #if _LIBCPP_DEBUG_LEVEL >= 2 @@ -956,7 +932,7 @@ public: _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, "unordered_map::emplace_hint(const_iterator, args...) called with an iterator not" " referring to this unordered_map"); -return emplace(_VSTD::forward<_Args>(__args)...).first; +return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; } #else iterator emplace_hint(const_iterator, _Args&&... __args) @@ -1501,7 +1477,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _ template template pair::iterator, bool> -unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__emplace_impl(_Args&&... __args) +unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args) { __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); pair __r = __table_.__node_insert_unique(__h.get()); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [Diffusion] rL258575: unordered_map: Reuse insert logic in emplace when possible, NFC
+cfe-commits (This looks like a broken feature of Phab. I suggest not using it, since it hasn't put the patch context in this email, it didn't CC the list, and it spawned a new thread instead of replying to the commit: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147763.html I'll reply to that mail in a moment to link to this thread.) > On 2016-Jan-22, at 20:13, Eric Fiselier wrote: > > EricWF added a subscriber: EricWF. > EricWF raised a concern with this commit. > EricWF added a comment. > > @dexonsmith This change should have been reviewed before committing. Sorry about this. I had assumed LLVM's culture of post-commit review. I'll take things more slowly going forward. > I think there are better ways to make `insert` and `emplace` work together. > In particular I would like to put most of the logic in `<__hash_table>` not > ``. Given that __hash_table and unordered_map have incompatible concepts of "value_type", and the purpose of sharing them is to optimize away mallocs when we can pull out the right parts of value_type, I'm skeptical. > Please revert this commit. r258625 > /libcxx/trunk/include/unordered_map:930 I think we can just call > `__table_.__insert_unique(std::forward<_Arg>(__arg))` for the one arg case > and `__table_. The purpose of this commit was to ensure that emplace gets the same malloc optimizations as insert, so that the tests in this patch pass: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147766.html I don't see how this alternate approach would accomplish that? > /libcxx/trunk/include/unordered_map:932 I think this optimization should be > limited to when "_Arg" is "value_type". The patch linked above optimizes mallocs whenever key_type matches. I also have a follow-up (originally part of that patch) that strengthens the optimization to whenever we can convert to key_type (and destruct it) trivially. It's simplest to forward to insert() to guarantee that each behaves "as if" the other were called; otherwise that patch needs to duplicate all the type-based dispatch in two places. > * `is_constructible` can cause a hard compile error when using Clang. I > prefer not to use it when possible. That's terrible. In what versions? (If ToT, we should fix that... can you point me at a PR?) It's already used in the enable_if for `insert()`. Does it break there? (My experience is that hard compile errors usually prevent meta-functions from being used in enable_ifs; I'd assumed there weren't any bugs in is_constructible since I saw the use below.) Maybe I should pivot the malloc optimization; if we change `insert()` to just call `emplace()` -- valid because of the enable_if (I assume the bugs in is_constructible don't cause miscompiles?) -- I can do the malloc optimization inside the single-argument `emplace()`. This would require more intrusive changes to __hash_table of course, since I think your original commit (r239666) only optimized the insert-side. What do you think? > > > Users: > dexonsmith (Author) > EricWF (Auditor) > > http://reviews.llvm.org/rL258575 > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [libcxx] r258575 - unordered_map: Reuse insert logic in emplace when possible, NFC
Note that this was reverted due to post-commit review, but Phab forked it into a different thread. Here it is: http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20160118/147795.html > On 2016-Jan-22, at 14:48, Duncan P. N. Exon Smith via cfe-commits > wrote: > > Author: dexonsmith > Date: Fri Jan 22 16:48:02 2016 > New Revision: 258575 > > URL: http://llvm.org/viewvc/llvm-project?rev=258575&view=rev > Log: > unordered_map: Reuse insert logic in emplace when possible, NFC > > An upcoming commit will add an optimization to insert() that avoids > unnecessary mallocs when we can safely extract the key type. This > commit shares code between emplace() and insert(): > - if emplace() is given a single argument, and > - value_type is constructible from that argument > so that we have a single code path for the two. > > I also updated the debug version of emplace_hint() to defer to > emplace(), like the non-debug version does. > > In both cases, there should be NFC here. > > Modified: >libcxx/trunk/include/unordered_map > > Modified: libcxx/trunk/include/unordered_map > URL: > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/unordered_map?rev=258575&r1=258574&r2=258575&view=diff > == > --- libcxx/trunk/include/unordered_map (original) > +++ libcxx/trunk/include/unordered_map Fri Jan 22 16:48:02 2016 > @@ -922,8 +922,32 @@ public: > #ifndef _LIBCPP_HAS_NO_VARIADICS > > template > -pair emplace(_Args&&... __args); > +pair emplace(_Args&&... __args) > +{return __emplace_dispatch(std::forward<_Args>(__args)...);} > > +private: > +template > +pair __emplace_dispatch(_Arg&& __arg) > +{ > +typedef is_constructible __constructible; > +return > __emplace_insert_if_constructible(std::forward<_Arg>(__arg), > + __constructible()); > +} > +template > +pair __emplace_dispatch(_Arg1&& __arg1, _Args&&... > __args) > +{return __emplace_impl(std::forward<_Arg1>(__arg1), > std::forward<_Args>(__args)...);} > + > +template > +pair __emplace_insert_if_constructible(_Arg&& __arg, > false_type) > +{return __emplace_impl(std::forward<_Arg>(__arg));} > +template > +pair __emplace_insert_if_constructible(_Arg&& __arg, > true_type) > +{return insert(std::forward<_Arg>(__arg));} > + > +template > +pair __emplace_impl(_Args&&... __args); > + > +public: > template > _LIBCPP_INLINE_VISIBILITY > #if _LIBCPP_DEBUG_LEVEL >= 2 > @@ -932,7 +956,7 @@ public: > _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, > "unordered_map::emplace_hint(const_iterator, args...) called > with an iterator not" > " referring to this unordered_map"); > -return > __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; > +return emplace(_VSTD::forward<_Args>(__args)...).first; > } > #else > iterator emplace_hint(const_iterator, _Args&&... __args) > @@ -1477,7 +1501,7 @@ unordered_map<_Key, _Tp, _Hash, _Pred, _ > template > template > pair::iterator, bool> > -unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::emplace(_Args&&... __args) > +unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::__emplace_impl(_Args&&... > __args) > { > __node_holder __h = __construct_node(_VSTD::forward<_Args>(__args)...); > pair __r = __table_.__node_insert_unique(__h.get()); > > > ___ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D12354: [libcxx] Add global assertion handler for debug mode.
> On 2016-Jan-22, at 18:01, Eric Fiselier wrote: > > > > On Fri, Jan 22, 2016 at 10:44 AM, Duncan P. N. Exon Smith > wrote: > > > On 2016-Jan-21, at 22:22, Eric Fiselier wrote: > > > > > > > > On Thu, Jan 21, 2016 at 10:35 PM, Duncan P. N. Exon Smith > > wrote: > > > > > On 2016-Jan-21, at 17:59, Eric Fiselier wrote: > > > > > > EricWF added a comment. > > > > > > In http://reviews.llvm.org/D12354#331776, @dexonsmith wrote: > > > > > >> This patch looks correct to me. Is there any reason it wasn't committed? > > > > > > > > > I was concerned about using a function-local static in the library > > > headers, I don't think libc++ does that anywhere else and I wanted to > > > make sure it was safe to do. > > > > > > > > > http://reviews.llvm.org/D12354 > > > > Ah, in the testing hook. I feel like it's better than the current > > situation, anyway. Unless we have ABI guarantees for _LIBCPP_DEBUG > > since this could lock us in somehow. (Do we? Should we?) > > > > The _LIBCPP_DEBUG mode should produce the same ABI as non-debug builds. > > However I don't see how this patch would "lock us in" or change our ABI > > guarantees. > > The function local static should have vague linkage and be emitted in every > > TU where it is ODR used. > > TU's compiled with debug mode off will not contain or depend on the symbol. > > > > The libc++.dylib will contain it's own copy of the function local static > > since _LIBCPP_ASSERT > > If so, then the hook (as intended) doesn't actually allow testing > the _LIBCPP_ASSERT()s in src/debug.cpp, unless I'm missing something? > > Your right below. libc++.dylib will have it's own copy but the linker will > coalesce it > with the version emitted in the headers. So it will allow testing of debug.cpp > > > In that case, why not just do (2) and not worry about a global variable > at all? I.e., in test/support/debug.hpp, something like: > -- > #define _LIBCPP_ASSERT(c, m) (c ? (void)0 : handleAssertion(m, __FILE__, ...)) > #include <__debug> > -- > > > Do you disagree? Do you have any concerns about this? > > As written, shouldn't the runtime linker coalesce these ODR functions > (and the function-local static) with the version in the headers? This > isn't going to have hidden visibility AFAICT (maybe I missed something). > > > I agree with that 100%. Sorry if I was unclear. It's important that > the function has default visibility so that versions in shared libraries > are properly coalesced. > > > > I want to be 100% sure about the ABI implications. > > Because these functions are inline (and not always_inline, or > internal_linkage, or whatever the new thing is), ODR requires that every > source file is compiled with the exact same version of them. I think > this affects the ABI. > > I don't think ODR is a concern here. The assertion handler function has the > same definition in every TU where it is ODR used. > It's unlikely that the handler function body will need to change any time > soon. Can you clarify on how ODR affects the ABI? > > The functions do have external "linkonce_odr" linkage and will be emited in > new libc++.dylib builds as weak symbols on ELF. > AFAIK it should be a ABI safe change to add/remove weak symbols on Linux. > For example we already get entirely different sets of weak symbols in > libc++.so between debug and release builds on linux. > > I'm not sure how Darwin handles comdat linkonce_odr symbols but hopefully > it's semantically similar to linux. Yes. > @Duncan What are your main concerns about adding a new global variable and > forcing the linker to coalesce it? The only concern is: this *is* an addition to the ABI, and it requires that the function doesn't change going forward. I'm not particularly concerned though. > > > > Thinking through a couple of other options: > > > > 2. The test could provide its own version of _LIBCPP_ASSERT. It's > > not obvious how to hook into the assertions in src/debug.cpp > > though. > > > > > > This could work, but it feels more like a hack than a fix. > > IMO, it's no more hacky than adding function-locals. The point of > this part of the patch is to test calls to _LIBCPP_ASSERT, but > approach (1) affects uses in non-trivial ways (adding global variables > that need to be coalesced between all the affected TUs). At least (2) > limits the hook to the testing framework itself. > > > I think there will be a need to override _LIBCPP_ASSERT calls in the dylib so > I'm hesitant to use this approach. Yup, doesn't work. From your previous mail I had misunderstood that you didn't expect this to work for dylib symbols. > > 1. We need to override _LIBCPP_ASSERT in src/debug.cpp in order to test a lot > of debug mode in the container library. > > 2. I would like to use _LIBCPP_ASSERT and the assertion handler to report > errors in src/mutex.cpp. Currently std::mutex uses "assert(ret == 0)" to > check that the pthread system calls succeed. > Currently t
r258628 - Improving documentation for the isMoveAssignmentOperator AST matcher.
Author: aaronballman Date: Sat Jan 23 11:49:18 2016 New Revision: 258628 URL: http://llvm.org/viewvc/llvm-project?rev=258628&view=rev Log: Improving documentation for the isMoveAssignmentOperator AST matcher. Patch by Jonathan Coe. Modified: cfe/trunk/docs/LibASTMatchersReference.html cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Modified: cfe/trunk/docs/LibASTMatchersReference.html URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=258628&r1=258627&r2=258628&view=diff == --- cfe/trunk/docs/LibASTMatchersReference.html (original) +++ cfe/trunk/docs/LibASTMatchersReference.html Sat Jan 23 11:49:18 2016 @@ -1820,11 +1820,13 @@ matches A and C::f, but not B, C, or B:: operator. Given - struct S { -S(const S &); #1 -S& operator=(S &&); #2 - }; -cxxMethodDecl(isMoveAssignmentOperator()) will match #2, but not #1. +struct A { + A &operator=(const A &); + A &operator=(A &&); +}; + +cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not +the first one. Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=258628&r1=258627&r2=258628&view=diff == --- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original) +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Sat Jan 23 11:49:18 2016 @@ -3581,12 +3581,14 @@ AST_MATCHER(CXXMethodDecl, isCopyAssignm /// /// Given /// \code -/// struct S { -/// S(const S &); // #1 -/// S& operator=(S &&); // #2 -/// }; +/// struct A { +/// A &operator=(const A &); +/// A &operator=(A &&); +/// }; /// \endcode -/// cxxMethodDecl(isMoveAssignmentOperator()) will match #2, but not #1. +/// +/// cxxMethodDecl(isMoveAssignmentOperator()) matches the second method but not +/// the first one. AST_MATCHER(CXXMethodDecl, isMoveAssignmentOperator) { return Node.isMoveAssignmentOperator(); } ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16377: Ensure virtual-near-miss does not crash on functions without names
aaron.ballman abandoned this revision. aaron.ballman added a comment. You are correct, this was fixed with http://reviews.llvm.org/D16179. Thanks! http://reviews.llvm.org/D16377 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D15935: Improve diagnostics for literal conversion to Boolean
aaron.ballman added inline comments. Comment at: lib/Sema/SemaChecking.cpp:6985 @@ -6984,6 +6984,3 @@ SmallString<16> PrettyTargetValue; - if (T->isSpecificBuiltinType(BuiltinType::Bool)) -PrettyTargetValue = Value.isZero() ? "false" : "true"; - else -IntegerValue.toString(PrettyTargetValue); + IntegerValue.toString(PrettyTargetValue); manmanren wrote: > Why do we remove the pretty printing for boolean here? Providing context here > will be nice. Because float->Boolean conversion has moved elsewhere (to line 7207 in the new file). http://reviews.llvm.org/D15935 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16511: [MSVC Compat] Only warn for unknown clang-cl arguments
ehsan created this revision. ehsan added a reviewer: rnk. ehsan added a subscriber: cfe-commits. MSVC's driver accepts all unknown arguments but warns about them. clang by default rejects all unknown arguments. This causes issues specifically with build systems such as autoconf which liberally pass things such as $LDFLAGS to the compiler and expect everything to work. This patch teaches clang-cl to ignore unknown driver arguments. http://reviews.llvm.org/D16511 Files: include/clang/Basic/DiagnosticDriverKinds.td lib/Driver/Driver.cpp lib/Driver/Tools.cpp test/Driver/cl-fallback.c test/Driver/unknown-arg.c test/Misc/warning-flags.c Index: test/Misc/warning-flags.c === --- test/Misc/warning-flags.c +++ test/Misc/warning-flags.c @@ -18,7 +18,7 @@ The list of warnings below should NEVER grow. It should gradually shrink to 0. -CHECK: Warnings without flags (84): +CHECK: Warnings without flags (85): CHECK-NEXT: ext_excess_initializers CHECK-NEXT: ext_excess_initializers_in_char_array_initializer CHECK-NEXT: ext_expected_semi_decl_list @@ -58,6 +58,7 @@ CHECK-NEXT: warn_drv_clang_unsupported CHECK-NEXT: warn_drv_objc_gc_unsupported CHECK-NEXT: warn_drv_pch_not_first_include +CHECK-NEXT: warn_drv_unknown_argument_clang_cl CHECK-NEXT: warn_dup_category_def CHECK-NEXT: warn_duplicate_protocol_def CHECK-NEXT: warn_enum_value_overflow Index: test/Driver/unknown-arg.c === --- test/Driver/unknown-arg.c +++ test/Driver/unknown-arg.c @@ -1,13 +1,22 @@ // RUN: not %clang %s -cake-is-lie -%0 -%d - -munknown-to-clang-option -print-stats -funknown-to-clang-option 2>&1 | \ // RUN: FileCheck %s +// RUN: %clang_cl -cake-is-lie -%0 -%d - -munknown-to-clang-option -print-stats -funknown-to-clang-option -c -- %s 2>&1 | \ +// RUN: FileCheck %s --check-prefix=CL // CHECK: unknown argument: '-cake-is-lie' // CHECK: unknown argument: '-%0' // CHECK: unknown argument: '-%d' // CHECK: unknown argument: '-' // CHECK: unknown argument: '-munknown-to-clang-option' // CHECK: unknown argument: '-print-stats' // CHECK: unknown argument: '-funknown-to-clang-option' +// CL: unknown argument ignored in clang-cl: '-cake-is-lie' +// CL: unknown argument ignored in clang-cl: '-%0' +// CL: unknown argument ignored in clang-cl: '-%d' +// CL: unknown argument ignored in clang-cl: '-' +// CL: unknown argument ignored in clang-cl: '-munknown-to-clang-option' +// CL: unknown argument ignored in clang-cl: '-print-stats' +// CL: unknown argument ignored in clang-cl: '-funknown-to-clang-option' // RUN: %clang -S %s -o %t.s -Wunknown-to-clang-option 2>&1 | FileCheck --check-prefix=IGNORED %s Index: test/Driver/cl-fallback.c === --- test/Driver/cl-fallback.c +++ test/Driver/cl-fallback.c @@ -3,6 +3,7 @@ // RUN: %clang_cl --target=i686-pc-win32 /fallback /Dfoo=bar /Ubaz /Ifoo /O0 /Ox /GR /GR- /Gy /Gy- \ // RUN: /Gw /Gw- /LD /LDd /EHs /EHs- /Zl /MD /MDd /MTd /MT /FImyheader.h /Zi \ +// RUN: -garbage -moregarbage \ // RUN: -### -- %s 2>&1 \ // RUN: | FileCheck %s // CHECK: "-fdiagnostics-format" "msvc-fallback" @@ -31,6 +32,8 @@ // CHECK: "/EHs-" // CHECK: "/Zl" // CHECK: "/MT" +// CHECK: "-garbage" +// CHECK: "-moregarbage" // CHECK: "/Tc" "{{.*cl-fallback.c}}" // CHECK: "/Fo{{.*cl-fallback.*.obj}}" Index: lib/Driver/Tools.cpp === --- lib/Driver/Tools.cpp +++ lib/Driver/Tools.cpp @@ -9694,6 +9694,10 @@ options::OPT__SLASH_MT, options::OPT__SLASH_MTd)) A->render(Args, CmdArgs); + // Pass through all unknown arguments so that the fallback command can see + // them too. + Args.AddAllArgs(CmdArgs, options::OPT_UNKNOWN); + // Input filename. assert(Inputs.size() == 1); const InputInfo &II = Inputs[0]; Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -146,7 +146,9 @@ } for (const Arg *A : Args.filtered(options::OPT_UNKNOWN)) -Diags.Report(diag::err_drv_unknown_argument) << A->getAsString(Args); +Diags.Report(IsCLMode() ? diag::warn_drv_unknown_argument_clang_cl : + diag::err_drv_unknown_argument) + << A->getAsString(Args); return Args; } @@ -1710,8 +1712,11 @@ continue; } - Diag(clang::diag::warn_drv_unused_argument) - << A->getAsString(C.getArgs()); + // In clang-cl, don't mention unknown arguments here since they have + // already been warned about. + if (!IsCLMode() || !A->getOption().matches(options::OPT_UNKNOWN)) +Diag(clang::diag::warn_drv_unused_argument) +<< A->getAsString(C.getArgs()); } } } Index: include/clang/Basic/D
Re: [PATCH] D16502: [CUDA] Reject the alias attribute in CUDA device code.
OK. -eric On Fri, Jan 22, 2016 at 5:56 PM Justin Lebar wrote: > jlebar created this revision. > jlebar added a reviewer: tra. > jlebar added subscribers: echristo, jhen, cfe-commits. > > CUDA (well, strictly speaking, NVPTX) doesn't support aliases. > > http://reviews.llvm.org/D16502 > > Files: > include/clang/Basic/DiagnosticSemaKinds.td > lib/Sema/SemaDeclAttr.cpp > test/SemaCUDA/alias.cu > > Index: test/SemaCUDA/alias.cu > === > --- /dev/null > +++ test/SemaCUDA/alias.cu > @@ -0,0 +1,14 @@ > +// REQUIRES: x86-registered-target > +// REQUIRES: nvptx-registered-target > +// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only > -fcuda-is-device -verify -DEXPECT_ERR %s > +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify > %s > + > + > +// The alias attribute is not allowed in CUDA device code. > +void bar(); > +__attribute__((alias("bar"))) void foo(); > +#ifdef EXPECT_ERR > +// expected-error@-2 {{CUDA does not support aliases}} > +#else > +// expected-no-diagnostics > +#endif > Index: lib/Sema/SemaDeclAttr.cpp > === > --- lib/Sema/SemaDeclAttr.cpp > +++ lib/Sema/SemaDeclAttr.cpp > @@ -1557,6 +1557,9 @@ > S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_darwin); > return; >} > + if (S.Context.getTargetInfo().getTriple().isNVPTX()) { > +S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_nvptx); > + } > >// Aliases should be on declarations, not definitions. >if (const auto *FD = dyn_cast(D)) { > Index: include/clang/Basic/DiagnosticSemaKinds.td > === > --- include/clang/Basic/DiagnosticSemaKinds.td > +++ include/clang/Basic/DiagnosticSemaKinds.td > @@ -6427,6 +6427,7 @@ >"CUDA device code does not support variadic functions">; > def err_va_arg_in_device : Error< >"CUDA device code does not support va_arg">; > +def err_alias_not_supported_on_nvptx : Error<"CUDA does not support > aliases">; > > def warn_non_pod_vararg_with_format_string : Warning< >"cannot pass %select{non-POD|non-trivial}0 object of type %1 to > variadic " > > > ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16502: [CUDA] Reject the alias attribute in CUDA device code.
echristo accepted this revision. echristo added a reviewer: echristo. echristo added a comment. This revision is now accepted and ready to land. OK. One question inline, but feel free to commit after answering one way or the other :) -eric Comment at: test/SemaCUDA/alias.cu:1-2 @@ +1,3 @@ +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target +// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify -DEXPECT_ERR %s Why does this require a registered target? Pretty sure TargetInfo should be able to cope with all of these. http://reviews.llvm.org/D16502 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16502: [CUDA] Reject the alias attribute in CUDA device code.
jlebar added inline comments. Comment at: test/SemaCUDA/alias.cu:1-2 @@ +1,3 @@ +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target +// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify -DEXPECT_ERR %s echristo wrote: > Why does this require a registered target? Pretty sure TargetInfo should be > able to cope with all of these. Honestly I've been cargo-culting those lines from other SemaCUDA tests. Would you mind elaborating on what they're for? http://reviews.llvm.org/D16502 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D16514: Add -stop-on-failure driver option, and enable it by default for CUDA compiles.
jlebar created this revision. jlebar added a reviewer: tra. jlebar added subscribers: echristo, cfe-commits, jhen. When compiling CUDA, we run the frontend N times, once for each device arch. This means that if you have a compile error in your file, you'll see that error N times. Relatedly, if ptxas fails, we'll output that error and then still try to pass its output to fatbinary, which then fails because (duh) its input file doesn't exist. This patch stops compilations with -stop-on-failure as soon as we encounter an error. -stop-on-failure is turned on by default for CUDA compilations. http://reviews.llvm.org/D16514 Files: include/clang/Driver/Compilation.h include/clang/Driver/Driver.h include/clang/Driver/Options.td lib/Driver/Compilation.cpp lib/Driver/Driver.cpp Index: lib/Driver/Driver.cpp === --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -58,7 +58,8 @@ CCPrintHeadersFilename(nullptr), CCLogDiagnosticsFilename(nullptr), CCCPrintBindings(false), CCPrintHeaders(false), CCLogDiagnostics(false), CCGenDiagnostics(false), CCCGenericGCCName(""), CheckInputsExist(true), - CCCUsePCH(true), SuppressMissingInputWarning(false) { + CCCUsePCH(true), SuppressMissingInputWarning(false), + StopOnJobFailure(false) { // Provide a sane fallback if no VFS is specified. if (!this->VFS) @@ -503,6 +504,16 @@ InputList Inputs; BuildInputs(C->getDefaultToolChain(), *TranslatedArgs, Inputs); + // StopOnJobFailure defaults to false, except for CUDA compilations. + if (Arg *A = C->getArgs().getLastArg(options::OPT_stop_on_failure, + options::OPT_nostop_on_failure)) +StopOnJobFailure = A->getOption().matches(options::OPT_stop_on_failure); + else +StopOnJobFailure = +llvm::any_of(Inputs, [](const std::pair &I) { + return I.first == types::TY_CUDA; +}); + // Construct the list of abstract actions to perform for this compilation. On // MachO targets this uses the driver-driver and universal actions. if (TC.getTriple().isOSBinFormatMachO()) @@ -636,7 +647,7 @@ // Generate preprocessed output. SmallVector, 4> FailingCommands; - C.ExecuteJobs(C.getJobs(), FailingCommands); + C.ExecuteJobs(C.getJobs(), /* StopOnFailure = */ false, FailingCommands); // If any of the preprocessing commands failed, clean up and exit. if (!FailingCommands.empty()) { @@ -728,7 +739,7 @@ for (auto &Job : C.getJobs()) setUpResponseFiles(C, Job); - C.ExecuteJobs(C.getJobs(), FailingCommands); + C.ExecuteJobs(C.getJobs(), StopOnJobFailure, FailingCommands); // Remove temp files. C.CleanupFileList(C.getTempFiles()); Index: lib/Driver/Compilation.cpp === --- lib/Driver/Compilation.cpp +++ lib/Driver/Compilation.cpp @@ -188,14 +188,17 @@ return !ActionFailed(&C.getSource(), FailingCommands); } -void Compilation::ExecuteJobs(const JobList &Jobs, +void Compilation::ExecuteJobs(const JobList &Jobs, bool StopOnFailure, FailingCommandList &FailingCommands) const { for (const auto &Job : Jobs) { if (!InputsOk(Job, FailingCommands)) continue; const Command *FailingCommand = nullptr; -if (int Res = ExecuteCommand(Job, FailingCommand)) +if (int Res = ExecuteCommand(Job, FailingCommand)) { FailingCommands.push_back(std::make_pair(Res, FailingCommand)); + if (StopOnFailure) +return; +} } } Index: include/clang/Driver/Options.td === --- include/clang/Driver/Options.td +++ include/clang/Driver/Options.td @@ -1801,6 +1801,11 @@ def : Flag<["-"], "no-integrated-as">, Alias, Flags<[CC1Option, DriverOption]>; +def stop_on_failure : Flag<["-"], "stop-on-failure">, Flags<[DriverOption]>, + HelpText<"Stop running jobs as soon as one fails. This is the default during " +"CUDA compilation without --save-temps.">; +def nostop_on_failure : Flag<["-"], "nostop-on-failure">, Flags<[DriverOption]>; + def working_directory : JoinedOrSeparate<["-"], "working-directory">, Flags<[CC1Option]>, HelpText<"Resolve file paths relative to the specified directory">; def working_directory_EQ : Joined<["-"], "working-directory=">, Flags<[CC1Option]>, Index: include/clang/Driver/Driver.h === --- include/clang/Driver/Driver.h +++ include/clang/Driver/Driver.h @@ -192,6 +192,10 @@ /// Certain options suppress the 'no input files' warning. bool SuppressMissingInputWarning : 1; + /// Should we stop running all jobs as soon as one fails? If false, we run as + /// much as we can. + bool StopOnJobFailure : 1; + std::list TempFiles; std::list ResultFiles; Index: include/clang/Driver/Compilation.h ===
Re: [PATCH] D16438: Fix printing of types in initializers with suppressed tags.
rsmith accepted this revision. rsmith added a comment. This revision is now accepted and ready to land. LGTM, thanks! Do you have SVN commit access? http://reviews.llvm.org/D16438 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16502: [CUDA] Reject the alias attribute in CUDA device code.
jlebar added inline comments. Comment at: test/SemaCUDA/alias.cu:1-2 @@ +1,3 @@ +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target +// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify -DEXPECT_ERR %s jlebar wrote: > echristo wrote: > > Why does this require a registered target? Pretty sure TargetInfo should be > > able to cope with all of these. > Honestly I've been cargo-culting those lines from other SemaCUDA tests. > Would you mind elaborating on what they're for? Removed them in the meantime. http://reviews.llvm.org/D16502 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r258640 - [CUDA] Use Triple::isNVPTX() instead of enumerating nvptx && nvptx64.
Author: jlebar Date: Sat Jan 23 15:28:08 2016 New Revision: 258640 URL: http://llvm.org/viewvc/llvm-project?rev=258640&view=rev Log: [CUDA] Use Triple::isNVPTX() instead of enumerating nvptx && nvptx64. Summary: No functional changes. Subscribers: tra, echristo, jhen, cfe-commits Differential Revision: http://reviews.llvm.org/D16495 Modified: cfe/trunk/lib/Driver/Tools.cpp Modified: cfe/trunk/lib/Driver/Tools.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=258640&r1=258639&r2=258640&view=diff == --- cfe/trunk/lib/Driver/Tools.cpp (original) +++ cfe/trunk/lib/Driver/Tools.cpp Sat Jan 23 15:28:08 2016 @@ -10660,8 +10660,7 @@ void NVPTX::Assembler::ConstructJob(Comp const char *LinkingOutput) const { const auto &TC = static_cast(getToolChain()); - assert(TC.getArch() == llvm::Triple::nvptx || - TC.getArch() == llvm::Triple::nvptx64); + assert(TC.getTriple().isNVPTX() && "Wrong platform"); std::vector gpu_archs = Args.getAllArgValues(options::OPT_march_EQ); @@ -10729,8 +10728,7 @@ void NVPTX::Linker::ConstructJob(Compila const char *LinkingOutput) const { const auto &TC = static_cast(getToolChain()); - assert(TC.getArch() == llvm::Triple::nvptx || - TC.getArch() == llvm::Triple::nvptx64); + assert(TC.getTriple().isNVPTX() && "Wrong platform"); ArgStringList CmdArgs; CmdArgs.push_back("--cuda"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16495: [CUDA] Use Triple::isNVPTX() instead of enumerating nvptx && nvptx64.
jlebar added a comment. In http://reviews.llvm.org/D16495#334383, @echristo wrote: > Probably qualifies as obvious. Also can you add some text to the assert > while you're there? Done in my local tree, will submit with that change. http://reviews.llvm.org/D16495 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r258641 - [CUDA] Reject the alias attribute in CUDA device code.
Author: jlebar Date: Sat Jan 23 15:28:10 2016 New Revision: 258641 URL: http://llvm.org/viewvc/llvm-project?rev=258641&view=rev Log: [CUDA] Reject the alias attribute in CUDA device code. Summary: CUDA (well, strictly speaking, NVPTX) doesn't support aliases. Reviewers: echristo Subscribers: cfe-commits, jhen, tra Differential Revision: http://reviews.llvm.org/D16502 Added: cfe/trunk/test/SemaCUDA/alias.cu Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDeclAttr.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258641&r1=258640&r2=258641&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 23 15:28:10 2016 @@ -6425,6 +6425,7 @@ def warn_kern_is_inline : Warning< InGroup; def err_va_arg_in_device : Error< "CUDA device code does not support va_arg">; +def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">; def warn_non_pod_vararg_with_format_string : Warning< "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic " Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=258641&r1=258640&r2=258641&view=diff == --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original) +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Sat Jan 23 15:28:10 2016 @@ -1557,6 +1557,9 @@ static void handleAliasAttr(Sema &S, Dec S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_darwin); return; } + if (S.Context.getTargetInfo().getTriple().isNVPTX()) { +S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_nvptx); + } // Aliases should be on declarations, not definitions. if (const auto *FD = dyn_cast(D)) { Added: cfe/trunk/test/SemaCUDA/alias.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/alias.cu?rev=258641&view=auto == --- cfe/trunk/test/SemaCUDA/alias.cu (added) +++ cfe/trunk/test/SemaCUDA/alias.cu Sat Jan 23 15:28:10 2016 @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify -DEXPECT_ERR %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s + +// The alias attribute is not allowed in CUDA device code. +void bar(); +__attribute__((alias("bar"))) void foo(); +#ifdef EXPECT_ERR +// expected-error@-2 {{CUDA does not support aliases}} +#else +// expected-no-diagnostics +#endif ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r258643 - [CUDA] Disallow variadic functions other than printf in device code.
Author: jlebar Date: Sat Jan 23 15:28:17 2016 New Revision: 258643 URL: http://llvm.org/viewvc/llvm-project?rev=258643&view=rev Log: [CUDA] Disallow variadic functions other than printf in device code. Reviewers: tra Subscribers: cfe-commits, echristo, jhen Differential Revision: http://reviews.llvm.org/D16484 Added: cfe/trunk/test/SemaCUDA/vararg.cu - copied, changed from r258642, cfe/trunk/test/SemaCUDA/va-arg.cu Removed: cfe/trunk/test/SemaCUDA/va-arg.cu Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDecl.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=258643&r1=258642&r2=258643&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Jan 23 15:28:17 2016 @@ -6423,6 +6423,8 @@ def warn_kern_is_method : Extension< def warn_kern_is_inline : Warning< "ignored 'inline' attribute on kernel function %0">, InGroup; +def err_variadic_device_fn : Error< + "CUDA device code does not support variadic functions">; def err_va_arg_in_device : Error< "CUDA device code does not support va_arg">; def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">; Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=258643&r1=258642&r2=258643&view=diff == --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Sat Jan 23 15:28:17 2016 @@ -8276,18 +8276,26 @@ Sema::ActOnFunctionDeclarator(Scope *S, MarkUnusedFileScopedDecl(NewFD); - if (getLangOpts().CUDA) -if (IdentifierInfo *II = NewFD->getIdentifier()) - if (!NewFD->isInvalidDecl() && - NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { -if (II->isStr("cudaConfigureCall")) { - if (!R->getAs()->getReturnType()->isScalarType()) -Diag(NewFD->getLocation(), diag::err_config_scalar_return); + if (getLangOpts().CUDA) { +IdentifierInfo *II = NewFD->getIdentifier(); +if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() && +NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { + if (!R->getAs()->getReturnType()->isScalarType()) +Diag(NewFD->getLocation(), diag::err_config_scalar_return); + + Context.setcudaConfigureCallDecl(NewFD); +} + +// Variadic functions, other than a *declaration* of printf, are not allowed +// in device-side CUDA code. +if (NewFD->isVariadic() && (NewFD->hasAttr() || +NewFD->hasAttr()) && +!(II && II->isStr("printf") && NewFD->isExternC() && + !D.isFunctionDefinition())) { + Diag(NewFD->getLocation(), diag::err_variadic_device_fn); +} + } - Context.setcudaConfigureCallDecl(NewFD); -} - } - // Here we have an function template explicit specialization at class scope. // The actually specialization will be postponed to template instatiation // time via the ClassScopeFunctionSpecializationDecl node. Removed: cfe/trunk/test/SemaCUDA/va-arg.cu URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/va-arg.cu?rev=258642&view=auto == --- cfe/trunk/test/SemaCUDA/va-arg.cu (original) +++ cfe/trunk/test/SemaCUDA/va-arg.cu (removed) @@ -1,28 +0,0 @@ -// REQUIRES: x86-registered-target -// REQUIRES: nvptx-registered-target -// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \ -// RUN: -verify -DEXPECT_ERR %s -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s - -#include -#include "Inputs/cuda.h" - -__device__ void foo() { - va_list list; - va_arg(list, int); -#ifdef EXPECT_ERR - // expected-error@-2 {{CUDA device code does not support va_arg}} -#endif -} - -void bar() { - va_list list; - va_arg(list, int); // OK: host-only -} - -__device__ void baz() { -#if !defined(__CUDA_ARCH__) - va_list list; - va_arg(list, int); // OK: only seen when compiling for host -#endif -} Copied: cfe/trunk/test/SemaCUDA/vararg.cu (from r258642, cfe/trunk/test/SemaCUDA/va-arg.cu) URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCUDA/vararg.cu?p2=cfe/trunk/test/SemaCUDA/vararg.cu&p1=cfe/trunk/test/SemaCUDA/va-arg.cu&r1=258642&r2=258643&rev=258643&view=diff == --- cfe/trunk/test/SemaCUDA/va-arg.cu (original) +++ cfe/trunk/test/SemaCUDA/vararg.cu Sat Jan 23 15:28:17 2016 @@ -2,7 +2,7 @@ // REQUIRES: nvptx-registered-target // RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device
Re: [PATCH] D16502: [CUDA] Reject the alias attribute in CUDA device code.
This revision was automatically updated to reflect the committed changes. Closed by commit rL258641: [CUDA] Reject the alias attribute in CUDA device code. (authored by jlebar). Changed prior to commit: http://reviews.llvm.org/D16502?vs=45783&id=45809#toc Repository: rL LLVM http://reviews.llvm.org/D16502 Files: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDeclAttr.cpp cfe/trunk/test/SemaCUDA/alias.cu Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -6425,6 +6425,7 @@ InGroup; def err_va_arg_in_device : Error< "CUDA device code does not support va_arg">; +def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">; def warn_non_pod_vararg_with_format_string : Warning< "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic " Index: cfe/trunk/test/SemaCUDA/alias.cu === --- cfe/trunk/test/SemaCUDA/alias.cu +++ cfe/trunk/test/SemaCUDA/alias.cu @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify -DEXPECT_ERR %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s + +// The alias attribute is not allowed in CUDA device code. +void bar(); +__attribute__((alias("bar"))) void foo(); +#ifdef EXPECT_ERR +// expected-error@-2 {{CUDA does not support aliases}} +#else +// expected-no-diagnostics +#endif Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp === --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp @@ -1557,6 +1557,9 @@ S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_darwin); return; } + if (S.Context.getTargetInfo().getTriple().isNVPTX()) { +S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_nvptx); + } // Aliases should be on declarations, not definitions. if (const auto *FD = dyn_cast(D)) { Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -6425,6 +6425,7 @@ InGroup; def err_va_arg_in_device : Error< "CUDA device code does not support va_arg">; +def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">; def warn_non_pod_vararg_with_format_string : Warning< "cannot pass %select{non-POD|non-trivial}0 object of type %1 to variadic " Index: cfe/trunk/test/SemaCUDA/alias.cu === --- cfe/trunk/test/SemaCUDA/alias.cu +++ cfe/trunk/test/SemaCUDA/alias.cu @@ -0,0 +1,11 @@ +// RUN: %clang_cc1 -triple nvptx-unknown-cuda -fsyntax-only -fcuda-is-device -verify -DEXPECT_ERR %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s + +// The alias attribute is not allowed in CUDA device code. +void bar(); +__attribute__((alias("bar"))) void foo(); +#ifdef EXPECT_ERR +// expected-error@-2 {{CUDA does not support aliases}} +#else +// expected-no-diagnostics +#endif Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp === --- cfe/trunk/lib/Sema/SemaDeclAttr.cpp +++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp @@ -1557,6 +1557,9 @@ S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_darwin); return; } + if (S.Context.getTargetInfo().getTriple().isNVPTX()) { +S.Diag(Attr.getLoc(), diag::err_alias_not_supported_on_nvptx); + } // Aliases should be on declarations, not definitions. if (const auto *FD = dyn_cast(D)) { ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16495: [CUDA] Use Triple::isNVPTX() instead of enumerating nvptx && nvptx64.
This revision was automatically updated to reflect the committed changes. Closed by commit rL258640: [CUDA] Use Triple::isNVPTX() instead of enumerating nvptx && nvptx64. (authored by jlebar). Changed prior to commit: http://reviews.llvm.org/D16495?vs=45775&id=45808#toc Repository: rL LLVM http://reviews.llvm.org/D16495 Files: cfe/trunk/lib/Driver/Tools.cpp Index: cfe/trunk/lib/Driver/Tools.cpp === --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -10660,8 +10660,7 @@ const char *LinkingOutput) const { const auto &TC = static_cast(getToolChain()); - assert(TC.getArch() == llvm::Triple::nvptx || - TC.getArch() == llvm::Triple::nvptx64); + assert(TC.getTriple().isNVPTX() && "Wrong platform"); std::vector gpu_archs = Args.getAllArgValues(options::OPT_march_EQ); @@ -10729,8 +10728,7 @@ const char *LinkingOutput) const { const auto &TC = static_cast(getToolChain()); - assert(TC.getArch() == llvm::Triple::nvptx || - TC.getArch() == llvm::Triple::nvptx64); + assert(TC.getTriple().isNVPTX() && "Wrong platform"); ArgStringList CmdArgs; CmdArgs.push_back("--cuda"); Index: cfe/trunk/lib/Driver/Tools.cpp === --- cfe/trunk/lib/Driver/Tools.cpp +++ cfe/trunk/lib/Driver/Tools.cpp @@ -10660,8 +10660,7 @@ const char *LinkingOutput) const { const auto &TC = static_cast(getToolChain()); - assert(TC.getArch() == llvm::Triple::nvptx || - TC.getArch() == llvm::Triple::nvptx64); + assert(TC.getTriple().isNVPTX() && "Wrong platform"); std::vector gpu_archs = Args.getAllArgValues(options::OPT_march_EQ); @@ -10729,8 +10728,7 @@ const char *LinkingOutput) const { const auto &TC = static_cast(getToolChain()); - assert(TC.getArch() == llvm::Triple::nvptx || - TC.getArch() == llvm::Triple::nvptx64); + assert(TC.getTriple().isNVPTX() && "Wrong platform"); ArgStringList CmdArgs; CmdArgs.push_back("--cuda"); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16484: [CUDA] Disallow variadic functions other than printf in device code.
This revision was automatically updated to reflect the committed changes. Closed by commit rL258643: [CUDA] Disallow variadic functions other than printf in device code. (authored by jlebar). Changed prior to commit: http://reviews.llvm.org/D16484?vs=45736&id=45811#toc Repository: rL LLVM http://reviews.llvm.org/D16484 Files: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaCUDA/va-arg.cu cfe/trunk/test/SemaCUDA/vararg.cu Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td === --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td @@ -6423,6 +6423,8 @@ def warn_kern_is_inline : Warning< "ignored 'inline' attribute on kernel function %0">, InGroup; +def err_variadic_device_fn : Error< + "CUDA device code does not support variadic functions">; def err_va_arg_in_device : Error< "CUDA device code does not support va_arg">; def err_alias_not_supported_on_nvptx : Error<"CUDA does not support aliases">; Index: cfe/trunk/test/SemaCUDA/vararg.cu === --- cfe/trunk/test/SemaCUDA/vararg.cu +++ cfe/trunk/test/SemaCUDA/vararg.cu @@ -0,0 +1,42 @@ +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \ +// RUN: -verify -DEXPECT_ERR %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only -verify %s + +#include +#include "Inputs/cuda.h" + +__device__ void foo() { + va_list list; + va_arg(list, int); +#ifdef EXPECT_ERR + // expected-error@-2 {{CUDA device code does not support va_arg}} +#endif +} + +void bar() { + va_list list; + va_arg(list, int); // OK: host-only +} + +__device__ void baz() { +#if !defined(__CUDA_ARCH__) + va_list list; + va_arg(list, int); // OK: only seen when compiling for host +#endif +} + +__device__ void vararg(const char* x, ...) {} +// expected-error@-1 {{CUDA device code does not support variadic functions}} + +extern "C" __device__ int printf(const char* fmt, ...); // OK, special case. + +// Definition of printf not allowed. +extern "C" __device__ int printf(const char* fmt, ...) { return 0; } +// expected-error@-1 {{CUDA device code does not support variadic functions}} + +namespace ns { +__device__ int printf(const char* fmt, ...); +// expected-error@-1 {{CUDA device code does not support variadic functions}} +} Index: cfe/trunk/test/SemaCUDA/va-arg.cu === --- cfe/trunk/test/SemaCUDA/va-arg.cu +++ cfe/trunk/test/SemaCUDA/va-arg.cu @@ -1,28 +0,0 @@ -// REQUIRES: x86-registered-target -// REQUIRES: nvptx-registered-target -// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -fsyntax-only \ -// RUN: -verify -DEXPECT_ERR %s -// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only %s - -#include -#include "Inputs/cuda.h" - -__device__ void foo() { - va_list list; - va_arg(list, int); -#ifdef EXPECT_ERR - // expected-error@-2 {{CUDA device code does not support va_arg}} -#endif -} - -void bar() { - va_list list; - va_arg(list, int); // OK: host-only -} - -__device__ void baz() { -#if !defined(__CUDA_ARCH__) - va_list list; - va_arg(list, int); // OK: only seen when compiling for host -#endif -} Index: cfe/trunk/lib/Sema/SemaDecl.cpp === --- cfe/trunk/lib/Sema/SemaDecl.cpp +++ cfe/trunk/lib/Sema/SemaDecl.cpp @@ -8276,18 +8276,26 @@ MarkUnusedFileScopedDecl(NewFD); - if (getLangOpts().CUDA) -if (IdentifierInfo *II = NewFD->getIdentifier()) - if (!NewFD->isInvalidDecl() && - NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { -if (II->isStr("cudaConfigureCall")) { - if (!R->getAs()->getReturnType()->isScalarType()) -Diag(NewFD->getLocation(), diag::err_config_scalar_return); + if (getLangOpts().CUDA) { +IdentifierInfo *II = NewFD->getIdentifier(); +if (II && II->isStr("cudaConfigureCall") && !NewFD->isInvalidDecl() && +NewFD->getDeclContext()->getRedeclContext()->isTranslationUnit()) { + if (!R->getAs()->getReturnType()->isScalarType()) +Diag(NewFD->getLocation(), diag::err_config_scalar_return); + + Context.setcudaConfigureCallDecl(NewFD); +} + +// Variadic functions, other than a *declaration* of printf, are not allowed +// in device-side CUDA code. +if (NewFD->isVariadic() && (NewFD->hasAttr() || +NewFD->hasAttr()) && +!(II && II->isStr("printf") && NewFD->isExternC() && + !D.isFunctionDefinition())) { + Diag(NewFD->getLocation(), diag::err_variadic_device_fn); +} + } - Context.setcudaConfigureCallDecl(NewFD); -} - } - // Here we have a
r258642 - [CUDA] Make printf work.
Author: jlebar Date: Sat Jan 23 15:28:14 2016 New Revision: 258642 URL: http://llvm.org/viewvc/llvm-project?rev=258642&view=rev Log: [CUDA] Make printf work. Summary: The code in CGCUDACall is largely based on a patch written by Eli Bendersky: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20140324/210218.html That patch implemented an LLVM pass lowering printf to vprintf; this one does something similar, but in Clang codegen. Reviewers: echristo Subscribers: cfe-commits, jhen, tra, majnemer Differential Revision: http://reviews.llvm.org/D16372 Added: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp cfe/trunk/test/CodeGenCUDA/printf.cu Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CMakeLists.txt cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h cfe/trunk/test/CodeGenCUDA/Inputs/cuda.h Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=258642&r1=258641&r2=258642&view=diff == --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Sat Jan 23 15:28:14 2016 @@ -1963,6 +1963,9 @@ RValue CodeGenFunction::EmitBuiltinExpr( return RValue::get(llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy)); break; } + case Builtin::BIprintf: +if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) + return EmitCUDADevicePrintfCallExpr(E, ReturnValue); } // If this is an alias for a lib function (e.g. __builtin_sin), emit Added: cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp?rev=258642&view=auto == --- cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp (added) +++ cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp Sat Jan 23 15:28:14 2016 @@ -0,0 +1,131 @@ +//===- CGCUDABuiltin.cpp - Codegen for CUDA builtins --===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===--===// +// +// Generates code for built-in CUDA calls which are not runtime-specific. +// (Runtime-specific codegen lives in CGCUDARuntime.) +// +//===--===// + +#include "CodeGenFunction.h" +#include "clang/Basic/Builtins.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/IR/Instruction.h" +#include "llvm/Support/MathExtras.h" + +using namespace clang; +using namespace CodeGen; + +static llvm::Function *GetVprintfDeclaration(llvm::Module &M) { + llvm::Type *ArgTypes[] = {llvm::Type::getInt8PtrTy(M.getContext()), +llvm::Type::getInt8PtrTy(M.getContext())}; + llvm::FunctionType *VprintfFuncType = llvm::FunctionType::get( + llvm::Type::getInt32Ty(M.getContext()), ArgTypes, false); + + if (auto* F = M.getFunction("vprintf")) { +// Our CUDA system header declares vprintf with the right signature, so +// nobody else should have been able to declare vprintf with a bogus +// signature. +assert(F->getFunctionType() == VprintfFuncType); +return F; + } + + // vprintf doesn't already exist; create a declaration and insert it into the + // module. + return llvm::Function::Create( + VprintfFuncType, llvm::GlobalVariable::ExternalLinkage, "vprintf", &M); +} + +// Transforms a call to printf into a call to the NVPTX vprintf syscall (which +// isn't particularly special; it's invoked just like a regular function). +// vprintf takes two args: A format string, and a pointer to a buffer containing +// the varargs. +// +// For example, the call +// +// printf("format string", arg1, arg2, arg3); +// +// is converted into something resembling +// +// char* buf = alloca(...); +// *reinterpret_cast(buf) = arg1; +// *reinterpret_cast(buf + ...) = arg2; +// *reinterpret_cast(buf + ...) = arg3; +// vprintf("format string", buf); +// +// buf is aligned to the max of {alignof(Arg1), ...}. Furthermore, each of the +// args is itself aligned to its preferred alignment. +// +// Note that by the time this function runs, E's args have already undergone the +// standard C vararg promotion (short -> int, float -> double, etc.). +RValue +CodeGenFunction::EmitCUDADevicePrintfCallExpr(const CallExpr *E, + ReturnValueSlot ReturnValue) { + assert(getLangOpts().CUDA); + assert(getLangOpts().CUDAIsDevice); + assert(E->getBuiltinCallee() == Builtin::BIprintf); + assert(E->getNumArgs() >= 1); // printf always has at least one arg. + + const llvm::DataLayout &DL = CGM.getDataLayout(); + llvm::LLVMContext &Ctx = CGM.getLLVMContext(); + + CallArgLis
Re: [PATCH] D16372: [CUDA] Make printf work.
This revision was automatically updated to reflect the committed changes. Closed by commit rL258642: [CUDA] Make printf work. (authored by jlebar). Changed prior to commit: http://reviews.llvm.org/D16372?vs=45456&id=45810#toc Repository: rL LLVM http://reviews.llvm.org/D16372 Files: cfe/trunk/lib/CodeGen/CGBuiltin.cpp cfe/trunk/lib/CodeGen/CGCUDABuiltin.cpp cfe/trunk/lib/CodeGen/CMakeLists.txt cfe/trunk/lib/CodeGen/CodeGenFunction.h cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h cfe/trunk/test/CodeGenCUDA/Inputs/cuda.h cfe/trunk/test/CodeGenCUDA/printf.cu Index: cfe/trunk/test/CodeGenCUDA/printf.cu === --- cfe/trunk/test/CodeGenCUDA/printf.cu +++ cfe/trunk/test/CodeGenCUDA/printf.cu @@ -0,0 +1,53 @@ +// REQUIRES: x86-registered-target +// REQUIRES: nvptx-registered-target + +// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -emit-llvm \ +// RUN: -o - %s | FileCheck %s + +#include "Inputs/cuda.h" + +extern "C" __device__ int vprintf(const char*, const char*); + +// Check a simple call to printf end-to-end. +__device__ int CheckSimple() { + // CHECK: [[FMT:%[0-9]+]] = load{{.*}}%fmt + const char* fmt = "%d"; + // CHECK: [[BUF:%[a-zA-Z0-9_]+]] = alloca i8, i32 4, align 4 + // CHECK: [[PTR:%[0-9]+]] = getelementptr i8, i8* [[BUF]], i32 0 + // CHECK: [[CAST:%[0-9]+]] = bitcast i8* [[PTR]] to i32* + // CHECK: store i32 42, i32* [[CAST]], align 4 + // CHECK: [[RET:%[0-9]+]] = call i32 @vprintf(i8* [[FMT]], i8* [[BUF]]) + // CHECK: ret i32 [[RET]] + return printf(fmt, 42); +} + +// Check that the args' types are promoted correctly when we call printf. +__device__ void CheckTypes() { + // CHECK: alloca {{.*}} align 8 + // CHECK: getelementptr {{.*}} i32 0 + // CHECK: bitcast {{.*}} to i32* + // CHECK: getelementptr {{.*}} i32 4 + // CHECK: bitcast {{.*}} to i32* + // CHECK: getelementptr {{.*}} i32 8 + // CHECK: bitcast {{.*}} to double* + // CHECK: getelementptr {{.*}} i32 16 + // CHECK: bitcast {{.*}} to double* + printf("%d %d %f %f", (char)1, (short)2, 3.0f, 4.0); +} + +// Check that the args are aligned properly in the buffer. +__device__ void CheckAlign() { + // CHECK: alloca i8, i32 40, align 8 + // CHECK: getelementptr {{.*}} i32 0 + // CHECK: getelementptr {{.*}} i32 8 + // CHECK: getelementptr {{.*}} i32 16 + // CHECK: getelementptr {{.*}} i32 20 + // CHECK: getelementptr {{.*}} i32 24 + // CHECK: getelementptr {{.*}} i32 32 + printf("%d %f %d %d %d %lld", 1, 2.0, 3, 4, 5, (long long)6); +} + +__device__ void CheckNoArgs() { + // CHECK: call i32 @vprintf({{.*}}, i8* null){{$}} + printf("hello, world!"); +} Index: cfe/trunk/test/CodeGenCUDA/Inputs/cuda.h === --- cfe/trunk/test/CodeGenCUDA/Inputs/cuda.h +++ cfe/trunk/test/CodeGenCUDA/Inputs/cuda.h @@ -18,3 +18,5 @@ int cudaConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0, cudaStream_t stream = 0); + +extern "C" __device__ int printf(const char*, ...); Index: cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h === --- cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h +++ cfe/trunk/lib/Headers/__clang_cuda_runtime_wrapper.h @@ -210,6 +210,11 @@ static __device__ __attribute__((used)) int __nvvm_reflect_anchor() { return __nvvm_reflect("NONE"); } + +// The nvptx vprintf syscall. This doesn't actually need to be declared, but we +// declare it so that if someone else declares it with a different signature, +// we'll throw an error. +extern "C" __device__ int vprintf(const char*, const char*); #endif #endif // __CUDA__ Index: cfe/trunk/lib/CodeGen/CGBuiltin.cpp === --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp @@ -1963,6 +1963,9 @@ return RValue::get(llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy)); break; } + case Builtin::BIprintf: +if (getLangOpts().CUDA && getLangOpts().CUDAIsDevice) + return EmitCUDADevicePrintfCallExpr(E, ReturnValue); } // If this is an alias for a lib function (e.g. __builtin_sin), emit Index: cfe/trunk/lib/CodeGen/CodeGenFunction.h === --- cfe/trunk/lib/CodeGen/CodeGenFunction.h +++ cfe/trunk/lib/CodeGen/CodeGenFunction.h @@ -2711,6 +2711,8 @@ RValue EmitCUDAKernelCallExpr(const CUDAKernelCallExpr *E, ReturnValueSlot ReturnValue); + RValue EmitCUDADevicePrintfCallExpr(const CallExpr *E, + ReturnValueSlot ReturnValue); RValue EmitBuiltinExpr(const FunctionDecl *FD, unsigned BuiltinID, const CallExpr *E, Index: cfe/trunk/lib/CodeGen/CMakeLists.txt === --- cfe/
Re: [PATCH] D16438: Fix printing of types in initializers with suppressed tags.
nick.sumner added a comment. Thanks for your help! I don't have SVN commit access. http://reviews.llvm.org/D16438 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16308: clang-tidy Enhance readability-simplify-boolean-expr check to handle implicit conversions of integral types to bool and member pointers
LegalizeAdulthood updated this revision to Diff 45812. LegalizeAdulthood marked 2 inline comments as done. LegalizeAdulthood added a comment. Update from review comments. http://reviews.llvm.org/D16308 Files: clang-tidy/readability/SimplifyBooleanExprCheck.cpp clang-tidy/readability/SimplifyBooleanExprCheck.h docs/clang-tidy/checks/readability-simplify-boolean-expr.rst test/clang-tidy/readability-simplify-bool-expr.cpp Index: test/clang-tidy/readability-simplify-bool-expr.cpp === --- test/clang-tidy/readability-simplify-bool-expr.cpp +++ test/clang-tidy/readability-simplify-bool-expr.cpp @@ -690,7 +690,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(i & 1);{{$}} +// CHECK-FIXES: {{^}} return (i & 1) != 0;{{$}} bool negated_if_implicit_bool_expr(int i) { if (i - 1) { @@ -700,7 +700,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return !static_cast(i - 1);{{$}} +// CHECK-FIXES: {{^}} return (i - 1) == 0;{{$}} bool implicit_int(int i) { if (i) { @@ -710,7 +710,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(i);{{$}} +// CHECK-FIXES: {{^}} return i != 0;{{$}} bool explicit_bool(bool b) { if (b) { @@ -757,7 +757,7 @@ } } // CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return -// CHECK-FIXES: {{^}} return static_cast(~i);{{$}} +// CHECK-FIXES: {{^}} return ~i != 0;{{$}} bool logical_or(bool a, bool b) { if (a || b) { @@ -830,7 +830,7 @@ bool b = i ? true : false; } // CHECK-MESSAGES: :[[@LINE-2]]:16: warning: {{.*}} in ternary expression result -// CHECK-FIXES: bool b = static_cast(i);{{$}} +// CHECK-FIXES: bool b = i != 0;{{$}} bool non_null_pointer_condition(int *p1) { if (p1) { @@ -895,3 +895,38 @@ // CHECK-MESSAGES: :[[@LINE-6]]:12: warning: {{.*}} in conditional return // CHECK-FIXES: {{^}} if (b) { // CHECK-FIXES: {{^}}#define SOMETHING_WICKED false + +bool integer_not_zero(int i) { + if (i) { +return false; + } else { +return true; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: {{^}} return i == 0;{{$}} + +class A { +public: +int m; +}; + +bool member_pointer_nullptr(int A::*p) { + if (p) { +return true; + } else { +return false; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: return p != nullptr;{{$}} + +bool integer_member_implicit_cast(A *p) { + if (p->m) { +return true; + } else { +return false; + } +} +// CHECK-MESSAGES: :[[@LINE-5]]:12: warning: {{.*}} in conditional return +// CHECK-FIXES: return p->m != 0;{{$}} Index: docs/clang-tidy/checks/readability-simplify-boolean-expr.rst === --- docs/clang-tidy/checks/readability-simplify-boolean-expr.rst +++ docs/clang-tidy/checks/readability-simplify-boolean-expr.rst @@ -40,6 +40,8 @@ 5. Implicit casts to ``bool`` are replaced with explicit casts to ``bool``. 6. Object expressions with ``explicit operator bool`` conversion operators are replaced with explicit casts to ``bool``. + 7. Implicit conversions of integral types to ``bool`` are replaced with + explicit comparisons to ``0``. Examples: 1. The ternary assignment ``bool b = (i < 0) ? true : false;`` has redundant @@ -60,11 +62,11 @@ The ternary assignment ``bool b = (i & 1) ? true : false;`` has an implicit conversion of ``i & 1`` to ``bool`` and becomes - ``bool b = static_cast(i & 1);``. + ``bool b = i & 1 != 0;``. 5. The conditional return ``if (i & 1) return true; else return false;`` has an implicit conversion of an integer quantity ``i & 1`` to ``bool`` and - becomes ``return static_cast(i & 1);`` + becomes ``return i & 1 != 0;`` 6. Given ``struct X { explicit operator bool(); };``, and an instance ``x`` of ``struct X``, the conditional return ``if (x) return true; return false;`` Index: clang-tidy/readability/SimplifyBooleanExprCheck.h === --- clang-tidy/readability/SimplifyBooleanExprCheck.h +++ clang-tidy/readability/SimplifyBooleanExprCheck.h @@ -52,6 +52,8 @@ /// 5. Implicit casts to `bool` are replaced with explicit casts to `bool`. /// 6. Object expressions with `explicit operator bool` conversion operators /// are replaced with explicit casts to `bool`. +/// 7. Implicit conversions of integral types to `bool` are replaced with +/// explicit comparisons to `0`. /// /// Examples: /// 1. The ternary assignment `bool b = (i < 0) ? true : false;` has redundant @@ -72,11 +74,11 @@ /// /// The ternary assignment `bool b = (i & 1) ? true : false;` has an //
r258650 - Clang changes for value profiling
Author: betulb Date: Sat Jan 23 16:50:44 2016 New Revision: 258650 URL: http://llvm.org/viewvc/llvm-project?rev=258650&view=rev Log: Clang changes for value profiling Differential Revision: http://reviews.llvm.org/D8940 Added: cfe/trunk/test/Profile/c-indirect-call.c Modified: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CodeGenPGO.cpp cfe/trunk/lib/CodeGen/CodeGenPGO.h Modified: cfe/trunk/lib/CodeGen/CGCall.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=258650&r1=258649&r2=258650&view=diff == --- cfe/trunk/lib/CodeGen/CGCall.cpp (original) +++ cfe/trunk/lib/CodeGen/CGCall.cpp Sat Jan 23 16:50:44 2016 @@ -3539,6 +3539,11 @@ RValue CodeGenFunction::EmitCall(const C CS.setAttributes(Attrs); CS.setCallingConv(static_cast(CallingConv)); + // Insert instrumentation or attach profile metadata at indirect call sites + if (!CS.getCalledFunction()) +PGO.valueProfile(Builder, llvm::IPVK_IndirectCallTarget, + CS.getInstruction(), Callee); + // In ObjC ARC mode with no ObjC ARC exception safety, tell the ARC // optimizer it can aggressively ignore unwind edges. if (CGM.getLangOpts().ObjCAutoRefCount) Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.cpp?rev=258650&r1=258649&r2=258650&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp Sat Jan 23 16:50:44 2016 @@ -18,11 +18,14 @@ #include "clang/AST/StmtVisitor.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" -#include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/Endian.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MD5.h" +static llvm::cl::opt EnableValueProfiling( + "enable-value-profiling", llvm::cl::ZeroOrMore, + llvm::cl::desc("Enable value profiling"), llvm::cl::init(false)); + using namespace clang; using namespace CodeGen; @@ -740,12 +743,83 @@ void CodeGenPGO::emitCounterIncrement(CG Builder.getInt32(Counter)}); } +// This method either inserts a call to the profile run-time during +// instrumentation or puts profile data into metadata for PGO use. +void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, +llvm::Instruction *ValueSite, llvm::Value *ValuePtr) { + + if (!EnableValueProfiling) +return; + + if (!ValuePtr || !ValueSite || !Builder.GetInsertBlock()) +return; + + bool InstrumentValueSites = CGM.getCodeGenOpts().ProfileInstrGenerate; + if (InstrumentValueSites && RegionCounterMap) { +llvm::LLVMContext &Ctx = CGM.getLLVMContext(); +auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx); +llvm::Value *Args[5] = { +llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy), +Builder.getInt64(FunctionHash), +Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()), +Builder.getInt32(ValueKind), +Builder.getInt32(NumValueSites[ValueKind]++) +}; +Builder.CreateCall( +CGM.getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args); +return; + } + + llvm::IndexedInstrProfReader *PGOReader = CGM.getPGOReader(); + if (PGOReader && haveRegionCounts()) { +// We record the top most called three functions at each call site. +// Profile metadata contains "VP" string identifying this metadata +// as value profiling data, then a uint32_t value for the value profiling +// kind, a uint64_t value for the total number of times the call is +// executed, followed by the function hash and execution count (uint64_t) +// pairs for each function. +if (NumValueSites[ValueKind] >= ProfRecord->getNumValueSites(ValueKind)) + return; +uint32_t NV = ProfRecord->getNumValueDataForSite(ValueKind, + NumValueSites[ValueKind]); +std::unique_ptr VD = +ProfRecord->getValueForSite(ValueKind, NumValueSites[ValueKind]); + +uint64_t Sum = 0; +for (uint32_t I = 0; I < NV; ++I) + Sum += VD[I].Count; + +llvm::LLVMContext &Ctx = CGM.getLLVMContext(); +llvm::MDBuilder MDHelper(Ctx); +SmallVector Vals; +Vals.push_back(MDHelper.createString("VP")); +Vals.push_back(MDHelper.createConstant( +llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), ValueKind))); +Vals.push_back(MDHelper.createConstant( +llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), Sum))); + +uint32_t MDCount = 3; +for (uint32_t I = 0; I < NV; ++I) { + Vals.push_back(MDHelper.createConstant( + llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), VD[I].Value))); + Vals.push_back(MDHelper.createConstant( + llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), VD[I].Count))); + if (--MDCount ==
Re: [PATCH] D8940: Clang changes for indirect call target profiling
This revision was automatically updated to reflect the committed changes. Closed by commit rL258650: Clang changes for value profiling (authored by betulb). Changed prior to commit: http://reviews.llvm.org/D8940?vs=45550&id=45813#toc Repository: rL LLVM http://reviews.llvm.org/D8940 Files: cfe/trunk/lib/CodeGen/CGCall.cpp cfe/trunk/lib/CodeGen/CodeGenPGO.cpp cfe/trunk/lib/CodeGen/CodeGenPGO.h cfe/trunk/test/Profile/c-indirect-call.c Index: cfe/trunk/lib/CodeGen/CGCall.cpp === --- cfe/trunk/lib/CodeGen/CGCall.cpp +++ cfe/trunk/lib/CodeGen/CGCall.cpp @@ -3539,6 +3539,11 @@ CS.setAttributes(Attrs); CS.setCallingConv(static_cast(CallingConv)); + // Insert instrumentation or attach profile metadata at indirect call sites + if (!CS.getCalledFunction()) +PGO.valueProfile(Builder, llvm::IPVK_IndirectCallTarget, + CS.getInstruction(), Callee); + // In ObjC ARC mode with no ObjC ARC exception safety, tell the ARC // optimizer it can aggressively ignore unwind edges. if (CGM.getLangOpts().ObjCAutoRefCount) Index: cfe/trunk/lib/CodeGen/CodeGenPGO.cpp === --- cfe/trunk/lib/CodeGen/CodeGenPGO.cpp +++ cfe/trunk/lib/CodeGen/CodeGenPGO.cpp @@ -18,11 +18,14 @@ #include "clang/AST/StmtVisitor.h" #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" -#include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/Endian.h" #include "llvm/Support/FileSystem.h" #include "llvm/Support/MD5.h" +static llvm::cl::opt EnableValueProfiling( + "enable-value-profiling", llvm::cl::ZeroOrMore, + llvm::cl::desc("Enable value profiling"), llvm::cl::init(false)); + using namespace clang; using namespace CodeGen; @@ -740,21 +743,95 @@ Builder.getInt32(Counter)}); } +// This method either inserts a call to the profile run-time during +// instrumentation or puts profile data into metadata for PGO use. +void CodeGenPGO::valueProfile(CGBuilderTy &Builder, uint32_t ValueKind, +llvm::Instruction *ValueSite, llvm::Value *ValuePtr) { + + if (!EnableValueProfiling) +return; + + if (!ValuePtr || !ValueSite || !Builder.GetInsertBlock()) +return; + + bool InstrumentValueSites = CGM.getCodeGenOpts().ProfileInstrGenerate; + if (InstrumentValueSites && RegionCounterMap) { +llvm::LLVMContext &Ctx = CGM.getLLVMContext(); +auto *I8PtrTy = llvm::Type::getInt8PtrTy(Ctx); +llvm::Value *Args[5] = { +llvm::ConstantExpr::getBitCast(FuncNameVar, I8PtrTy), +Builder.getInt64(FunctionHash), +Builder.CreatePtrToInt(ValuePtr, Builder.getInt64Ty()), +Builder.getInt32(ValueKind), +Builder.getInt32(NumValueSites[ValueKind]++) +}; +Builder.CreateCall( +CGM.getIntrinsic(llvm::Intrinsic::instrprof_value_profile), Args); +return; + } + + llvm::IndexedInstrProfReader *PGOReader = CGM.getPGOReader(); + if (PGOReader && haveRegionCounts()) { +// We record the top most called three functions at each call site. +// Profile metadata contains "VP" string identifying this metadata +// as value profiling data, then a uint32_t value for the value profiling +// kind, a uint64_t value for the total number of times the call is +// executed, followed by the function hash and execution count (uint64_t) +// pairs for each function. +if (NumValueSites[ValueKind] >= ProfRecord->getNumValueSites(ValueKind)) + return; +uint32_t NV = ProfRecord->getNumValueDataForSite(ValueKind, + NumValueSites[ValueKind]); +std::unique_ptr VD = +ProfRecord->getValueForSite(ValueKind, NumValueSites[ValueKind]); + +uint64_t Sum = 0; +for (uint32_t I = 0; I < NV; ++I) + Sum += VD[I].Count; + +llvm::LLVMContext &Ctx = CGM.getLLVMContext(); +llvm::MDBuilder MDHelper(Ctx); +SmallVector Vals; +Vals.push_back(MDHelper.createString("VP")); +Vals.push_back(MDHelper.createConstant( +llvm::ConstantInt::get(llvm::Type::getInt32Ty(Ctx), ValueKind))); +Vals.push_back(MDHelper.createConstant( +llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), Sum))); + +uint32_t MDCount = 3; +for (uint32_t I = 0; I < NV; ++I) { + Vals.push_back(MDHelper.createConstant( + llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), VD[I].Value))); + Vals.push_back(MDHelper.createConstant( + llvm::ConstantInt::get(llvm::Type::getInt64Ty(Ctx), VD[I].Count))); + if (--MDCount == 0) +break; +} +ValueSite->setMetadata( +llvm::LLVMContext::MD_prof, llvm::MDNode::get(Ctx, Vals)); +NumValueSites[ValueKind]++; + } +} + void CodeGenPGO::loadRegionCounts(llvm::IndexedInstrProfReader *PGOReader, bool IsInMainFile) { CGM.getPGOStats().addVisited(IsInMainFile); RegionCounts.clear(
Re: [PATCH] D8940: Clang changes for indirect call target profiling
betulb added a comment. Committed in revision 258650. Repository: rL LLVM http://reviews.llvm.org/D8940 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r257947 - Avoid self-assignment of SmallString, trigger UB behavior down the road.
On Sat, Jan 16, 2016 at 03:51:11PM +0100, Joerg Sonnenberger via cfe-commits wrote: > Hello Richard, > can this be merged into 3.8? It creates some trivial noise under > valgrind. Ping? Joerg ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r258652 - [PGO] Windows buildbot failure fix. [NFC]
Author: betulb Date: Sat Jan 23 18:56:19 2016 New Revision: 258652 URL: http://llvm.org/viewvc/llvm-project?rev=258652&view=rev Log: [PGO] Windows buildbot failure fix. [NFC] Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h Modified: cfe/trunk/lib/CodeGen/CodeGenPGO.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenPGO.h?rev=258652&r1=258651&r2=258652&view=diff == --- cfe/trunk/lib/CodeGen/CodeGenPGO.h (original) +++ cfe/trunk/lib/CodeGen/CodeGenPGO.h Sat Jan 23 18:56:19 2016 @@ -21,6 +21,7 @@ #include "llvm/ADT/StringMap.h" #include "llvm/ProfileData/InstrProfReader.h" #include "llvm/Support/MemoryBuffer.h" +#include #include namespace clang { @@ -33,7 +34,7 @@ private: std::string FuncName; llvm::GlobalVariable *FuncNameVar; - unsigned NumValueSites[llvm::IPVK_Last + 1]; + std::array NumValueSites; unsigned NumRegionCounters; uint64_t FunctionHash; std::unique_ptr> RegionCounterMap; @@ -47,7 +48,7 @@ private: public: CodeGenPGO(CodeGenModule &CGM) - : CGM(CGM), NumValueSites{0}, NumRegionCounters(0), + : CGM(CGM), NumValueSites({{0}}), NumRegionCounters(0), FunctionHash(0), CurrentRegionCount(0), SkipCoverageMapping(false) {} /// Whether or not we have PGO region data for the current function. This is ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D8940: Clang changes for indirect call target profiling
ovyalov added a subscriber: ovyalov. ovyalov added a comment. It seems this CL is causing Window build to fail - http://lab.llvm.org:8011/builders/lldb-windows7-android/builds/3885 Could you take a look? Repository: rL LLVM http://reviews.llvm.org/D8940 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16259: Add clang-tidy readability-redundant-return check
LegalizeAdulthood marked 8 inline comments as done. Comment at: clang-tidy/readability/RedundantReturnCheck.cpp:24 @@ +23,3 @@ + functionDecl(isDefinition(), returns(asString("void")), + has(compoundStmt(hasAnySubstatement(returnStmt() + .bind("fn"), aaron.ballman wrote: > LegalizeAdulthood wrote: > > aaron.ballman wrote: > > > Would be best to restrict this to a return statement that has no > > > expression if we don't want to diagnose this: > > > ``` > > > void g(); > > > > > > void f() { > > > return g(); > > > } > > > ``` > > > Either way, it would be good to have a test that ensures this isn't > > > mangled. > > How about transforming this odd looking duck into > > > > ``` > > void g(); > > > > void f() { > > g(); > > } > > ``` > > > > ? > I think in the context of this check, that would be fine. For now I have opted to simply ignore such odd ducks. Comment at: test/clang-tidy/readability-redundant-return.cpp:1 @@ +1,2 @@ +// RUN: %check_clang_tidy %s readability-redundant-return %t + alexfh wrote: > Please add tests with macros and templates that ensure: > * no replacements in macro bodies > * correct replacements in macro arguments (that are not inside another > macro's body) > * replacements in template bodies with multiple instantiations are applied > only once (adding `unless(isInTemplateInstantiation())` filter to the matcher > is a usual way to handle this). When I added template test cases, I wasn't sure how to write a test case for what you requested. I wrote test code that multiply instantiated a template and only see my check triggering on the template body as written in the code. http://reviews.llvm.org/D16259 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [PATCH] D16259: Add clang-tidy readability-redundant-control-flow check
LegalizeAdulthood retitled this revision from "Add clang-tidy readability-redundant-return check" to "Add clang-tidy readability-redundant-control-flow check". LegalizeAdulthood updated this revision to Diff 45814. LegalizeAdulthood marked an inline comment as done. LegalizeAdulthood added a comment. Update from review comments http://reviews.llvm.org/D16259 Files: clang-tidy/readability/CMakeLists.txt clang-tidy/readability/ReadabilityTidyModule.cpp clang-tidy/readability/RedundantControlFlowCheck.cpp clang-tidy/readability/RedundantControlFlowCheck.h docs/clang-tidy/checks/list.rst docs/clang-tidy/checks/readability-redundant-control-flow.rst test/clang-tidy/readability-redundant-control-flow.cpp Index: test/clang-tidy/readability-redundant-control-flow.cpp === --- /dev/null +++ test/clang-tidy/readability-redundant-control-flow.cpp @@ -0,0 +1,222 @@ +// RUN: %check_clang_tidy %s readability-redundant-control-flow %t + +void g(int i); +void j(); + +void f() { + return; +} +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement at the end of void function [readability-redundant-control-flow] +// CHECK-FIXES: {{^}}void f() {{{$}} +// CHECK-FIXES-NEXT: {{^ *}$}} + +void g() { + f(); + return; +} +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement +// CHECK-FIXES: {{^ }}f();{{$}} +// CHECK-FIXES-NEXT: {{^ *}$}} + +void g(int i) { + if (i < 0) { +return; + } + if (i < 10) { +f(); + } +} + +int h() { + return 1; +} + +void j() { +} + +void k() { + for (int i = 0; i < 10; ++i) { +continue; + } +} +// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement at the end of loop statement +// CHECK-FIXES: {{^}} for (int i = 0; i < 10; ++i) {{{$}} +// CHECK-FIXES-NEXT: {{^ *}$}} + +void k2() { + int v[10] = { 0 }; + for (auto i : v) { +continue; + } +} +// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement +// CHECK-FIXES: {{^}} for (auto i : v) {{{$}} +// CHECK-FIXES-NEXT: {{^ *}$}} + +void m() { + int i = 0; + do { +++i; +continue; + } while (i < 10); +} +// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement +// CHECK-FIXES: {{^ do {$}} +// CHECK-FIXES-NEXT: {{^}}++i;{{$}} +// CHECK-FIXES-NEXT: {{^ *}}} while (i < 10);{{$}} + +void p() { + int i = 0; + while (i < 10) { +++i; +continue; + } +} +// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement +// CHECK-FIXES: {{^}} while (i < 10) {{{$}} +// CHECK-FIXES-NEXT: {{^}}++i;{{$}} +// CHECK-FIXES-NEXT: {{^ *}$}} + +void im_not_dead(int i) { + if (i > 0) { +return; + } + g(); +} + +void im_still_not_dead(int i) { + for (int j = 0; j < 10; ++j) { +if (i < 10) { + continue; +} +g(); + } +} + +void im_dead(int i) { + if (i > 0) { +return; +g(); + } + g(); +} + +void im_still_dead(int i) { + for (int j = 0; j < 10; ++j) { +if (i < 10) { + continue; + g(); +} +g(); + } +} + +void void_return() { + return g(); +} + +void nested_return_unmolested() { + g(); + { +g(); +return; + } +} + +void nested_continue_unmolested() { + for (int i = 0; i < 10; ++i) { +if (i < 5) { + continue; +} + } +} + +#define MACRO_RETURN_UNMOLESTED(fn_) \ + (fn_)();\ + return + +#define MACRO_CONTINUE_UNMOLESTED(x_) \ + do {\ +for (int i = 0; i < (x_); ++i) { \ + continue; \ +} \ + } while (false) + +void macro_return() { + MACRO_RETURN_UNMOLESTED(g); +} + +void macro_continue() { + MACRO_CONTINUE_UNMOLESTED(10); +} + +#define MACRO_RETURN_ARG(stmt_) \ + stmt_ + +#define MACRO_CONTINUE_ARG(stmt_) \ + do { \ +for (int i = 0; i < 10; ++i) { \ + stmt_;\ +} \ + } while (false) + +void macro_arg_return() { + MACRO_RETURN_ARG(return); +} + +void macro_arg_continue() { + MACRO_CONTINUE_ARG(continue); +} + +template +void template_return(T check) { + if (check < T(0)) { +return; + } + return; +} +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement +// CHECK-FIXES: {{^}} if (check < T(0)) {{{$}} +// CHECK-FIXES-NEXT: {{^return;$}} +// CHECK-FIXES-NEXT: {{^ *}$}} + +template <> +void template_return(int check) { + if (check < 0) { +return; + } + return; +} +// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: redundant return statement +// CHECK-FIXES: {{^}} if (check < 0) {{{$}} +// CHECK-FIXES-NEXT: {{^return;$}} +// CHECK-FIXES-NEXT: {{^ *}$}} + +template +void template_loop(T end) { + for (T i = 0; i < end; ++i) { +continue; + } +} +// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: redundant continue statement +// CHECK-FIXES: {{^}} for (T i = 0; i < end; ++i) {{{$}} +// CHECK-FIXES-NEXT: {{^ *}$}} +
RE: [PATCH] D8940: Clang changes for indirect call target profiling
http://reviews.llvm.org/rL258652 should fix the issue. Please let me know if you continue to see failures. -Betul -Original Message- From: Oleksiy Vyalov [mailto:ovya...@google.com] Sent: Saturday, January 23, 2016 5:10 PM To: bet...@codeaurora.org; m...@justinbogner.com; dnovi...@google.com; x...@google.com; davi...@google.com Cc: ovya...@google.com; v...@apple.com; ib...@codeaurora.org; cfe-commits@lists.llvm.org Subject: Re: [PATCH] D8940: Clang changes for indirect call target profiling ovyalov added a subscriber: ovyalov. ovyalov added a comment. It seems this CL is causing Window build to fail - http://lab.llvm.org:8011/builders/lldb-windows7-android/builds/3885 Could you take a look? Repository: rL LLVM http://reviews.llvm.org/D8940 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits