[PATCH] D33865: Mark llvm.*annotation intrinsics as NoMem and Speculatable

Marek Olšák via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 19 09:05:45 PDT 2017


mareko added a comment.

In https://reviews.llvm.org/D33865#783238, @sanjoy wrote:

> In https://reviews.llvm.org/D33865#782258, @mareko wrote:
>
> > Do we need to add more reviewers?
>
>
> JFYI: so far you haven't added any reviewers. :)
>
> However, if you want to make this change, at the very least you also need to edit the language reference entry for `llvm.var.annotation` to state that it isn't allowed to express control flow dependent properties.  Can you also please give some examples of how you use `llvm.var.annotate` (for discussion)?


I use llvm.annotation to attach an integer number to some loads and stores to identify them uniquely. For loads, I annotate the return value, i.e. llvm.annotation(load(pointer), number). For stores, I annotate the input value being stored, i.e. store(llvm.annotation(value, number)). The load and store offsets can be rather arbitrary and not meaningful in my case (graphics shaders), but the numbers are unique. Then I run LLVM IR optimizations (DCE, CSE, etc.), and then I walk the IR and look at llvm.annotation(.., number) to see which loads and stores survived DCE. Since the loads and stores are from "invisible" memory, CSE can be used, but I need IntrNoMem and IntrSpeculatable there, so that llvm.annotation itself doesn't prevent CSE from being done.


https://reviews.llvm.org/D33865





More information about the llvm-commits mailing list