[clang] [CIR] Add restrict→noalias on non-builtin pointer params (PR #191483)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 10 15:52:12 PDT 2026
================
@@ -698,6 +698,23 @@ void CIRGenModule::constructFunctionArgumentAttributes(
builder.getI64IntegerAttr(
getNaturalPointeeTypeAlignment(argType).getQuantity()));
}
+
+ // restrict on pointer parameters -> noalias. Skip builtins: OGCG only
+ // applies restrict->noalias through calling convention lowering, which
+ // builtins bypass.
+ 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();
+
+ if (pvdType->isPointerType() && pvdType.isRestrictQualified() &&
+ !fd->getBuiltinID())
----------------
andykaylor wrote:
It's not clear to me that OGCG ever applies noalias to call sites. I'm also not sure what the benefit of doing so would be.
https://github.com/llvm/llvm-project/pull/191483
More information about the cfe-commits
mailing list