================
@@ -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
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to