This is an archive of the discontinued LLVM Phabricator instance.

Avoid inlining if there is byval arguments with non-alloca address space
ClosedPublic

Authored by bjope on Jan 10 2018, 4:19 AM.

Details

Summary

After teaching InlineCost more about address spaces ()
another fault was detected in the inliner. If an argument has
the byval attribute the parameter might be copied to an alloca.
That part seems to work fine even if the argument has a different
address space than the alloca address space. However, if the
address spaces differ, then the inlined function still might
refer to the parameter using the original address space (the
inliner does not handle that situation very well).

This patch avoids the problem by simply disallowing inlining
when there are byval arguments with address space that differs
from the alloca address space.

I'm not really sure how to transform the code if we want to
get inlining for this situation. I assume that it never has
been working, and that the fixes in r321809 just exposed an
old problem.

Fault found by skatkov (Serguei Katkov). It is mentioned in
follow up comments to https://reviews.llvm.org/D40455.

Event Timeline

bjope created this revision.Jan 10 2018, 4:19 AM
bjope added a subscriber: uabelho.Jan 10 2018, 4:21 AM
skatkov accepted this revision.Jan 10 2018, 4:23 AM
This revision is now accepted and ready to land.Jan 10 2018, 4:23 AM
This revision was automatically updated to reflect the committed changes.