This is an archive of the discontinued LLVM Phabricator instance.

[Transforms] Preserve metadata when converting invoke to call.
ClosedPublic

Authored by Meinersbur on Dec 13 2018, 12:25 PM.

Details

Summary

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>

Diff Detail

Repository
rL LLVM

Event Timeline

Meinersbur created this revision.Dec 13 2018, 12:25 PM

Add test case

hfinkel added inline comments.Dec 13 2018, 8:12 PM
lib/Transforms/Utils/Local.cpp
1973 ↗(On Diff #178121)

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!

  • Generalize copyMetadata
Meinersbur retitled this revision from [Transforms] Preserve access metadata. to [Transforms] Preserve metadata when converting invoke to call..Dec 13 2018, 9:41 PM
hfinkel accepted this revision.Dec 14 2018, 8:20 AM

I think that this is okay. There's no semantic change nor a change in control dependence. For this to cause a problem, there would need to be metadata that would change meaning or validity when the instruction changes from an invoke to a call (where the invoke is semantically equivalent to the call).

LGTM.

This revision is now accepted and ready to land.Dec 14 2018, 8:20 AM
This revision was automatically updated to reflect the committed changes.
Meinersbur marked an inline comment as done.