[PATCH] D79213: [hip] Add noalias on restrict qualified coerced hip pointers
Michael Liao via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 30 21:25:21 PDT 2020
hliao added a comment.
Basically, I think that should be a generic issue. As argument coercing doesn't handle pointer previously, we need to that address pointer-specific issue. That is, if the original argument has qualifiers being able to map onto LLVM attributes, the coerced argument should be those qualifiers as well if the new coerced one is still a simple value as the original one. We may lose more useful attributes not limited to `noalias`.
================
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);
+ }
----------------
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.
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