RE: [clang] b670ab7 - recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese
[AMD Official Use Only - Internal Distribution Only] commit 2c31aa2de13a23a00ced87123b92e905f2929c7b should fix this. Thanks. Sam -Original Message- From: Liu, Yaxun (Sam) Sent: Sunday, April 5, 2020 12:20 PM To: Joerg Sonnenberger ; Yaxun Liu Cc: cfe-commits@lists.llvm.org Subject: RE: [clang] b670ab7 - recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese [AMD Official Use Only - Internal Distribution Only] The issue is addressed by https://reviews.llvm.org/D77028 Sam -Original Message- From: Joerg Sonnenberger Sent: Sunday, April 5, 2020 9:48 AM To: Liu, Yaxun (Sam) ; Yaxun Liu Cc: cfe-commits@lists.llvm.org Subject: Re: [clang] b670ab7 - recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese [CAUTION: External Email] On Mon, Mar 23, 2020 at 09:09:31AM -0700, Yaxun Liu via cfe-commits wrote: > > Author: Yaxun (Sam) Liu > Date: 2020-03-23T12:09:07-04:00 > New Revision: b670ab7b6b3d2f26179213be1da1d4ba376f50a3 > > URL: > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith > ub.com%2Fllvm%2Fllvm-project%2Fcommit%2Fb670ab7b6b3d2f26179213be1da1d4 > ba376f50a3data=02%7C01%7Cyaxun.liu%40amd.com%7Cfc099ddf95594ab17e > da08d7d968004e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6372169134 > 68808969sdata=WtAm5JbQgR7UDY0FL5AlIvZOSOLPbQTRbKHJvP0Vot8%3D > reserved=0 > DIFF: > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith > ub.com%2Fllvm%2Fllvm-project%2Fcommit%2Fb670ab7b6b3d2f26179213be1da1d4 > ba376f50a3.diffdata=02%7C01%7Cyaxun.liu%40amd.com%7Cfc099ddf95594 > ab17eda08d7d968004e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63721 > 6913468808969sdata=wREjtZ%2F5SHC1U4dxGbbSvYYncnhqa%2ByJzHBxv%2FIh > PlY%3Dreserved=0 > > LOG: recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred > diagnostics by a post-parsing AST travese This change is responsible for a significant performance regression. Somewhat reduced example is attached. With -fopenmp, it needs ~5s, without 0.02s. Joerg ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
RE: [clang] b670ab7 - recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese
[AMD Official Use Only - Internal Distribution Only] The issue is addressed by https://reviews.llvm.org/D77028 Sam -Original Message- From: Joerg Sonnenberger Sent: Sunday, April 5, 2020 9:48 AM To: Liu, Yaxun (Sam) ; Yaxun Liu Cc: cfe-commits@lists.llvm.org Subject: Re: [clang] b670ab7 - recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese [CAUTION: External Email] On Mon, Mar 23, 2020 at 09:09:31AM -0700, Yaxun Liu via cfe-commits wrote: > > Author: Yaxun (Sam) Liu > Date: 2020-03-23T12:09:07-04:00 > New Revision: b670ab7b6b3d2f26179213be1da1d4ba376f50a3 > > URL: > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith > ub.com%2Fllvm%2Fllvm-project%2Fcommit%2Fb670ab7b6b3d2f26179213be1da1d4 > ba376f50a3data=02%7C01%7Cyaxun.liu%40amd.com%7Cfc099ddf95594ab17e > da08d7d968004e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C6372169134 > 68808969sdata=WtAm5JbQgR7UDY0FL5AlIvZOSOLPbQTRbKHJvP0Vot8%3D > reserved=0 > DIFF: > https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgith > ub.com%2Fllvm%2Fllvm-project%2Fcommit%2Fb670ab7b6b3d2f26179213be1da1d4 > ba376f50a3.diffdata=02%7C01%7Cyaxun.liu%40amd.com%7Cfc099ddf95594 > ab17eda08d7d968004e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C63721 > 6913468808969sdata=wREjtZ%2F5SHC1U4dxGbbSvYYncnhqa%2ByJzHBxv%2FIh > PlY%3Dreserved=0 > > LOG: recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred > diagnostics by a post-parsing AST travese This change is responsible for a significant performance regression. Somewhat reduced example is attached. With -fopenmp, it needs ~5s, without 0.02s. Joerg ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: [clang] b670ab7 - recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese
On Mon, Mar 23, 2020 at 09:09:31AM -0700, Yaxun Liu via cfe-commits wrote: > > Author: Yaxun (Sam) Liu > Date: 2020-03-23T12:09:07-04:00 > New Revision: b670ab7b6b3d2f26179213be1da1d4ba376f50a3 > > URL: > https://github.com/llvm/llvm-project/commit/b670ab7b6b3d2f26179213be1da1d4ba376f50a3 > DIFF: > https://github.com/llvm/llvm-project/commit/b670ab7b6b3d2f26179213be1da1d4ba376f50a3.diff > > LOG: recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a > post-parsing AST travese This change is responsible for a significant performance regression. Somewhat reduced example is attached. With -fopenmp, it needs ~5s, without 0.02s. Joerg ; ; namespace std { inline namespace __1 { template struct char_traits; template class basic_ostream; typedef basic_ostream ostream; template basic_ostream<_Traits>& operator<<(basic_ostream<_Traits>& __os, const char* __str) ; extern ostream cerr; } ; } template class flet { public: flet(T , const T ) ; }; ; template class _scoped_numeral { typedef typename Manager::numeral numeral; public: _scoped_numeral(Manager ) ; operator numeral&() ; }; template class buffer { public: ; unsigned size() const ; ; ; T & operator[](unsigned idxT ) ; }; template class buffer ; template class sbuffer : public buffer { }; class mpz { public: mpz(int v) ; }; template class mpz_manager { public: ; typedef mpz numeral; void mul2k(mpz , unsigned k, mpz r) ; }; typedef mpz_manager unsynch_mpz_manager; typedef _scoped_numeral scoped_mpz; class mpq { }; template class mpq_manager : public mpz_manager { public: typedef mpq numeral; bool is_zero; void mul( mpq b, mpq ) ; void set(mpq , mpq source) ; }; typedef mpq_manager unsynch_mpq_manager; typedef _scoped_numeral scoped_mpq; ; template class interval_manager { public: ; typedef typename C::interval interval; bool is_P(interval n) const ; void set(interval , interval s); void neg(interval a, interval ); void add(interval a, interval b, interval ); void mul(interval a, interval b, interval ); }; template class _scoped_interval { typedef typename Manager::interval interval; public: _scoped_interval(Manager ) ; operator interval&() ; }; namespace realclosure { class num; ; class manager { struct imp; typedef num numeral; }; struct value; class num { friend class
[clang] b670ab7 - recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese
Author: Yaxun (Sam) Liu Date: 2020-03-23T12:09:07-04:00 New Revision: b670ab7b6b3d2f26179213be1da1d4ba376f50a3 URL: https://github.com/llvm/llvm-project/commit/b670ab7b6b3d2f26179213be1da1d4ba376f50a3 DIFF: https://github.com/llvm/llvm-project/commit/b670ab7b6b3d2f26179213be1da1d4ba376f50a3.diff LOG: recommit 1b978ddba05c [CUDA][HIP][OpenMP] Emit deferred diagnostics by a post-parsing AST travese Differential Revision: https://reviews.llvm.org/D70172 Added: Modified: clang/include/clang/Sema/ExternalSemaSource.h clang/include/clang/Sema/MultiplexExternalSemaSource.h clang/include/clang/Sema/Sema.h clang/include/clang/Serialization/ASTBitCodes.h clang/include/clang/Serialization/ASTReader.h clang/lib/Sema/MultiplexExternalSemaSource.cpp clang/lib/Sema/Sema.cpp clang/lib/Sema/SemaCUDA.cpp clang/lib/Sema/SemaDecl.cpp clang/lib/Sema/SemaExpr.cpp clang/lib/Sema/SemaOpenMP.cpp clang/lib/Sema/UsedDeclVisitor.h clang/lib/Serialization/ASTReader.cpp clang/lib/Serialization/ASTWriter.cpp clang/test/OpenMP/declare_target_messages.cpp clang/test/OpenMP/nvptx_target_exceptions_messages.cpp clang/test/SemaCUDA/bad-calls-on-same-line.cu clang/test/SemaCUDA/call-device-fn-from-host.cu clang/test/SemaCUDA/call-host-fn-from-device.cu clang/test/SemaCUDA/openmp-target.cu clang/test/SemaCUDA/trace-through-global.cu Removed: diff --git a/clang/include/clang/Sema/ExternalSemaSource.h b/clang/include/clang/Sema/ExternalSemaSource.h index c79ca0e71df5..2854b4893484 100644 --- a/clang/include/clang/Sema/ExternalSemaSource.h +++ b/clang/include/clang/Sema/ExternalSemaSource.h @@ -193,6 +193,15 @@ class ExternalSemaSource : public ExternalASTSource { llvm::MapVector> ) {} + /// Read the set of decls to be checked for deferred diags. + /// + /// The external source should append its own potentially emitted function + /// and variable decls which may cause deferred diags. Note that this routine + /// may be invoked multiple times; the external source should take care not to + /// introduce the same declarations repeatedly. + virtual void ReadDeclsToCheckForDeferredDiags( + llvm::SmallVector ) {} + /// \copydoc Sema::CorrectTypo /// \note LookupKind must correspond to a valid Sema::LookupNameKind /// diff --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h b/clang/include/clang/Sema/MultiplexExternalSemaSource.h index dcbac9f0ba10..e94dd5d46871 100644 --- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h +++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h @@ -332,6 +332,15 @@ class MultiplexExternalSemaSource : public ExternalSemaSource { llvm::MapVector> ) override; + /// Read the set of decls to be checked for deferred diags. + /// + /// The external source should append its own potentially emitted function + /// and variable decls which may cause deferred diags. Note that this routine + /// may be invoked multiple times; the external source should take care not to + /// introduce the same declarations repeatedly. + void ReadDeclsToCheckForDeferredDiags( + llvm::SmallVector ) override; + /// \copydoc ExternalSemaSource::CorrectTypo /// \note Returns the first nonempty correction. TypoCorrection CorrectTypo(const DeclarationNameInfo , diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h index b2c849f7e1b8..03f3a1b4bdc9 100644 --- a/clang/include/clang/Sema/Sema.h +++ b/clang/include/clang/Sema/Sema.h @@ -1492,6 +1492,18 @@ class Sema final { void emitAndClearUnusedLocalTypedefWarnings(); + private: +/// Function or variable declarations to be checked for whether the deferred +/// diagnostics should be emitted. +SmallVector DeclsToCheckForDeferredDiags; + + public: + // Emit all deferred diagnostics. + void emitDeferredDiags(); + // Emit any deferred diagnostics for FD and erase them from the map in which + // they're stored. + void emitDeferredDiags(FunctionDecl *FD, bool ShowCallStack); + enum TUFragmentKind { /// The global module fragment, between 'module;' and a module-declaration. Global, @@ -3767,7 +3779,8 @@ class Sema final { TemplateDiscarded, // Discarded due to uninstantiated templates Unknown, }; - FunctionEmissionStatus getEmissionStatus(FunctionDecl *Decl); + FunctionEmissionStatus getEmissionStatus(FunctionDecl *Decl, + bool Final = false); // Whether the callee should be ignored in CUDA/HIP/OpenMP host/device check. bool shouldIgnoreInHostDeviceCheck(FunctionDecl *Callee); @@ -9767,22 +9780,10 @@ class Sema final { /// Pop OpenMP function region for non-capturing function. void popOpenMPFunctionRegion(const sema::FunctionScopeInfo *OldFSI); - /// Check whether we're allowed to