[PATCH] D79213: [hip] Add noalias on restrict qualified coerced hip pointers

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 1 08:22:27 PDT 2020


yaxunl added inline comments.


================
Comment at: clang/lib/CodeGen/CGCall.cpp:2556-2563
+      // Restrict qualified HIP pointers that were coerced to global pointers
+      // can be marked with the noalias attribute.
+      if (isCoercedHIPGlobalPointer(*this, getLangOpts(), ArgI, Ty) &&
+          Arg->getType().isRestrictQualified()) {
+        auto AI = cast<llvm::Argument>(FnArgs[FirstIRArg]);
+        AI->addAttr(llvm::Attribute::NoAlias);
+      }
----------------
hliao wrote:
> I don't think we need to check pointer address and/or HIP specific. As the generic argument processing, if the original type has any qualifiers, the coerced type (if it has a single value as the original parameter) should have those qualifiers as well. Here, we not only miss `restrict` but also alignment, `nonnull`, and etc. It should be fixed as a generic case instead of a target- or language-specific one.
I agree we should migrate other argument properties for promoted pointer-type kernel arg for HIP, and that should be possible since other than the address space change, the type is the same.

However, I am not sure if we can do that for coerced function arguments in general. It may not even be pointer any more.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D79213/new/

https://reviews.llvm.org/D79213





More information about the cfe-commits mailing list