The changeToCall function did not preserve the invoke's metadata. Whether a call or invoke, the callee will access the same elements and therefore we can preserve the loop-parallel access metadata.
Copy the llvm.mem.parallel_loop_access from the invoke instruction before replacing it.
This fixes http://llvm.org/PR39994
Suggested-by: Moritz Kreutzer <moritz.kreutzer@siemens.com>
Can you please generalize this? We should preserve much more than this. LLVMContext::MD_alias_scope and LLVMContext::MD_noalias should be preserved as well. I don't believe that any of our current metadata is invalidated by this (although only a limited number can appear on calls).
Thanks!