Author: Alexey Bataev Date: 2020-08-19T16:14:33-04:00 New Revision: fb4acd37fe60a08a0077560d2814053d76ea1c41
URL: https://github.com/llvm/llvm-project/commit/fb4acd37fe60a08a0077560d2814053d76ea1c41 DIFF: https://github.com/llvm/llvm-project/commit/fb4acd37fe60a08a0077560d2814053d76ea1c41.diff LOG: [OPENMP]Fix PR47158, case 2: do not report host-only functions in unused function in device mode. If the function is not marked exlicitly as declare target and it calls function(s), marked as declare target device_type(host), these host-only functions should not be dignosed as used in device mode, if the caller function is not used in device mode too. Differential Revision: https://reviews.llvm.org/D86164 Added: Modified: clang/lib/Sema/Sema.cpp clang/test/OpenMP/declare_target_messages.cpp Removed: ################################################################################ diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index b9d655bab1b0..47484c5be9c9 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/lib/Sema/Sema.cpp @@ -1551,7 +1551,8 @@ class DeferredDiagnosticsEmitter S.shouldIgnoreInHostDeviceCheck(FD) || InUsePath.count(FD)) return; // Finalize analysis of OpenMP-specific constructs. - if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1) + if (Caller && S.LangOpts.OpenMP && UsePath.size() == 1 && + (ShouldEmitRootNode || InOMPDeviceContext)) S.finalizeOpenMPDelayedAnalysis(Caller, FD, Loc); if (Caller) S.DeviceKnownEmittedFns[FD] = {Caller, Loc}; diff --git a/clang/test/OpenMP/declare_target_messages.cpp b/clang/test/OpenMP/declare_target_messages.cpp index 3a78e492af58..7287a6682f0b 100644 --- a/clang/test/OpenMP/declare_target_messages.cpp +++ b/clang/test/OpenMP/declare_target_messages.cpp @@ -167,7 +167,7 @@ void bazzz() {bazz();} #pragma omp declare target to(bazzz) device_type(nohost) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} void any() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}} void host1() {bazz();} // host5-error {{function with 'device_type(nohost)' is not available on host}} -#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 4 {{marked as 'device_type(host)' here}} +#pragma omp declare target to(host1) device_type(host) // omp45-error {{unexpected 'device_type' clause, only 'to' or 'link' clauses expected}} dev5-note 3 {{marked as 'device_type(host)' here}} void host2() {bazz();} //host5-error {{function with 'device_type(nohost)' is not available on host}} #pragma omp declare target to(host2) void device() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}} @@ -183,7 +183,7 @@ void any4() {any2();} #pragma omp end declare target void any5() {any();} -void any6() {host1();} // dev5-error {{function with 'device_type(host)' is not available on device}} +void any6() {host1();} void any7() {device();} // host5-error {{function with 'device_type(nohost)' is not available on host}} void any8() {any2();} _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits