[PATCH] D111124: [Clang][OpenMP] Allow loop-transformations with template parameters.

Michael Kruse via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 5 00:37:32 PDT 2021


Meinersbur created this revision.
Meinersbur added reviewers: ABataev, jdenny.
Meinersbur added projects: OpenMP, clang.
Herald added subscribers: zzheng, guansong, yaxunl.
Meinersbur requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added a subscriber: sstefan1.

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 nullptr (until the template is instantiated). 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 later 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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D111124

Files:
  clang/include/clang/AST/StmtOpenMP.h
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/OpenMP/tile_ast_print.cpp
  clang/test/OpenMP/unroll_ast_print.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111124.377101.patch
Type: text/x-patch
Size: 8728 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211005/bae1c757/attachment-0001.bin>


More information about the cfe-commits mailing list