This is an archive of the discontinued LLVM Phabricator instance.

[InlineCost] Fix scalable vectors in visitAlloca
ClosedPublic

Authored by c-rhodes on Aug 12 2020, 11:16 AM.

Details

Summary

Discovered as part of the VLS type work (see D85128).

Diff Detail

Event Timeline

c-rhodes created this revision.Aug 12 2020, 11:16 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 12 2020, 11:16 AM
c-rhodes requested review of this revision.Aug 12 2020, 11:16 AM
efriedma added inline comments.Aug 12 2020, 11:21 AM
llvm/lib/Analysis/InlineCost.cpp
857

This will refuse to inline any function with a scalable vector variable; that seems so conservative that it's likely to cause practical issues. Please take the time to fix the code properly.

c-rhodes added inline comments.Aug 12 2020, 12:52 PM
llvm/lib/Analysis/InlineCost.cpp
857

This will refuse to inline any function with a scalable vector variable; that seems so conservative that it's likely to cause practical issues. Please take the time to fix the code properly.

Is that not better than crashing? As far as I can tell either getFixedSize will be called causing a crash or it's a dynamic alloca that wont be inlined anyway.

I know we want to support scalable vectors here but unless I'm missing something this seems like a worthwhile improvement for the time being.

efriedma added inline comments.Aug 12 2020, 2:39 PM
llvm/lib/Analysis/InlineCost.cpp
857

Reading the code, I think you could just replace the uses of getFixedSize() with getKnownMinSize() and get roughly the right behavior.

The reason I don't want to put this off is that inlining is very important for optimizations; if we add a hack now, we're inevitably going to have to look at it again very soon, so I'd rather just get it done now.

c-rhodes updated this revision to Diff 285644.Aug 14 2020, 7:02 AM
c-rhodes retitled this revision from [InlineCost] Skip scalable vectors in visitAlloca to [InlineCost] Fix scalable vectors in visitAlloca.

Replace getFixedSize with getKnownMinSize rather than skipping scalable vectors.

c-rhodes marked an inline comment as done.Aug 14 2020, 7:05 AM
c-rhodes added inline comments.
llvm/lib/Analysis/InlineCost.cpp
857

The reason I don't want to put this off is that inlining is very important for optimizations; if we add a hack now, we're inevitably going to have to look at it again very soon, so I'd rather just get it done now.

No worries, makes sense if it's as trivial as using getKnownMinSize instead

This revision is now accepted and ready to land.Aug 14 2020, 8:34 AM
This revision was automatically updated to reflect the committed changes.
c-rhodes marked an inline comment as done.