[Clang][OpenMP] Allow loop-transformations with template parameters.
Clang would reject #pragma omp for #pragma omp tile sizes(P) for (int i = 0; i < 128; ++i) {} where P is a template parameter, but the loop itself is not template-dependent. Because P context-dependent, the TransformedStmt cannot be generated and therefore is nullptr (until the template is instantiated by TreeTransform). The OMPForDirective would still expect the a loop is the dependent context and trigger an error. Fix by introducing a NumGeneratedLoops field to OMPLoopTransformation. This is used to distinguish the case where no TransformedStmt will be generated at all (e.g. #pragma omp unroll full) and template instantiation is needed. In the latter case, delay resolving the iteration space like when the for-loop itself is template-dependent until the template instatiation. A more radical solution would always delay the iteration space analysis until template instantiation, but would also break many test cases. Reviewed By: ABataev Differential Revision: https://reviews.llvm.org/D111124
Loading
Please sign in to comment