[llvm-branch-commits] [clang] [Clang] define memory scopes as a builtin enum (PR #185408)

via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Mar 9 05:39:44 PDT 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-modules

Author: Sameer Sahasrabuddhe (ssahasra)

<details>
<summary>Changes</summary>

Clang currently represents memory scopes as pre-defined preprocessor macros that evaluate to integers. But so far, there are three sets of conflicting scopes: "common" clang scopes, HIP scopes and OpenCL scopes. These sets use the same integers in different orders, making it impossible to validate their use. A better approach is to represent these scopes as enum types, so that the integer values become less significant. Sema can now validate the scope argument by its type instead.

Both C and C++ define an enum for memory_order, but there is no standard enum for memory_scope. This change introduces a Clang-specific enum "memory_scope". The pre-defined macros are now mapped to this enum. Later changes can add similar enums for other languages.

enum __memory_scope {
  __memory_scope_system,
  __memory_scope_device,
  __memory_scope_workgroup,
  __memory_scope_wavefront,
  __memory_scope_singlethread,
  __memory_scope_cluster
};

Note that since this is not a standard enum, it cannot be introduced via stdatomic.h or other headers. Instead Sema builds this enum on demand when it sees an identifier that matches one of the enumerators. This ensures that the enum is injected in the AST only if it is used. Otherwise, it will show up in every program being compiled, which is noticeable in a number of test failures that were not expecting this enum.

For a gradual transition, Sema will continue to accept integer values for the "__scoped_atomic_*" builtins, but issue a warning in favour of the new enums. This change will only be visible to clients that use PCH files or clients like hip-rtc that store pre-processed files that are then passed to a newer compiler in the application's environment.

Assisted-By: Claude Sonnet 4.5

---

Patch is 42.55 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/185408.diff


18 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+6) 
- (modified) clang/include/clang/AST/DeclID.h (+3) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+3) 
- (modified) clang/lib/AST/ASTContext.cpp (+88) 
- (modified) clang/lib/Frontend/InitPreprocessor.cpp (+6-6) 
- (modified) clang/lib/Sema/SemaChecking.cpp (+42) 
- (modified) clang/lib/Sema/SemaLookup.cpp (+53) 
- (modified) clang/lib/Serialization/ASTReader.cpp (+6) 
- (modified) clang/lib/Serialization/ASTWriter.cpp (+1) 
- (modified) clang/test/Preprocessor/init-aarch64.c (+12-12) 
- (modified) clang/test/Preprocessor/init-loongarch.c (+12-12) 
- (modified) clang/test/Preprocessor/init.c (+30-30) 
- (added) clang/test/Sema/builtin-memory-scope-conflict.c (+14) 
- (added) clang/test/Sema/builtin-memory-scope-shadowing.c (+52) 
- (added) clang/test/Sema/builtin-memory-scope.c (+56) 
- (modified) clang/test/Sema/scoped-atomic-ops.c (+14-14) 
- (added) clang/test/Sema/scoped-atomic-scope-deprecation.c (+106) 
- (modified) clang/test/SemaOpenCL/atomic-ops.cl (+2-2) 


``````````diff
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index 05302c30d18d1..189c58a8f9e5b 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -515,6 +515,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
   /// Declaration for the CUDA cudaLaunchDevice function.
   FunctionDecl *cudaLaunchDeviceDecl = nullptr;
 
+  /// The typedef for the __memory_scope enum type.
+  mutable TypedefDecl *MemoryScopeDecl = nullptr;
+
   /// Keeps track of all declaration attributes.
   ///
   /// Since so few decls have attrs, we keep them in a hash map instead of
@@ -1448,6 +1451,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
   /// Retrieve the declaration for the 128-bit unsigned integer type.
   TypedefDecl *getUInt128Decl() const;
 
+  /// Retrieve the declaration for the __memory_scope enum type.
+  TypedefDecl *getMemoryScopeDecl() const;
+
   //===--------------------------------------------------------------------===//
   //                           Type Constructors
   //===--------------------------------------------------------------------===//
diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h
index 47ae05b2747ae..c77ec3d8c8aab 100644
--- a/clang/include/clang/AST/DeclID.h
+++ b/clang/include/clang/AST/DeclID.h
@@ -65,6 +65,9 @@ enum PredefinedDeclIDs {
   /// The internal '__builtin_ms_va_list' typedef.
   PREDEF_DECL_BUILTIN_MS_VA_LIST_ID,
 
+  /// The internal '__memory_scope' typedef.
+  PREDEF_DECL_MEMORY_SCOPE_ID,
+
   /// The predeclared '_GUID' struct.
   PREDEF_DECL_BUILTIN_MS_GUID_ID,
 
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0e6b3f51a5231..9fbe0c9084936 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9636,6 +9636,9 @@ def warn_atomic_op_has_invalid_memory_order : Warning<
   InGroup<DiagGroup<"atomic-memory-ordering">>;
 def err_atomic_op_has_invalid_sync_scope : Error<
   "synchronization scope argument to atomic operation is invalid">;
+def warn_atomic_op_scope_should_be_enum : Warning<
+  "synchronization scope should be of type __memory_scope">,
+  InGroup<DiagGroup<"atomic-memory-scope">>;
 def warn_atomic_implicit_seq_cst : Warning<
   "implicit use of sequentially-consistent atomic may incur stronger memory barriers than necessary">,
   InGroup<DiagGroup<"atomic-implicit-seq-cst">>, DefaultIgnore;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index d9e9ae062e8d7..fcc2f6f4a41e5 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -1215,6 +1215,94 @@ TypedefDecl *ASTContext::getUInt128Decl() const {
   return UInt128Decl;
 }
 
+TypedefDecl *ASTContext::getMemoryScopeDecl() const {
+  // Return cached value if already created
+  if (MemoryScopeDecl)
+    return MemoryScopeDecl;
+
+    // Create the enum
+#define MEMORY_SCOPE_ENUMERATORS(ENUM)                                         \
+  ENUM(__memory_scope_system, 0)                                               \
+  ENUM(__memory_scope_device, 1)                                               \
+  ENUM(__memory_scope_workgroup, 2)                                            \
+  ENUM(__memory_scope_wavefront, 3)                                            \
+  ENUM(__memory_scope_singlethread, 4)                                         \
+  ENUM(__memory_scope_cluster, 5)
+
+  const char *EnumName = "__memory_scope";
+
+  // Check if user has already declared enum __memory_scope
+  // If so, we cannot create our builtin - return nullptr to signal error
+  IdentifierInfo &II = Idents.get(EnumName);
+  DeclContext::lookup_result Existing =
+      getTranslationUnitDecl()->lookup(DeclarationName(&II));
+  if (!Existing.empty()) {
+    // User declared __memory_scope before we could create the builtin
+    // Return nullptr - caller will diagnose this error
+    return nullptr;
+  }
+
+  // Create enum (unscoped, works in both C and C++)
+  EnumDecl *MemoryScopeEnum = EnumDecl::Create(
+      *this, getTranslationUnitDecl(), SourceLocation(), SourceLocation(),
+      &Idents.get(EnumName), nullptr, false, false, true);
+
+  MemoryScopeEnum->setIntegerType(IntTy);
+  MemoryScopeEnum->setImplicit();
+  MemoryScopeEnum->startDefinition();
+
+  // Track max value for bit calculation
+  int MaxValue = 0;
+
+  // Create enumerators
+  llvm::APSInt Val(getIntWidth(IntTy), false);
+
+#define ADD_ENUMERATOR(Name, Value)                                            \
+  Val = Value;                                                                 \
+  if ((Value) > MaxValue)                                                      \
+    MaxValue = (Value);                                                        \
+  {                                                                            \
+    EnumConstantDecl *Constant =                                               \
+        EnumConstantDecl::Create(*this, MemoryScopeEnum, SourceLocation(),     \
+                                 &Idents.get(#Name), IntTy, nullptr, Val);     \
+    Constant->setImplicit();                                                   \
+    MemoryScopeEnum->addDecl(Constant);                                        \
+  }
+
+  MEMORY_SCOPE_ENUMERATORS(ADD_ENUMERATOR)
+#undef ADD_ENUMERATOR
+
+  // Calculate bits needed for max value
+  unsigned NumPositiveBits =
+      MaxValue > 0 ? llvm::APInt(32, MaxValue).getActiveBits() : 0;
+
+  // Complete definition
+  MemoryScopeEnum->completeDefinition(IntTy, IntTy, NumPositiveBits, 0);
+
+  // Set enumerator types to the enum type (for C++)
+  QualType EnumType = getCanonicalTagType(MemoryScopeEnum);
+  for (EnumConstantDecl *Constant : MemoryScopeEnum->enumerators()) {
+    Constant->setType(EnumType);
+  }
+
+  // Add enum to TranslationUnit
+  getTranslationUnitDecl()->addDecl(MemoryScopeEnum);
+
+  // Create a typedef so we can use it without 'enum' keyword in C
+  TypedefDecl *TypedefD = TypedefDecl::Create(
+      *this, getTranslationUnitDecl(), SourceLocation(), SourceLocation(),
+      &Idents.get(EnumName), getTrivialTypeSourceInfo(EnumType));
+  TypedefD->setImplicit();
+  getTranslationUnitDecl()->addDecl(TypedefD);
+
+  // Cache the typedef (mutable field allows modification in const method)
+  MemoryScopeDecl = TypedefD;
+
+#undef MEMORY_SCOPE_ENUMERATORS
+
+  return TypedefD;
+}
+
 void ASTContext::InitBuiltinType(CanQualType &R, BuiltinType::Kind K) {
   auto *Ty = new (*this, alignof(BuiltinType)) BuiltinType(K);
   R = CanQualType::CreateUnsafe(QualType(Ty, 0));
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp b/clang/lib/Frontend/InitPreprocessor.cpp
index 1ccd74314f373..338320f6401b3 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -874,12 +874,12 @@ static void InitializePredefinedMacros(const TargetInfo &TI,
   Builder.defineMacro("__ATOMIC_SEQ_CST", "5");
 
   // Define macros for the clang atomic scopes.
-  Builder.defineMacro("__MEMORY_SCOPE_SYSTEM", "0");
-  Builder.defineMacro("__MEMORY_SCOPE_DEVICE", "1");
-  Builder.defineMacro("__MEMORY_SCOPE_WRKGRP", "2");
-  Builder.defineMacro("__MEMORY_SCOPE_WVFRNT", "3");
-  Builder.defineMacro("__MEMORY_SCOPE_SINGLE", "4");
-  Builder.defineMacro("__MEMORY_SCOPE_CLUSTR", "5");
+  Builder.defineMacro("__MEMORY_SCOPE_SYSTEM", "__memory_scope_system");
+  Builder.defineMacro("__MEMORY_SCOPE_DEVICE", "__memory_scope_device");
+  Builder.defineMacro("__MEMORY_SCOPE_WRKGRP", "__memory_scope_workgroup");
+  Builder.defineMacro("__MEMORY_SCOPE_WVFRNT", "__memory_scope_wavefront");
+  Builder.defineMacro("__MEMORY_SCOPE_SINGLE", "__memory_scope_singlethread");
+  Builder.defineMacro("__MEMORY_SCOPE_CLUSTR", "__memory_scope_cluster");
 
   // Define macros for the OpenCL memory scope.
   // The values should match AtomicScopeOpenCLModel::ID enum.
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index ba9890296ef96..a80aa60784c1d 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2099,6 +2099,27 @@ CheckBuiltinTargetInSupported(Sema &S, CallExpr *TheCall,
   return true;
 }
 
+/// CheckScopedAtomicScopeArgument - Check the scope argument for scoped atomic
+/// operations and fences. Emits a deprecation warning if an integer type is
+/// used instead of the __memory_scope enum.
+static void CheckScopedAtomicScopeArgument(Sema &S, Expr *Scope) {
+  assert(Scope->getType()->isIntegerType() &&
+         "Non-integer type should have emitted an error before reaching here");
+  // Strip implicit casts to get the original expression type
+  Expr *OrigScope = Scope->IgnoreParenImpCasts();
+
+  // Check if it's the __memory_scope enum type
+  if (const auto *EnumTy = OrigScope->getType()->getAs<EnumType>()) {
+    if (EnumTy->getDecl()->getName() == "__memory_scope") {
+      return;
+    }
+  }
+
+  // Use of any other integer type gets a warning
+  S.Diag(Scope->getBeginLoc(), diag::warn_atomic_op_scope_should_be_enum)
+      << Scope->getSourceRange();
+}
+
 static void CheckNonNullArgument(Sema &S, const Expr *ArgExpr,
                                  SourceLocation CallSiteLoc);
 
@@ -3181,6 +3202,14 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
     Diag(TheCall->getBeginLoc(), diag::warn_atomic_implicit_seq_cst)
         << TheCall->getCallee()->getSourceRange();
     break;
+  case Builtin::BI__scoped_atomic_thread_fence: {
+    // Validate the scope argument (second argument)
+    if (TheCall->getNumArgs() >= 2) {
+      Expr *Scope = TheCall->getArg(1);
+      CheckScopedAtomicScopeArgument(*this, Scope);
+    }
+    break;
+  }
   case Builtin::BI__builtin_nontemporal_load:
   case Builtin::BI__builtin_nontemporal_store:
     return BuiltinNontemporalOverloaded(TheCallResult);
@@ -5157,12 +5186,25 @@ ExprResult Sema::BuildAtomicExpr(SourceRange CallRange, SourceRange ExprRange,
 
   if (auto ScopeModel = AtomicExpr::getScopeModel(Op)) {
     auto *Scope = Args[Args.size() - 1];
+
+    // If the scope is an integer constant, validate its value
     if (std::optional<llvm::APSInt> Result =
             Scope->getIntegerConstantExpr(Context)) {
       if (!ScopeModel->isValid(Result->getZExtValue()))
         Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_sync_scope)
             << Scope->getSourceRange();
     }
+
+    if (!Scope->getType()->isIntegerType()) {
+      // Ensure that it is an integer.
+      Diag(Scope->getBeginLoc(), diag::err_atomic_op_has_invalid_sync_scope)
+          << Scope->getSourceRange();
+    } else if (BuiltinInfo && BuiltinInfo->Langs == ALL_LANGUAGES) {
+      // In the case of language-agnostic builtins, also check if it uses the
+      // builtin enum type "__memory_scope".
+      CheckScopedAtomicScopeArgument(*this, Scope);
+    }
+
     SubExprs.push_back(Scope);
   }
 
diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index a983a4a9a3378..c881e71da1fa4 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -2211,6 +2211,52 @@ bool LookupResult::isAvailableForLookup(Sema &SemaRef, NamedDecl *ND) {
   return false;
 }
 
+/// Try to create a builtin __memory_scope typedef or enumerator.
+/// Returns true if a declaration was added to R.
+static bool TryCreateMemoryScopeBuiltin(Sema &S, LookupResult &R,
+                                        const IdentifierInfo &II) {
+  // Don't create builtins during redeclaration lookup - this would conflict
+  // with user declarations of the same name
+  if (R.isForRedeclaration())
+    return false;
+
+  if (II.getName() == "__memory_scope") {
+    // Looking up __memory_scope typedef itself
+    if (TypedefDecl *TD = S.Context.getMemoryScopeDecl()) {
+      R.addDecl(TD);
+      R.resolveKind();
+      return true;
+    }
+    return false;
+  }
+
+  if (II.getName().starts_with("__memory_scope_")) {
+    // Looking up a __memory_scope enumerator
+    TypedefDecl *TD = S.Context.getMemoryScopeDecl();
+    if (!TD) {
+      // getMemoryScopeDecl() returned nullptr - user declared __memory_scope
+      // The enumerator won't be found, resulting in an "undeclared identifier"
+      // error
+      return false;
+    }
+
+    // Find the specific enumerator
+    if (const EnumType *ET = TD->getUnderlyingType()->getAs<EnumType>()) {
+      if (EnumDecl *ED = ET->getDecl()) {
+        for (auto *Enumerator : ED->enumerators()) {
+          if (Enumerator->getName() == II.getName()) {
+            R.addDecl(Enumerator);
+            R.resolveKind();
+            return true;
+          }
+        }
+      }
+    }
+  }
+
+  return false;
+}
+
 bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation,
                       bool ForceNoCPlusPlus) {
   DeclarationName Name = R.getLookupName();
@@ -2309,6 +2355,13 @@ bool Sema::LookupName(LookupResult &R, Scope *S, bool AllowBuiltinCreation,
       return true;
   }
 
+  // Check for __memory_scope builtins even when AllowBuiltinCreation is false,
+  // because we want to support __memory_scope as a builtin type name.
+  if (IdentifierInfo *II = Name.getAsIdentifierInfo()) {
+    if (TryCreateMemoryScopeBuiltin(*this, R, *II))
+      return true;
+  }
+
   // If we didn't find a use of this identifier, and if the identifier
   // corresponds to a compiler builtin, create the decl object for the builtin
   // now, injecting it into translation unit scope, and return it.
diff --git a/clang/lib/Serialization/ASTReader.cpp b/clang/lib/Serialization/ASTReader.cpp
index b82ae971bc84d..ccd99802085cf 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -8421,6 +8421,12 @@ Decl *ASTReader::getPredefinedDecl(PredefinedDeclIDs ID) {
     NewLoaded = Context.getBuiltinVaListDecl();
     break;
 
+  case PREDEF_DECL_MEMORY_SCOPE_ID:
+    if (Context.MemoryScopeDecl)
+      return Context.MemoryScopeDecl;
+    NewLoaded = Context.getMemoryScopeDecl();
+    break;
+
   case PREDEF_DECL_VA_LIST_TAG:
     if (Context.VaListTagDecl)
       return Context.VaListTagDecl;
diff --git a/clang/lib/Serialization/ASTWriter.cpp b/clang/lib/Serialization/ASTWriter.cpp
index ec718169550aa..b562d8aad929c 100644
--- a/clang/lib/Serialization/ASTWriter.cpp
+++ b/clang/lib/Serialization/ASTWriter.cpp
@@ -5647,6 +5647,7 @@ void ASTWriter::PrepareWritingSpecialDecls(Sema &SemaRef) {
   RegisterPredefDecl(Context.VaListTagDecl, PREDEF_DECL_VA_LIST_TAG);
   RegisterPredefDecl(Context.BuiltinMSVaListDecl,
                      PREDEF_DECL_BUILTIN_MS_VA_LIST_ID);
+  RegisterPredefDecl(Context.MemoryScopeDecl, PREDEF_DECL_MEMORY_SCOPE_ID);
   RegisterPredefDecl(Context.MSGuidTagDecl,
                      PREDEF_DECL_BUILTIN_MS_GUID_ID);
   RegisterPredefDecl(Context.MSTypeInfoTagDecl,
diff --git a/clang/test/Preprocessor/init-aarch64.c b/clang/test/Preprocessor/init-aarch64.c
index 09e3fc926a309..4d4bb419b6f5b 100644
--- a/clang/test/Preprocessor/init-aarch64.c
+++ b/clang/test/Preprocessor/init-aarch64.c
@@ -235,12 +235,12 @@
 // AARCH64-NEXT: #define __LONG_MAX__ 9223372036854775807L
 // AARCH64-NEXT: #define __LONG_WIDTH__ 64
 // AARCH64-NEXT: #define __LP64__ 1
-// AARCH64-NEXT: #define __MEMORY_SCOPE_CLUSTR 5
-// AARCH64-NEXT: #define __MEMORY_SCOPE_DEVICE 1
-// AARCH64-NEXT: #define __MEMORY_SCOPE_SINGLE 4
-// AARCH64-NEXT: #define __MEMORY_SCOPE_SYSTEM 0
-// AARCH64-NEXT: #define __MEMORY_SCOPE_WRKGRP 2
-// AARCH64-NEXT: #define __MEMORY_SCOPE_WVFRNT 3
+// AARCH64-NEXT: #define __MEMORY_SCOPE_CLUSTR __memory_scope_cluster
+// AARCH64-NEXT: #define __MEMORY_SCOPE_DEVICE __memory_scope_device
+// AARCH64-NEXT: #define __MEMORY_SCOPE_SINGLE __memory_scope_singlethread
+// AARCH64-NEXT: #define __MEMORY_SCOPE_SYSTEM __memory_scope_system
+// AARCH64-NEXT: #define __MEMORY_SCOPE_WRKGRP __memory_scope_workgroup
+// AARCH64-NEXT: #define __MEMORY_SCOPE_WVFRNT __memory_scope_wavefront
 // AARCH64-NEXT: #define __NO_INLINE__ 1
 // AARCH64-NEXT: #define __NO_MATH_ERRNO__ 1
 // AARCH64-NEXT: #define __OBJC_BOOL_IS_BOOL 0
@@ -991,12 +991,12 @@
 // ARM64EC-MSVC: #define __LONG_LONG_MAX__ 9223372036854775807LL
 // ARM64EC-MSVC: #define __LONG_MAX__ 2147483647L
 // ARM64EC-MSVC: #define __LONG_WIDTH__ 32
-// ARM64EC-MSVC: #define __MEMORY_SCOPE_CLUSTR 5
-// ARM64EC-MSVC: #define __MEMORY_SCOPE_DEVICE 1
-// ARM64EC-MSVC: #define __MEMORY_SCOPE_SINGLE 4
-// ARM64EC-MSVC: #define __MEMORY_SCOPE_SYSTEM 0
-// ARM64EC-MSVC: #define __MEMORY_SCOPE_WRKGRP 2
-// ARM64EC-MSVC: #define __MEMORY_SCOPE_WVFRNT 3
+// ARM64EC-MSVC: #define __MEMORY_SCOPE_CLUSTR __memory_scope_cluster
+// ARM64EC-MSVC: #define __MEMORY_SCOPE_DEVICE __memory_scope_device
+// ARM64EC-MSVC: #define __MEMORY_SCOPE_SINGLE __memory_scope_singlethread
+// ARM64EC-MSVC: #define __MEMORY_SCOPE_SYSTEM __memory_scope_system
+// ARM64EC-MSVC: #define __MEMORY_SCOPE_WRKGRP __memory_scope_workgroup
+// ARM64EC-MSVC: #define __MEMORY_SCOPE_WVFRNT __memory_scope_wavefront
 // ARM64EC-MSVC: #define __NO_INLINE__ 1
 // ARM64EC-MSVC: #define __NO_MATH_ERRNO__ 1
 // ARM64EC-MSVC: #define __OBJC_BOOL_IS_BOOL 0
diff --git a/clang/test/Preprocessor/init-loongarch.c b/clang/test/Preprocessor/init-loongarch.c
index ef9a043a8ddde..51c2449c32948 100644
--- a/clang/test/Preprocessor/init-loongarch.c
+++ b/clang/test/Preprocessor/init-loongarch.c
@@ -182,12 +182,12 @@
 // LA32: #define __LONG_LONG_MAX__ 9223372036854775807LL
 // LA32: #define __LONG_MAX__ 2147483647L
 // LA32: #define __LONG_WIDTH__ 32
-// LA32: #define __MEMORY_SCOPE_CLUSTR 5
-// LA32: #define __MEMORY_SCOPE_DEVICE 1
-// LA32: #define __MEMORY_SCOPE_SINGLE 4
-// LA32: #define __MEMORY_SCOPE_SYSTEM 0
-// LA32: #define __MEMORY_SCOPE_WRKGRP 2
-// LA32: #define __MEMORY_SCOPE_WVFRNT 3
+// LA32: #define __MEMORY_SCOPE_CLUSTR __memory_scope_cluster
+// LA32: #define __MEMORY_SCOPE_DEVICE __memory_scope_device
+// LA32: #define __MEMORY_SCOPE_SINGLE __memory_scope_singlethread
+// LA32: #define __MEMORY_SCOPE_SYSTEM __memory_scope_system
+// LA32: #define __MEMORY_SCOPE_WRKGRP __memory_scope_workgroup
+// LA32: #define __MEMORY_SCOPE_WVFRNT __memory_scope_wavefront
 // LA32: #define __NO_INLINE__ 1
 // LA32: #define __NO_MATH_ERRNO__ 1
 // LA32: #define __OBJC_BOOL_IS_BOOL 0
@@ -515,12 +515,12 @@
 // LA64: #define __LONG_MAX__ 9223372036854775807L
 // LA64: #define __LONG_WIDTH__ 64
 // LA64: #define __LP64__ 1
-// LA64: #define __MEMORY_SCOPE_CLUSTR 5
-// LA64: #define __MEMORY_SCOPE_DEVICE 1
-// LA64: #define __MEMORY_SCOPE_SINGLE 4
-// LA64: #define __MEMORY_SCOPE_SYSTEM 0
-// LA64: #define __MEMORY_SCOPE_WRKGRP 2
-// LA64: #define __MEMORY_SCOPE_WVFRNT 3
+// LA64: #define __MEMORY_SCOPE_CLUSTR __memory_scope_cluster
+// LA64: #define __MEMORY_SCOPE_DEVICE __memory_scope_device
+// LA64: #define __MEMORY_SCOPE_SINGLE __memory_scope_singlethread
+// LA64: #define __MEMORY_SCOPE_SYSTEM __memory_scope_system
+// LA64: #define __MEMORY_SCOPE_WRKGRP __memory_scope_workgroup
+// LA64: #define __MEMORY_SCOPE_WVFRNT __memory_scope_wavefront
 // LA64: #define __NO_INLINE__ 1
 // LA64: #define __NO_MATH_ERRNO__ 1
 // LA64: #define __OBJC_BOOL_IS_BOOL 0
diff --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 80b7a6399e5f4..387bc728cd213 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1901,12 +1901,12 @@
 // WEBASSEMBLY64-NEXT:#define __LONG_MAX__ 9223372036854775807L
 // WEBASSEMBLY64-NEXT:#define __LONG_WIDTH__ 64
 // WEBASSEMBLY64-NEXT:#define __LP64__ 1
-// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_CLUSTR 5
-// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_DEVICE 1
-// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_SINGLE 4
-// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_SYSTEM 0
-// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_WRKGRP 2
-// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_WVFRNT 3
+// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_CLUSTR __memory_scope_cluster
+// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_DEVICE __memory_scope_device
+// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_SINGLE __memory_scope_singlethread
+// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_SYSTEM __memory_scope_system
+// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_WRKGRP __memory_scope_workgroup
+// WEBASSEMBLY-NEXT:#define __MEMORY_SCOPE_WVFRNT __memory_scope_wavefront
 // WEBASSEMBLY-NEXT:#de...
[truncated]

``````````

</details>


https://github.com/llvm/llvm-project/pull/185408


More information about the llvm-branch-commits mailing list