[Mlir-commits] [clang] [mlir] [CIR] Implement lowering for 'no-builtins' attributes (PR #178899)
Bruno Cardoso Lopes
llvmlistbot at llvm.org
Fri Jan 30 15:52:38 PST 2026
================
@@ -111,6 +111,41 @@ static void addAttributesFromFunctionProtoType(CIRGenBuilderTy &builder,
mlir::UnitAttr::get(builder.getContext()));
}
+static void addNoBuiltinAttributes(mlir::MLIRContext &ctx,
+ mlir::NamedAttrList &attrs,
+ const LangOptions &langOpts,
+ const NoBuiltinAttr *nba = nullptr) {
+ // First, handle the language options passed through -fno-builtin.
+ // or, if there is a wildcard in the builtin names specified through the
+ // attribute, disable them all.
+ if (langOpts.NoBuiltin ||
+ (nba && llvm::is_contained(nba->builtinNames(), "*"))) {
+ // -fno-builtin disables them all.
+ // Empty attribute means 'all'.
+ attrs.set(cir::CIRDialect::getNoBuiltinsAttrName(),
+ mlir::ArrayAttr::get(&ctx, {}));
+ return;
+ }
+
+ llvm::SetVector<mlir::Attribute> nbFuncs;
+ auto addNoBuiltinAttr = [&ctx, &nbFuncs](StringRef builtinName) {
+ nbFuncs.insert(mlir::StringAttr::get(&ctx, builtinName));
+ };
+
+ // Then, add attributes for builtins specified through -fno-builtin-<name>.
+ llvm::for_each(langOpts.NoBuiltinFuncs, addNoBuiltinAttr);
+
+ if (nba) {
----------------
bcardosolopes wrote:
get rid of this curly?
https://github.com/llvm/llvm-project/pull/178899
More information about the Mlir-commits
mailing list