[PATCH] D75285: Mark restrict pointer or reference to const as invariant

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 27 11:46:37 PST 2020


yaxunl created this revision.
yaxunl added a reviewer: rjmccall.

We saw users intend to use `const int* restrict` to indicate the memory pointed to by the pointer is invariant.

This makes sense since restrict means the memory is not aliased by any other pointers whereas const
means the memory does not change.

Mark such pointer or reference as invariant allows more optimization opportunities.

This gives users a way to mark something as invariant.


https://reviews.llvm.org/D75285

Files:
  clang/lib/CodeGen/CGDeclCXX.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGenCXX/invariant.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75285.247047.patch
Type: text/x-patch
Size: 13048 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200227/8de8bb20/attachment-0001.bin>


More information about the cfe-commits mailing list