Skip to content

Commit

Permalink
Revert "[OpenMP] atomic compare fail : Parser & AST support"
Browse files Browse the repository at this point in the history
This reverts commit edd675a.

This breaks clang build where every component is a shared library.

The file clang/lib/Basic/OpenMPKinds.cpp, which is a part of
libclangBasic.so, uses `getOpenMPClauseName` which isn't:

/usr/bin/ld: CMakeFiles/obj.clangBasic.dir/OpenMPKinds.cpp.o: in functio
n `clang ::getOpenMPSimpleClauseTypeName(llvm::omp::Clause, unsigned int
)':
OpenMPKinds.cpp:(.text._ZN5clang29getOpenMPSimpleClauseTypeNameEN4llvm3o
mp6ClauseEj+0x9b): undefined reference to `llvm::omp::getOpenMPClauseNam
e(llvm::omp::Clause)'
  • Loading branch information
kparzysz committed Nov 20, 2023
1 parent 882d400 commit ddfed81
Show file tree
Hide file tree
Showing 20 changed files with 1 addition and 255 deletions.
83 changes: 0 additions & 83 deletions clang/include/clang/AST/OpenMPClause.h
Original file line number Diff line number Diff line change
Expand Up @@ -2513,89 +2513,6 @@ class OMPRelaxedClause final : public OMPClause {
}
};

/// This represents 'fail' clause in the '#pragma omp atomic'
/// directive.
///
/// \code
/// #pragma omp atomic compare fail
/// \endcode
/// In this example directive '#pragma omp atomic compare' has 'fail' clause.
class OMPFailClause final : public OMPClause {

// FailParameter is a memory-order-clause. Storing the ClauseKind is
// sufficient for our purpose.
OpenMPClauseKind FailParameter = llvm::omp::Clause::OMPC_unknown;
SourceLocation FailParameterLoc;
SourceLocation LParenLoc;

friend class OMPClauseReader;

/// Sets the location of '(' in fail clause.
void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }

/// Sets the location of memoryOrder clause argument in fail clause.
void setFailParameterLoc(SourceLocation Loc) { FailParameterLoc = Loc; }

/// Sets the mem_order clause for 'atomic compare fail' directive.
void setFailParameter(OpenMPClauseKind FailParameter) {
this->FailParameter = FailParameter;
assert(checkFailClauseParameter(FailParameter) &&
"Invalid fail clause parameter");
}

public:
/// Build 'fail' clause.
///
/// \param StartLoc Starting location of the clause.
/// \param EndLoc Ending location of the clause.
OMPFailClause(SourceLocation StartLoc, SourceLocation EndLoc)
: OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc) {}

OMPFailClause(OpenMPClauseKind FailParameter, SourceLocation FailParameterLoc,
SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation EndLoc)
: OMPClause(llvm::omp::OMPC_fail, StartLoc, EndLoc),
FailParameterLoc(FailParameterLoc), LParenLoc(LParenLoc) {

setFailParameter(FailParameter);
}

/// Build an empty clause.
OMPFailClause()
: OMPClause(llvm::omp::OMPC_fail, SourceLocation(), SourceLocation()) {}

child_range children() {
return child_range(child_iterator(), child_iterator());
}

const_child_range children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}

child_range used_children() {
return child_range(child_iterator(), child_iterator());
}
const_child_range used_children() const {
return const_child_range(const_child_iterator(), const_child_iterator());
}

static bool classof(const OMPClause *T) {
return T->getClauseKind() == llvm::omp::OMPC_fail;
}

/// Gets the location of '(' (for the parameter) in fail clause.
SourceLocation getLParenLoc() const {
return LParenLoc;
}

/// Gets the location of Fail Parameter (type memory-order-clause) in
/// fail clause.
SourceLocation getFailParameterLoc() const { return FailParameterLoc; }

/// Gets the parameter (type memory-order-clause) in Fail clause.
OpenMPClauseKind getFailParameter() const { return FailParameter; }
};

/// This represents clause 'private' in the '#pragma omp ...' directives.
///
/// \code
Expand Down
5 changes: 0 additions & 5 deletions clang/include/clang/AST/RecursiveASTVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -3398,11 +3398,6 @@ bool RecursiveASTVisitor<Derived>::VisitOMPCompareClause(OMPCompareClause *) {
return true;
}

template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPFailClause(OMPFailClause *) {
return true;
}

template <typename Derived>
bool RecursiveASTVisitor<Derived>::VisitOMPSeqCstClause(OMPSeqCstClause *) {
return true;
Expand Down
2 changes: 0 additions & 2 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -10962,8 +10962,6 @@ def note_omp_atomic_compare: Note<
"expect binary operator in conditional expression|expect '<', '>' or '==' as order operator|expect comparison in a form of 'x == e', 'e == x', 'x ordop expr', or 'expr ordop x'|"
"expect lvalue for result value|expect scalar value|expect integer value|unexpected 'else' statement|expect '==' operator|expect an assignment statement 'v = x'|"
"expect a 'if' statement|expect no more than two statements|expect a compound statement|expect 'else' statement|expect a form 'r = x == e; if (r) ...'}0">;
def err_omp_atomic_fail_wrong_or_no_clauses : Error<"expected a memory order clause">;
def err_omp_atomic_fail_no_compare : Error<"expected 'compare' clause with the 'fail' modifier">;
def err_omp_atomic_several_clauses : Error<
"directive '#pragma omp atomic' cannot contain more than one 'read', 'write', 'update', 'capture', or 'compare' clause">;
def err_omp_several_mem_order_clauses : Error<
Expand Down
9 changes: 0 additions & 9 deletions clang/include/clang/Basic/OpenMPKinds.def
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
#ifndef OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND
#define OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(Name)
#endif
#ifndef OPENMP_ATOMIC_FAIL_MODIFIER
#define OPENMP_ATOMIC_FAIL_MODIFIER(Name)
#endif
#ifndef OPENMP_AT_KIND
#define OPENMP_AT_KIND(Name)
#endif
Expand Down Expand Up @@ -141,11 +138,6 @@ OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(seq_cst)
OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(acq_rel)
OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND(relaxed)

// Modifiers for atomic 'fail' clause.
OPENMP_ATOMIC_FAIL_MODIFIER(seq_cst)
OPENMP_ATOMIC_FAIL_MODIFIER(acquire)
OPENMP_ATOMIC_FAIL_MODIFIER(relaxed)

// Modifiers for 'at' clause.
OPENMP_AT_KIND(compilation)
OPENMP_AT_KIND(execution)
Expand Down Expand Up @@ -234,7 +226,6 @@ OPENMP_DOACROSS_MODIFIER(source_omp_cur_iteration)
#undef OPENMP_SCHEDULE_MODIFIER
#undef OPENMP_SCHEDULE_KIND
#undef OPENMP_ATOMIC_DEFAULT_MEM_ORDER_KIND
#undef OPENMP_ATOMIC_FAIL_MODIFIER
#undef OPENMP_AT_KIND
#undef OPENMP_SEVERITY_KIND
#undef OPENMP_MAP_KIND
Expand Down
5 changes: 0 additions & 5 deletions clang/include/clang/Basic/OpenMPKinds.h
Original file line number Diff line number Diff line change
Expand Up @@ -363,11 +363,6 @@ bool isOpenMPCombinedParallelADirective(OpenMPDirectiveKind DKind);
/// \return true - if the above condition is met for this directive
/// otherwise - false.
bool needsTaskBasedThreadLimit(OpenMPDirectiveKind DKind);

/// Checks if the parameter to the fail clause in "#pragma atomic compare fail"
/// is restricted only to memory order clauses of "OMPC_acquire",
/// "OMPC_relaxed" and "OMPC_seq_cst".
bool checkFailClauseParameter(OpenMPClauseKind FailClauseParameter);
}

#endif
Expand Down
7 changes: 0 additions & 7 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -12193,13 +12193,6 @@ class Sema final {
/// Called on well-formed 'compare' clause.
OMPClause *ActOnOpenMPCompareClause(SourceLocation StartLoc,
SourceLocation EndLoc);
/// Called on well-formed 'fail' clause.
OMPClause *ActOnOpenMPFailClause(SourceLocation StartLoc,
SourceLocation EndLoc);
OMPClause *ActOnOpenMPFailClause(
OpenMPClauseKind Kind, SourceLocation KindLoc,
SourceLocation StartLoc, SourceLocation LParenLoc, SourceLocation EndLoc);

/// Called on well-formed 'seq_cst' clause.
OMPClause *ActOnOpenMPSeqCstClause(SourceLocation StartLoc,
SourceLocation EndLoc);
Expand Down
12 changes: 0 additions & 12 deletions clang/lib/AST/OpenMPClause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ const OMPClauseWithPreInit *OMPClauseWithPreInit::get(const OMPClause *C) {
case OMPC_update:
case OMPC_capture:
case OMPC_compare:
case OMPC_fail:
case OMPC_seq_cst:
case OMPC_acq_rel:
case OMPC_acquire:
Expand Down Expand Up @@ -228,7 +227,6 @@ const OMPClauseWithPostUpdate *OMPClauseWithPostUpdate::get(const OMPClause *C)
case OMPC_update:
case OMPC_capture:
case OMPC_compare:
case OMPC_fail:
case OMPC_seq_cst:
case OMPC_acq_rel:
case OMPC_acquire:
Expand Down Expand Up @@ -1927,16 +1925,6 @@ void OMPClausePrinter::VisitOMPCompareClause(OMPCompareClause *) {
OS << "compare";
}

void OMPClausePrinter::VisitOMPFailClause(OMPFailClause *Node) {
OS << "fail";
if (Node) {
OS << "(";
OS << getOpenMPSimpleClauseTypeName(
Node->getClauseKind(), static_cast<int>(Node->getFailParameter()));
OS << ")";
}
}

void OMPClausePrinter::VisitOMPSeqCstClause(OMPSeqCstClause *) {
OS << "seq_cst";
}
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/AST/StmtProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,8 +582,6 @@ void OMPClauseProfiler::VisitOMPCaptureClause(const OMPCaptureClause *) {}

void OMPClauseProfiler::VisitOMPCompareClause(const OMPCompareClause *) {}

void OMPClauseProfiler::VisitOMPFailClause(const OMPFailClause *) {}

void OMPClauseProfiler::VisitOMPSeqCstClause(const OMPSeqCstClause *) {}

void OMPClauseProfiler::VisitOMPAcqRelClause(const OMPAcqRelClause *) {}
Expand Down
17 changes: 0 additions & 17 deletions clang/lib/Basic/OpenMPKinds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,6 @@ unsigned clang::getOpenMPSimpleClauseType(OpenMPClauseKind Kind, StringRef Str,
.Case(#Name, OMPC_ATOMIC_DEFAULT_MEM_ORDER_##Name)
#include "clang/Basic/OpenMPKinds.def"
.Default(OMPC_ATOMIC_DEFAULT_MEM_ORDER_unknown);
case OMPC_fail:
return static_cast<unsigned int>(llvm::StringSwitch<llvm::omp::Clause>(Str)
#define OPENMP_ATOMIC_FAIL_MODIFIER(Name) .Case(#Name, OMPC_##Name)
#include "clang/Basic/OpenMPKinds.def"
.Default(OMPC_unknown));
case OMPC_device_type:
return llvm::StringSwitch<OpenMPDeviceType>(Str)
#define OPENMP_DEVICE_TYPE_KIND(Name) .Case(#Name, OMPC_DEVICE_TYPE_##Name)
Expand Down Expand Up @@ -439,11 +434,6 @@ const char *clang::getOpenMPSimpleClauseTypeName(OpenMPClauseKind Kind,
#include "clang/Basic/OpenMPKinds.def"
}
llvm_unreachable("Invalid OpenMP 'depend' clause type");
case OMPC_fail: {
OpenMPClauseKind CK = static_cast<OpenMPClauseKind>(Type);
return getOpenMPClauseName(CK).data();
llvm_unreachable("Invalid OpenMP 'fail' clause modifier");
}
case OMPC_device:
switch (Type) {
case OMPC_DEVICE_unknown:
Expand Down Expand Up @@ -899,10 +889,3 @@ void clang::getOpenMPCaptureRegions(
llvm_unreachable("Unknown OpenMP directive");
}
}

bool clang::checkFailClauseParameter(OpenMPClauseKind FailClauseParameter) {
return FailClauseParameter == llvm::omp::OMPC_acquire ||
FailClauseParameter == llvm::omp::OMPC_relaxed ||
FailClauseParameter == llvm::omp::OMPC_seq_cst;
}

4 changes: 0 additions & 4 deletions clang/lib/CodeGen/CGStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6516,10 +6516,6 @@ static void emitOMPAtomicExpr(CodeGenFunction &CGF, OpenMPClauseKind Kind,
IsPostfixUpdate, IsFailOnly, Loc);
break;
}
case OMPC_fail: {
//TODO
break;
}
default:
llvm_unreachable("Clause is not allowed in 'omp atomic'.");
}
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Parse/ParseOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3248,7 +3248,6 @@ OMPClause *Parser::ParseOpenMPClause(OpenMPDirectiveKind DKind,
else
Clause = ParseOpenMPSingleExprClause(CKind, WrongDirective);
break;
case OMPC_fail:
case OMPC_default:
case OMPC_proc_bind:
case OMPC_atomic_default_mem_order:
Expand Down
34 changes: 0 additions & 34 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12682,14 +12682,6 @@ StmtResult Sema::ActOnOpenMPAtomicDirective(ArrayRef<OMPClause *> Clauses,
}
break;
}
case OMPC_fail: {
if (AtomicKind != OMPC_compare) {
Diag(C->getBeginLoc(), diag::err_omp_atomic_fail_no_compare)
<< SourceRange(C->getBeginLoc(), C->getEndLoc());
return StmtError();
}
break;
}
case OMPC_seq_cst:
case OMPC_acq_rel:
case OMPC_acquire:
Expand Down Expand Up @@ -16891,11 +16883,6 @@ OMPClause *Sema::ActOnOpenMPSimpleClause(
static_cast<OpenMPAtomicDefaultMemOrderClauseKind>(Argument),
ArgumentLoc, StartLoc, LParenLoc, EndLoc);
break;
case OMPC_fail:
Res = ActOnOpenMPFailClause(
static_cast<OpenMPClauseKind>(Argument),
ArgumentLoc, StartLoc, LParenLoc, EndLoc);
break;
case OMPC_update:
Res = ActOnOpenMPUpdateClause(static_cast<OpenMPDependClauseKind>(Argument),
ArgumentLoc, StartLoc, LParenLoc, EndLoc);
Expand Down Expand Up @@ -17536,9 +17523,6 @@ OMPClause *Sema::ActOnOpenMPClause(OpenMPClauseKind Kind,
case OMPC_compare:
Res = ActOnOpenMPCompareClause(StartLoc, EndLoc);
break;
case OMPC_fail:
Res = ActOnOpenMPFailClause(StartLoc, EndLoc);
break;
case OMPC_seq_cst:
Res = ActOnOpenMPSeqCstClause(StartLoc, EndLoc);
break;
Expand Down Expand Up @@ -17699,24 +17683,6 @@ OMPClause *Sema::ActOnOpenMPCompareClause(SourceLocation StartLoc,
return new (Context) OMPCompareClause(StartLoc, EndLoc);
}

OMPClause *Sema::ActOnOpenMPFailClause(SourceLocation StartLoc,
SourceLocation EndLoc) {
return new (Context) OMPFailClause(StartLoc, EndLoc);
}

OMPClause *Sema::ActOnOpenMPFailClause(
OpenMPClauseKind Parameter, SourceLocation KindLoc,
SourceLocation StartLoc, SourceLocation LParenLoc,
SourceLocation EndLoc) {

if (!checkFailClauseParameter(Parameter)) {
Diag(KindLoc, diag::err_omp_atomic_fail_wrong_or_no_clauses);
return nullptr;
}
return new (Context)
OMPFailClause(Parameter, KindLoc, StartLoc, LParenLoc, EndLoc);
}

OMPClause *Sema::ActOnOpenMPSeqCstClause(SourceLocation StartLoc,
SourceLocation EndLoc) {
return new (Context) OMPSeqCstClause(StartLoc, EndLoc);
Expand Down
6 changes: 0 additions & 6 deletions clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -9866,12 +9866,6 @@ TreeTransform<Derived>::TransformOMPCompareClause(OMPCompareClause *C) {
return C;
}

template <typename Derived>
OMPClause *TreeTransform<Derived>::TransformOMPFailClause(OMPFailClause *C) {
// No need to rebuild this clause, no template-dependent parameters.
return C;
}

template <typename Derived>
OMPClause *
TreeTransform<Derived>::TransformOMPSeqCstClause(OMPSeqCstClause *C) {
Expand Down
13 changes: 0 additions & 13 deletions clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10276,9 +10276,6 @@ OMPClause *OMPClauseReader::readClause() {
case llvm::omp::OMPC_compare:
C = new (Context) OMPCompareClause();
break;
case llvm::omp::OMPC_fail:
C = new (Context) OMPFailClause();
break;
case llvm::omp::OMPC_seq_cst:
C = new (Context) OMPSeqCstClause();
break;
Expand Down Expand Up @@ -10672,16 +10669,6 @@ void OMPClauseReader::VisitOMPCaptureClause(OMPCaptureClause *) {}

void OMPClauseReader::VisitOMPCompareClause(OMPCompareClause *) {}

// Read the parameter of fail clause. This will have been saved when
// OMPClauseWriter is called.
void OMPClauseReader::VisitOMPFailClause(OMPFailClause *C) {
C->setLParenLoc(Record.readSourceLocation());
SourceLocation FailParameterLoc = Record.readSourceLocation();
C->setFailParameterLoc(FailParameterLoc);
OpenMPClauseKind CKind = Record.readEnum<OpenMPClauseKind>();
C->setFailParameter(CKind);
}

void OMPClauseReader::VisitOMPSeqCstClause(OMPSeqCstClause *) {}

void OMPClauseReader::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Expand Down
7 changes: 0 additions & 7 deletions clang/lib/Serialization/ASTWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6622,13 +6622,6 @@ void OMPClauseWriter::VisitOMPCaptureClause(OMPCaptureClause *) {}

void OMPClauseWriter::VisitOMPCompareClause(OMPCompareClause *) {}

// Save the parameter of fail clause.
void OMPClauseWriter::VisitOMPFailClause(OMPFailClause *C) {
Record.AddSourceLocation(C->getLParenLoc());
Record.AddSourceLocation(C->getFailParameterLoc());
Record.writeEnum(C->getFailParameter());
}

void OMPClauseWriter::VisitOMPSeqCstClause(OMPSeqCstClause *) {}

void OMPClauseWriter::VisitOMPAcqRelClause(OMPAcqRelClause *) {}
Expand Down
Loading

0 comments on commit ddfed81

Please sign in to comment.