Skip to content

[Clang] Use "syncscope" instead of "synchscope". NFC. #134616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -6757,7 +6757,7 @@ class PseudoObjectExpr final
/// and corresponding __opencl_atomic_* for OpenCL 2.0.
/// All of these instructions take one primary pointer, at least one memory
/// order. The instructions for which getScopeModel returns non-null value
/// take one synch scope.
/// take one sync scope.
class AtomicExpr : public Expr {
public:
enum AtomicOp {
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -9075,7 +9075,7 @@ def err_atomic_op_needs_atomic_int : Error<
def warn_atomic_op_has_invalid_memory_order : Warning<
"%select{|success |failure }0memory order argument to atomic operation is invalid">,
InGroup<DiagGroup<"atomic-memory-ordering">>;
def err_atomic_op_has_invalid_synch_scope : Error<
def err_atomic_op_has_invalid_sync_scope : Error<
"synchronization scope argument to atomic operation is invalid">;
def warn_atomic_implicit_seq_cst : Warning<
"implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary">,
Expand Down
38 changes: 19 additions & 19 deletions clang/include/clang/Basic/SyncScope.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,17 @@

namespace clang {

/// Defines synch scope values used internally by clang.
/// Defines sync scope values used internally by clang.
///
/// The enum values start from 0 and are contiguous. They are mainly used for
/// enumerating all supported synch scope values and mapping them to LLVM
/// synch scopes. Their numerical values may be different from the corresponding
/// synch scope enums used in source languages.
/// enumerating all supported sync scope values and mapping them to LLVM
/// sync scopes. Their numerical values may be different from the corresponding
/// sync scope enums used in source languages.
///
/// In atomic builtin and expressions, language-specific synch scope enums are
/// In atomic builtin and expressions, language-specific sync scope enums are
/// used. Currently only OpenCL memory scope enums are supported and assumed
/// to be used by all languages. However, in the future, other languages may
/// define their own set of synch scope enums. The language-specific synch scope
/// define their own set of sync scope enums. The language-specific sync scope
/// values are represented by class AtomicScopeModel and its derived classes.
///
/// To add a new enum value:
Expand Down Expand Up @@ -88,39 +88,39 @@ inline llvm::StringRef getAsString(SyncScope S) {
case SyncScope::OpenCLSubGroup:
return "opencl_subgroup";
}
llvm_unreachable("Invalid synch scope");
llvm_unreachable("Invalid sync scope");
}

/// Defines the kind of atomic scope models.
enum class AtomicScopeModelKind { None, OpenCL, HIP, Generic };

/// Defines the interface for synch scope model.
/// Defines the interface for sync scope model.
class AtomicScopeModel {
public:
virtual ~AtomicScopeModel() {}
/// Maps language specific synch scope values to internal
/// Maps language specific sync scope values to internal
/// SyncScope enum.
virtual SyncScope map(unsigned S) const = 0;

/// Check if the compile-time constant synch scope value
/// Check if the compile-time constant sync scope value
/// is valid.
virtual bool isValid(unsigned S) const = 0;

/// Get all possible synch scope values that might be
/// Get all possible sync scope values that might be
/// encountered at runtime for the current language.
virtual ArrayRef<unsigned> getRuntimeValues() const = 0;

/// If atomic builtin function is called with invalid
/// synch scope value at runtime, it will fall back to a valid
/// synch scope value returned by this function.
/// sync scope value at runtime, it will fall back to a valid
/// sync scope value returned by this function.
virtual unsigned getFallBackValue() const = 0;

/// Create an atomic scope model by AtomicScopeModelKind.
/// \return an empty std::unique_ptr for AtomicScopeModelKind::None.
static std::unique_ptr<AtomicScopeModel> create(AtomicScopeModelKind K);
};

/// Defines the synch scope model for OpenCL.
/// Defines the sync scope model for OpenCL.
class AtomicScopeOpenCLModel : public AtomicScopeModel {
public:
/// The enum values match the pre-defined macros
Expand All @@ -147,7 +147,7 @@ class AtomicScopeOpenCLModel : public AtomicScopeModel {
case SubGroup:
return SyncScope::OpenCLSubGroup;
}
llvm_unreachable("Invalid language synch scope value");
llvm_unreachable("Invalid language sync scope value");
}

bool isValid(unsigned S) const override {
Expand All @@ -156,7 +156,7 @@ class AtomicScopeOpenCLModel : public AtomicScopeModel {
}

ArrayRef<unsigned> getRuntimeValues() const override {
static_assert(Last == SubGroup, "Does not include all synch scopes");
static_assert(Last == SubGroup, "Does not include all sync scopes");
static const unsigned Scopes[] = {
static_cast<unsigned>(WorkGroup), static_cast<unsigned>(Device),
static_cast<unsigned>(AllSVMDevices), static_cast<unsigned>(SubGroup)};
Expand All @@ -168,7 +168,7 @@ class AtomicScopeOpenCLModel : public AtomicScopeModel {
}
};

/// Defines the synch scope model for HIP.
/// Defines the sync scope model for HIP.
class AtomicScopeHIPModel : public AtomicScopeModel {
public:
/// The enum values match the pre-defined macros
Expand Down Expand Up @@ -198,7 +198,7 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
case System:
return SyncScope::HIPSystem;
}
llvm_unreachable("Invalid language synch scope value");
llvm_unreachable("Invalid language sync scope value");
}

bool isValid(unsigned S) const override {
Expand All @@ -207,7 +207,7 @@ class AtomicScopeHIPModel : public AtomicScopeModel {
}

ArrayRef<unsigned> getRuntimeValues() const override {
static_assert(Last == System, "Does not include all synch scopes");
static_assert(Last == System, "Does not include all sync scopes");
static const unsigned Scopes[] = {
static_cast<unsigned>(SingleThread), static_cast<unsigned>(Wavefront),
static_cast<unsigned>(Workgroup), static_cast<unsigned>(Agent),
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/CodeGen/CGAtomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,8 +781,8 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *Expr, Address Dest,
llvm::Value *Scope) {
auto ScopeModel = Expr->getScopeModel();

// LLVM atomic instructions always have synch scope. If clang atomic
// expression has no scope operand, use default LLVM synch scope.
// LLVM atomic instructions always have sync scope. If clang atomic
// expression has no scope operand, use default LLVM sync scope.
if (!ScopeModel) {
llvm::SyncScope::ID SS;
if (CGF.getLangOpts().OpenCL)
Expand Down Expand Up @@ -821,8 +821,8 @@ static void EmitAtomicOp(CodeGenFunction &CGF, AtomicExpr *Expr, Address Dest,
CGF.createBasicBlock("atomic.scope.continue", CGF.CurFn);

auto *SC = Builder.CreateIntCast(Scope, Builder.getInt32Ty(), false);
// If unsupported synch scope is encountered at run time, assume a fallback
// synch scope value.
// If unsupported sync scope is encountered at run time, assume a fallback
// sync scope value.
auto FallBack = ScopeModel->getFallBackValue();
llvm::SwitchInst *SI = Builder.CreateSwitch(SC, BB[FallBack]);
for (auto S : Scopes) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4229,7 +4229,7 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
if (std::optional<llvm::APSInt> Result =
Scope->getIntegerConstantExpr(Context)) {
if (!ScopeModel->isValid(Result->getZExtValue()))
Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_synch_scope)
Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_sync_scope)
<< Scope->getSourceRange();
}
SubExprs.push_back(Scope);
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaOpenCL/atomic-ops.cl
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ void memory_checks(atomic_int *Ap, int *p, int val) {
(void)__opencl_atomic_compare_exchange_weak(Ap, p, val, memory_order_seq_cst, memory_order_relaxed, memory_scope_work_group);
}

void synchscope_checks(atomic_int *Ap, int scope) {
void syncscope_checks(atomic_int *Ap, int scope) {
(void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_work_item); // expected-error{{synchronization scope argument to atomic operation is invalid}}
(void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_work_group);
(void)__opencl_atomic_load(Ap, memory_order_relaxed, memory_scope_device);
Expand Down