This is an archive of the discontinued LLVM Phabricator instance.

[Inline] Fix noalias addition on simplified instructions (PR50589)
ClosedPublic

Authored by nikic on Jul 18 2021, 11:28 AM.

Details

Summary

When adding noalias/alias.scope metadata, we analyze the instructions of the original callee, and then place metadata on the corresponding inlined instructions in the caller as provided by VMap. However, this assumes that this actually a clone of the instruction, rather than the result of simplification. If simplification occurred, the instruction that VMap points to may not have any relationship as far as ModRef behavior is concerned.

Fix this by tracking simplified instructions during cloning and then only processing instructions that have not been simplified. This is done with an additional map form original to cloned instruction, into which we only insert if no simplification is performed. The mapping in VMap can then be compared to this map. If they're the same, the instruction hasn't been simplified. (I originally wanted to only track a set of simplified instructions, but that wouldn't work if the instruction only gets simplified afterwards, e.g. based on rewritten phis.)

Fixes https://bugs.llvm.org/show_bug.cgi?id=50589.

Diff Detail

Event Timeline

nikic created this revision.Jul 18 2021, 11:28 AM
nikic requested review of this revision.Jul 18 2021, 11:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 18 2021, 11:28 AM
llvm/test/Transforms/Inline/pr50589.ll
21

Use '--match-full-lines' to ensure that the !noalias metadata is missing ? Or else maybe a CHECK-NOT: !noalias might also do the trick.

nikic updated this revision to Diff 359870.Jul 19 2021, 12:00 PM

Add end of line match.

llvm/test/Transforms/Inline/pr50589.ll
21

It looks like --match-full-lines isn't compatible with update_test_checks output, so I added an explicit {{$}} to these two lines.

lgtm. Thanks !

This revision is now accepted and ready to land.Jul 19 2021, 3:25 PM
This revision was landed with ongoing or failed builds.Jul 20 2021, 10:52 AM
This revision was automatically updated to reflect the committed changes.