[clang] [CIR][ABI] Add restrict, nonnull, and ReturnsNonNull attributes (PR #188281)

Andy Kaylor via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 25 15:46:44 PDT 2026


================
@@ -398,8 +398,13 @@ void CIRGenModule::constructAttributeList(
     attrs.set(cir::CIRDialect::getSideEffectAttrName(),
               cir::SideEffectAttr::get(&getMLIRContext(), sideEffect));
 
-    // TODO(cir): When doing 'return attrs' we need to cover the Restrict and
-    // ReturnsNonNull attributes here.
+    if (targetDecl->hasAttr<ReturnsNonNullAttr>())
+      retAttrs.set(mlir::LLVM::LLVMDialect::getNonNullAttrName(),
+                   mlir::UnitAttr::get(&getMLIRContext()));
+
+    // TODO(cir): Add noalias to returns for malloc-like functions
----------------
andykaylor wrote:

Nit: This is handled above the non-null handler in classic codegen. It might be good to move the comment.

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


More information about the cfe-commits mailing list