This is an archive of the discontinued LLVM Phabricator instance.

[Clang][OpenMP] Add the support for atomic compare in parser
ClosedPublic

Authored by tianshilei1992 on Dec 10 2021, 4:06 PM.

Details

Summary

This patch adds the support for atomic compare in parser. The support
in Sema and CodeGen will come soon. For now, it simply eimits an error when it
is encountered.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Dec 10 2021, 4:06 PM
tianshilei1992 requested review of this revision.Dec 10 2021, 4:06 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptDec 10 2021, 4:06 PM

remove useless code

further remove code

continue to remove more unrelated code changes

rebase and remove unnecessary changes

All good but parser tests needed.

Note you'll want to add a line to flang/lib/Semantics/check-omp-structure.cpp for the new clause or the flang build will fail.

CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)

Note you'll want to add a line to flang/lib/Semantics/check-omp-structure.cpp for the new clause or the flang build will fail.

CHECK_SIMPLE_CLAUSE(Compare, OMPC_compare)

Thanks, will do.

All good but parser tests needed.

Since we directly emit an error in Sema, I'm not sure if we can do the same thing as clang/test/OpenMP/atomic_ast_print.cpp because we can always get compile error. I'll see what we can do.

cchen added a subscriber: cchen.Dec 16 2021, 9:35 AM

update one test case and flang fix

Herald added a project: Restricted Project. · View Herald TranscriptDec 17 2021, 1:04 PM

remove unexpected change

tianshilei1992 planned changes to this revision.Dec 20 2021, 5:48 PM

I think I'm going to build another patches on top of this one and land them altogether. In this way, I don't need to add any test in this patch.

just emit the error but not return

ABataev added inline comments.Dec 23 2021, 4:51 AM
clang/include/clang/AST/OpenMPClause.h
2234

final

clang/lib/Sema/SemaOpenMP.cpp
11400–11402

Maybe emit error in codegen instead? Without adding err_omp_atomic_compare message in include/clang/Basic/DiagnosticSemaKinds.td, just emit emit directly there:

unsigned DiagID = CGM.getDiags().getCustomDiagID(
    DiagnosticsEngine::Error, "atomic compare is not supported for now");
CGM.getDiags().Report(SLoc, DiagID);
tianshilei1992 marked 2 inline comments as done.Dec 23 2021, 5:33 PM
tianshilei1992 added inline comments.
clang/lib/Sema/SemaOpenMP.cpp
11400–11402

I think emitting error here sounds better because if we defer it to codegen, it's like it already passed Sema but in fact it didn't.

This revision is now accepted and ready to land.Dec 24 2021, 4:23 AM
This revision was landed with ongoing or failed builds.Dec 24 2021, 5:17 AM
This revision was automatically updated to reflect the committed changes.
tianshilei1992 marked an inline comment as done.