================
@@ -698,6 +704,36 @@ void CIRGenModule::constructFunctionArgumentAttributes(
builder.getI64IntegerAttr(
getNaturalPointeeTypeAlignment(argType).getQuantity()));
}
+
+ // Source-level parameter attributes (restrict, nonnull). These
+ // require the FunctionDecl to access ParmVarDecl info.
+ if (fd) {
+ unsigned paramIdx = &argAttrList - argAttrs.data();
+ unsigned srcIdx = info.isInstanceMethod() ? paramIdx - 1 : paramIdx;
+ if (srcIdx < fd->getNumParams()) {
+ const ParmVarDecl *pvd = fd->getParamDecl(srcIdx);
+ QualType pvdType = pvd->getType();
+
+ // restrict on pointer parameters → noalias. Skip builtins:
+ // OGCG only applies restrict→noalias through calling convention
+ // lowering, which builtins bypass.
+ if (pvdType->isPointerType() && pvdType.isRestrictQualified() &&
+ !fd->getBuiltinID())
+ argAttrList.set(mlir::LLVM::LLVMDialect::getNoAliasAttrName(),
+ mlir::UnitAttr::get(&getMLIRContext()));
+
+ // __attribute__((nonnull)) on pointer parameters.
+ if (pvdType->isPointerType() && !codeGenOpts.NullPointerIsValid) {
+ bool hasNonnull = pvd->hasAttr<NonNullAttr>();
----------------
adams381 wrote:
Addressed -- the restrict/nonnull checks now read naturally from the pvd in the
zip binding.
https://github.com/llvm/llvm-project/pull/188281
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits