There are several optimizations when we try to load speculatively. There are also two similar functions to determine whether it's a safe transformation:
- isSafeToLoadUnconditionally
- isDereferenceableAndAlignedPointer
Once we have D9791in place, we can unify these two functions. With this change isSafeToLoadUnconditionally calls isDereferenceableAndAlignedPointer to check whether speculative execution is possible.
As a side effect optimizations which use isSafeToLoadUnconditionally will benefit from dereferenceable attribute. Corresponding test cases added.
Why can this part not be unified?
It seems this is the only difference. Why don't we just eliminate this function in favor of isDereferenceableAndAlignedPointer?