This is fix for PR24059.
When we are hoisting instruction above some condition it may turn out that metadata on this instruction was control dependant on the condition. So metadata on the hoisted instruction becomes invalid and we need to drop it. See the bug and test cases for the llvm-ir examples.
This patch should cover most obvious places of speculative execution (which I have found by greping isSafeToSpeculativelyExecute). I think there is more cases but at least it covers the severe ones.
Nit: "dependent"