Depnds on D20116
I am planning to add the speculatable attribute to all the intrinsics listed in this function in a separate patch.
Do we want to also change this function to give information about speculatable cost as proposed in this review: https://reviews.llvm.org/D20116
Another question I have is should the presence of speculatable by itself be enough for isSafeToSpeculativelyExecute() to return true. This would mean that the callers would be responsible for checking memory dependencies before speculating. The alternative would be to make isSafeToSpeculativelyExecute() require both the readnone and speculatable attributes.
I agree. We could easily end up with invoked functions being speculatable as an intermediate state (especially if we start inferring the attribute).
Also, it is not clearly a logical contradiction. The user might add the speculatable attribute on a function that might throw because the user does not care if the exception is thrown early. I'm not sure what we would do with that, however, because moving the catch blocks around to speculate the invoke seems unlikely worthwhile.