Page MenuHomePhabricator

Mark llvm.*annotation intrinsics as NoMem and Speculatable
AbandonedPublic

Authored by mareko on Jun 3 2017, 8:51 AM.

Details

Reviewers
None
Summary

We'd like to use them in AMD's Mesa OpenGL driver to mark certain intrinsic
calls in a hw-independent way, but we wouldn't like the annotation
intrinsics to disallow optimizations.

Event Timeline

mareko created this revision.Jun 3 2017, 8:51 AM

Do we need to add more reviewers?

sanjoy added a subscriber: sanjoy.Jun 17 2017, 1:28 PM

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)?

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.

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.

How do you use these integer annotations? If you're using them solely as optimization information (i.e. dropping them would be correct, but perhaps undesirable), it may be better to use metadata here.

How do you use these integer annotations? If you're using them solely as optimization information (i.e. dropping them would be correct, but perhaps undesirable), it may be better to use metadata here.

The annotations are used to generate different/better LLVM IR next time we do the compilation. Dropping them would be incorrect. They need to be preserved at all costs.

mareko abandoned this revision.Nov 12 2018, 7:38 PM