This patch adds an immutable pass, AssumptionTracker, which keeps a cache of @llvm.assume instructions within a module. It uses callback value handles to keep stale functions and intrinsics out of the map, and it relies on any code that creates new @llvm.assume calls to notify it of the new instructions. The benefit is that code needing to find @llvm.assume intrinsics can do so directly, without scanning the function, thus allowing the cost of @llvm.assume handling to be negligible when none are present.
I apologize ahead of time: Some of the patches in this series now depend on each other in odd ways. You probably can't compile them unless you apply them all.
Comment could be improved. Specifically, why are they tracked? What is the actually mapping?
Suggestions: pass that keeps track of @llvm.assume intrinsics found in each function of the module. As a result, scanning for assumes is quite cheap and can be used freely by the optimizers.