yaxunl added a comment. In D76937#1950077 <https://reviews.llvm.org/D76937#1950077>, @rjmccall wrote:
> Can you explain what exactly the emission/semantic model is for variables? > Normal code-generation absolutely triggers the emission of many variables > lazily (e.g. internal-linkage globals, C++ inline variables); and any > variable that's *not* being emitted lazily actually needs to be treated as a > potential root into the delayed-diagnostic graph. Currently only in the following case a global variable can change the emission state of a function: int foobar3() { return 1; } #pragma omp declare target int (*C)() = &foobar3; #pragma omp end declare target The global variable needs to be in a omp declare target directive. Its initializer references a host function. This will cause the function emitted in device compilation. This is not transitive for variable declaration/references, e.g. the following case will not cause foobar3 to be emitted in device compilation, unless variable C itself is enclosed in omp declare target directive. int foobar3() { return 1; } int (*C)() = &foobar3; #pragma omp declare target int (*D)() = C; #pragma omp end declare target Since we logged all such variable declarations in DeclsToCheckForDeferredDiags, we only need to check variables decls in DeclsToCheckForDeferredDiags and do not need to check variable decls in DeclRefExpr. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76937/new/ https://reviews.llvm.org/D76937 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits