[clang] [Clang] Add support for scoped atomic thread fence (PR #115545)

Joseph Huber via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 8 13:58:12 PST 2024


================
@@ -5133,6 +5133,135 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
     Builder.SetInsertPoint(ContBB);
     return RValue::get(nullptr);
   }
+  case Builtin::BI__scoped_atomic_thread_fence: {
+    auto ScopeModel = AtomicScopeModel::create(AtomicScopeModelKind::Generic);
+
+    Value *Order = EmitScalarExpr(E->getArg(0));
+    Value *Scope = EmitScalarExpr(E->getArg(1));
+    if (isa<llvm::ConstantInt>(Order) && isa<llvm::ConstantInt>(Scope)) {
+      int Ord = cast<llvm::ConstantInt>(Order)->getZExtValue();
+      int Scp = cast<llvm::ConstantInt>(Scope)->getZExtValue();
----------------
jhuber6 wrote:

All the atomic builtins do case expansion when the argument is not a constant, it can't be an error to have non-constant arguments because that's how `std::atomic` works AFAIK.

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


More information about the cfe-commits mailing list