[clang] [CIR][ABI] Add restrict, nonnull, and ReturnsNonNull attributes (PR #188281)
via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 15 10:58:50 PDT 2026
================
@@ -613,16 +614,21 @@ void CIRGenModule::constructFunctionReturnAttributes(
getNaturalPointeeTypeAlignment(retTy).getQuantity()));
}
}
+
+ if (targetDecl && targetDecl->hasAttr<ReturnsNonNullAttr>() &&
+ !codeGenOpts.NullPointerIsValid)
+ retAttrs.set(mlir::LLVM::LLVMDialect::getNonNullAttrName(),
+ mlir::UnitAttr::get(&getMLIRContext()));
}
void CIRGenModule::constructFunctionArgumentAttributes(
- const CIRGenFunctionInfo &info, bool isThunk,
+ const CIRGenFunctionInfo &info, const Decl *targetDecl, bool isThunk,
llvm::MutableArrayRef<mlir::NamedAttrList> argAttrs) {
assert(!cir::MissingFeatures::abiArgInfo());
// TODO(cir): classic codegen does a lot of work here based on the ABIArgInfo
// to set things based on calling convention.
- // At the moment, only nonnull, dereferenceable, align, and noundef are being
- // implemented here, using similar logic to how we do so for return types.
+
+ const auto *fd = dyn_cast_or_null<FunctionDecl>(targetDecl);
----------------
adams381 wrote:
Moved into the pvd block below.
https://github.com/llvm/llvm-project/pull/188281
More information about the cfe-commits
mailing list