Generalize isSafeToSpeculativelyExecute to work on arbitrary