[PATCH] D53295: [OpenCL] Mark load of block invoke function as invariant

Yaxun Liu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 16 04:22:24 PDT 2018


yaxunl added inline comments.


================
Comment at: lib/CodeGen/CGBlocks.cpp:1318
+        CGM.getModule().getMDKindID("invariant.load"),
+        llvm::MDNode::get(getLLVMContext(), None));
+
----------------
rjmccall wrote:
> OpenCL blocks are still potentially function-local, right?  I don't think you're allowed to put `invariant.load` on something that's visibly initialized, even if it's visibly initialized to the same thing every time.  The problem is that `invariant.load` could allow the load to be hoisted above the initialization.
> 
> If you can solve that problem, you can make this non-OpenCL-specific.
It seems that invariant.load implies the pointer is invariant in the whole module, disregarding the store to it, which is not suitable for this case.

In this case what I need is that after the first store to the pointer, every load does not change.

It seems invariant.group can be used for this.


https://reviews.llvm.org/D53295





More information about the cfe-commits mailing list