<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Dec 18, 2019 at 7:16 AM Tim Northover via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi all,<br>
<br>
At the dev meeting I promised to update everyone on where my work with opaque<br>
pointers is right now. It's taken me a while, but at least it's the same year!<br>
<br>
Current Status<br>
==============<br>
<br>
I've put two branches up at <a href="https://github.com/TNorthover/llvm-project" rel="noreferrer" target="_blank">https://github.com/TNorthover/llvm-project</a>:<br>
"opaque-ptr" which has most of the real work so far; and "opaque-ptr-always"<br>
that additionally has a patch to force every pointer to be opaque and see what<br>
falls over. It's about 40 patches on top of master in a few categories.<br>
<br>
1. Serialization: bitcode <-> in-memory <-> textual IR[0].<br>
2. Relaxing assertions in Instruction constructors and the Verifier so<br>
that we don't assume every pointer has an element type.<br>
3. Modifying passes and other components to get their element types from other<br>
sources when needed. This is where I see the bulk of the future work in LLVM<br>
itself.<br>
<br>
All of them are very much from my dev machine and not prepared for real review.<br>
<br>
To give an idea of the work ahead, on "opaque-ptr-always", running "ninja check"<br>
there are about 4500 failures.<br>
<br>
Many of these are of course CHECK lines looking for typed pointers that LLVM<br>
will never again print; we'll need some kind of script to automate<br>
converting as many<br>
of those tests as possible.<br>
<br>
Byeond that, there are still about 800 assertion failures, but looking at the<br>
backtraces I think that there are "only" 75ish distinct callsites[1] that would<br>
have to be fixed, plus whatever's revealed behind them.<br>
<br>
<br>
Future Direction<br>
================<br>
<br>
I think this work needs to happen more incrementally. It's really not great that<br>
I've built up a backlog of 40 patches that only I have access to and can work<br>
on.<br>
<br>
So at a high level I think we should put the serialization and Instruction<br>
changes in sooner rather than later, giving us a largely undocumented[2] dialect<br>
of IR with opaque pointers that we can write tests against to upstream the rest<br>
of what I've done (and others can use to continue work in parallel if they're<br>
inclined).<br></blockquote><div><br>My, admittedly rather vague, plan was to change the API down to the point where there was only a primitive for "propagating pointee type from one place to another" but without the ability to query it otherwise - well, with a deprecated way to query it that we could chase down calls to as the main migration. Once we got to zero "getElementType" callers we could figure out the actual IR migration piece.<br><br>Do you think that wouldn't be viable & that introducing the new opaque pointer type sooner would be better/more viable?<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The risk is of course that this becomes yet another unfinished feature we drag<br>
around for years, with a corresponding maintenance burden. And it's a real risk,<br>
I unfortunately don't have the go ahead to work on this full time.<br>
<br>
But I don't think the alternatives are much better. Even full time I don't think<br>
I could do it completely alone because some choices will need input from<br>
experts. Even if I could, it would finish with a patch bomb even bigger than<br>
what I'm dropping here.<br>
<br>
<br>
Proposal<br>
========<br>
<br>
Short term (because otherwise we can't do it for another six months):<br>
<br>
1. Add inalloca(<ty>) support.<br></blockquote><div><br>Is byval already fixed/changed? I may've lost track of some of these changes, but I knew that was next on my list. (& how was byval addressed - byval(<ty>) or byval(byte count)? I guess inalloca goes/should go the same way as byval)<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
2. Document for January release the planned removal of:<br>
* Old style byval<br>
* Old style inalloca<br>
* Typeless CreateCall, CreateLoad, CreateGEP.<br></blockquote><div><br>Sounds good to me.<br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
3. Soon after January branch, strip out those bits. The third in<br>
particular should prevent front-end regression, I had to fix a fair<br>
few new deprecated callsites in Clang when rebasing everything this<br>
week.<br>
<br>
Short/medium term:<br>
<br>
1. Commit serialization and Instruction changes. </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
2. Use that to add tests for patches I already have and upstream them.<br>
3. Keep fixing the issues, but no-one not working on opaque pointers should need<br>
to change their behaviour other than a general encouragement to not use<br>
getElementType unless they have to.<br>
<br>
Long term:<br>
<br>
As we get close to everything working, we should shift the expectations so that<br>
new uses of getElementPtr aren't allowed in LLVM.<br>
<br>
Front-ends (including Clang) will need more work I suspect.<br>
<br>
No doubt there will be performance issues where having a pointee type helps some<br>
heuristic be a bit better. We'll have to decide what to do about those.<br>
<br>
[0] See attached opaque.ll for some proposed IR.<br>
[1] See attached asserts.txt if interested.<br>
[2] Or perhaps more likely documented with "don't use it unless you're working<br>
on opaque pointers" warnings.<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>