This patch adds parse and sema support for iterator map modifier.
Details
Diff Detail
Unit Tests
Event Timeline
clang/include/clang/AST/OpenMPClause.h | ||
---|---|---|
5780 | We're using tail allocation for such objects. |
clang/include/clang/AST/OpenMPClause.h | ||
---|---|---|
5866–5867 | Can we use just a nullptr as a mark that there is no associated iterator? | |
clang/include/clang/Parse/Parser.h | ||
3474–3475 ↗ | (On Diff #489917) | Where is it defined, cannot find it in the patch? |
clang/lib/Sema/SemaOpenMP.cpp | ||
1166–1168 | Do you really need to store the variable in the stack, is not it enough just to check that the type of this variable is BuiltinType::OMPIterator? | |
clang/test/OpenMP/target_map_messages.cpp | ||
256–257 | Cases with incorrect parsing, wrong variables etc.? |
clang/include/clang/Parse/Parser.h | ||
---|---|---|
3474–3475 ↗ | (On Diff #489917) | Leftover, removed it. |
clang/lib/Sema/SemaOpenMP.cpp | ||
1166–1168 | I'm happy to replace this if you think it will work. Is there an example somewhere in the code where I can get from the VarDecl to the build in type you mention? |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | You have already a check IteratorModifier->getType()->isSpecificBuiltinType(BuiltinType::OMPIterator), you can you something similar for the variable |
clang/test/OpenMP/target_map_messages.cpp | ||
---|---|---|
970–979 | You mean as part of the iterator ? like iterator(it = 0:UndefVar) ? |
clang/test/OpenMP/target_map_messages.cpp | ||
---|---|---|
970–979 | I mean, you have a check that in mappers only iterator vars are allowed. Can you add a check for this? |
clang/test/OpenMP/target_map_messages.cpp | ||
---|---|---|
970–979 | As far as I understand it the additional check I added to the existing mapper checks is needed because of the way the mapper check was written. The mapper checks looks at declarations and if a mapper clause exists then it assumes that the declaration must be coming from that mapper clause. This used to hold in the past since that was the only way you could have a declaration. This is not true anymore since we can now have declarations coming from both the mapper and the iterator modifier. I'll add a test to showcase this. |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | This didn't work and I had to revert to using the stack! |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | Why? |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | I checked the output of the check and it was false when it should have been true! If you check the latest test that I added it showcases the source code and in the case of OpenMP 5.2 you can see that the message "only variable 'vvec' is allowed in map clauses of this 'omp declare mapper' directive" doesn't appear when a legal iteration variable is used. |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | Did not get it. It still shall be of type builtintype::OMPIterator. |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | I am not sure how I can force it to have that type when it just doesn't. Do you have any suggestions? |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | The VD that we are checking for this builtin is coming from somewhere else in the code, it is passed into the Sema::DiagnoseUseOfDecl( function. It's not a VarDecl that is under the control of anything added in this patch. |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | This implementation is in line with the current checks for the declaration of the mapper variable. You store the declaration onto the stack so that you can compare it with the incoming VarDecl passed to the diagnose function. |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
1166–1168 | Some debug printouts regarding VD:
VarDecl 0x55b57f81dec8 <test_declare_mapper_iterator.c:26:52> col:52 implicit used it 'int' This is the type of the variable if you do VD->getType()->dump(): BuiltinType 0x55b57f6d2560 'int' |
clang/lib/Sema/SemaOpenMP.cpp | ||
---|---|---|
22400–22413 | This input to this function is the VD variable I've been talking about. If you print it all out it's just a simple VarDecl: if you do VD->dump(); VarDecl 0x55b57f81dec8 <test_declare_mapper_iterator.c:26:52> col:52 implicit used it 'int' if you do VD->getType()->dump(): BuiltinType 0x55b57f6d2560 'int' |
Can you add positive test for declare mapper?
clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
5423–5426 | Can we register this variable only in declare mapper context, i.e. add a check that we add it only for declare mapper? |
clang/test/OpenMP/declare_mapper_messages.c | ||
---|---|---|
33–36 | Here we have both the positive and the negative declare mapper cases. Please let me know if you meant something different. |
clang/lib/Sema/SemaExpr.cpp | ||
---|---|---|
5423–5426 | Happy to do that! |
clang/test/OpenMP/declare_mapper_messages.c | ||
---|---|---|
33–36 | Would be good to have ast print case and codegen |
clang/test/OpenMP/declare_mapper_messages.c | ||
---|---|---|
33–36 | I can add ast print! Code gen for this map modifier is going to be done in a separate patch. |
clang/test/OpenMP/declare_mapper_messages.c | ||
---|---|---|
33–36 | Ok, a st print should be enough |
Why do we need it here, if it is specific to map clause?