[llvm-dev] [RFC] Refactor class hierarchy of VectorType in the IR

Chris Tetreault via llvm-dev llvm-dev at lists.llvm.org
Fri May 22 17:59:28 PDT 2020


John,

> I’m not going to feel guilty about work you did for over a month without raising an RFC.

I’m not sure what you mean by that, but I definitely did raise and RFC over this. On March 9th, I raised the initial RFC. I then pinged it on April 22nd. It was then pinged again on May 5th by another developer requesting a change to my plan. Just last week it was requested that I reverse some changes I had made to the C API for this work. I didn’t like those changes either, but I made them because it wasn’t that much work, and the impact wasn’t that great, but the people requesting them felt very strongly about the value of it. However, this change will be a ton of work and muddies up the C++ api in the name of stability, when the C++ api has no expectation of remaining stable.

I agree with Sander that perhaps the bi-weekly SVE meeting would be a good forum to discuss this further. I’d like to invite any other interested parties to join us in the meeting as well. I’d really like to settle this issue once and for all. My work can wait until then, it’s a long weekend after all. 😊

Thanks,
   Christopher Tetreault

From: John McCall <rjmccall at apple.com>
Sent: Friday, May 22, 2020 12:59 PM
To: Chris Tetreault <ctetreau at quicinc.com>
Cc: llvm-dev at lists.llvm.org
Subject: [EXT] Re: [llvm-dev] [RFC] Refactor class hierarchy of VectorType in the IR


On 22 May 2020, at 3:15, Chris Tetreault wrote:

John,

For the last several months, those of us working on the scalable vectors feature have been examining the codebase, identifying places where llvm::VectorType is used incorrectly, and fixing them. The fact is that there are many places where VectorType is correctly taken to be the generic “any vector” type. getNumElements may be being called, but it’s being called in accordance with the previously documented semantics. There are many places where it isn’t as well, and many people add new usages that are incorrect.

This puts us in an unfortunate situation: if we were to take your proposal and have VectorType be the fixed width vector type, then all of this work is undone. Every place that has been fixed up to correctly have VectorType be used as a universal vector type will now incorrectly have the fixed width vector type being used as the universal vector type. Since VectorType will inherit from BaseVectorType, it will have inherited the getElementCount(), so the compiler will happily continue to compile this code. However, none of this code will even work with scalable vectors because the bool will always be false. There will be no compile time indication that this is going on, functions will just start mysteriously returning nullptr. Earlier this afternoon, I set about seeing how much work it would be to change the type names as you have suggested. I do not see any way forward other than painstakingly auditing the code.

If you define getElementCount() = delete in VectorType, you can easily find the places that are doing this and update them to use VectorBaseType. You wouldn’t actually check that in, of course; it’s a tool for doing the audit in a way that’s no more painstaking than what you’re already doing with getNumElements(). And in the meantime, the code that you haven’t audited — the code that’s currently unconditionally calling getNumElements() on a VectorType — will just conservatively not trigger on scalable vectors, which for most of LLVM is a better result than crashing if a scalable vector comes through until your audit gets around to updating it.

Additionally, for those who disagree that the LLVM developer policy is to disregard the needs of downstream codebases when making changes to upstream, I submit that not throwing away months of work by everybody working to fix the codebase to handle scalable vectors represents a real expected benefit. I personally have been spending most of my time on this since January.

I’m responding to this as soon as I heard about it. I’ll accept that ideally I would have seen it when you raised the RFC in March, although in practice it’s quite hard to proactively keep up with llvmdev, and as a community I think we really need to figure out a better process for IR design. I’m not going to feel guilty about work you did for over a month without raising an RFC. And I really don’t think you have in any way wasted your time; I am asking for a large but fairly mechanical change to the code you’ve already been updating.

But most of your arguments are not based on how much work you’ve done on your current audit, they’re based on the fact that scalable vectors were initially implemented as a flag on VectorType. So part of my problem here is that you’re basically arguing that, as soon as that was accepted, the generalization of VectorType was irreversible; and that’s a real problem, because it’s very common for early prototype work to not worry much about representations, and so they stumble into this kind of problematic representation.

My concern is really only ~50% that this is going to force a lot of unnecessary mechanical changes for downstream projects and 50% that generalizing VectorType to include scalable vectors, as the initial prototype did, is the wrong polarity and makes a lot of existing code broken if it ever sees a scalable vector. Your hierarchy change only solves this in the specific case that there’s an immediate call to getNumElements().

Of course, if the community generally disagrees with me that this is necessary, I’ll accept that. But right now I’m just hearing from people that are part of your project.

John.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20200523/9b5ac2d2/attachment-0001.html>


More information about the llvm-dev mailing list