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.
Details
- Reviewers
- None
Diff Detail
- Build Status
Buildable 6961 Build 6961: arc lint + arc unit
Event Timeline
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.
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.