This is the Waymarking algorithm implemented as an independent utility.
The utility is operating on a range of sequential elements.
First we "tag" the elements, by calling fillWaymarks.
Then we can "follow" the tags from every element inside the tagged range, and reach the "head" (the first element), by calling followWaymarks.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Hi Ehud,
Thank you for the patch, can you elaborate on why this is a good thing to do? Is there another client of this functionality that you expect?
-Chris
Hi Chris,
I use this in another project built on top of LLVM, so I thought to share it.
It may be used in other projects as well; fir example, MLIR or Swift, in the same manner as it is used in the llvm::Use class.
We may also use this utility in the llvm::Use class itself, once it is in, to remove duplications.
Is there a reason why MLIR doesn't do this? The representation of Use and UseList in MLIR seems a little different from how it is done in llvm::Use.
In MLIR, IROperand points back to the Operation via the owner field.
This question would be best for River. MLIR is using a simpler approach, it isn't clear to me whether Waymarking would be worth it, but it should be possible to benchmark it now.
Using waymarking would be a nice memory savings(~1 word per operand). The main complaint I've heard about waymarking is the debuggability aspect of it.
Cool. Do you have time to review this patch for Ehud? he's been very patiently pinging
Looks mostly good to me. I think the main thing is that more documentation would be nice, waymarking can be extremely hard to follow at times if you aren't familiar with it. This is why it took me a bit to review, I had to make sure that I could follow all of the different templates correctly. That being said, I'm not sure that I am comfortable enough doing the final approval here.
llvm/include/llvm/ADT/Waymarking.h | ||
---|---|---|
120 | Can you add better documentation for this? I know this is an implementation detail, but it would help those of us that don't really know waymarking that well. | |
213 | Why use < instead of == or !=? This seems to apply a specific iterator pattern. For example, I don't think this would work for llvm::Use which may be allocated before the User. In that case the tags are assigned in reverse, with the end of the array being assigned the full stop tag. Could you add support and a test case for this potential usage? | |
217 | Can you please add more comments on the specific things going on here? | |
228 | Seems like Count is assigned to the same in both branches, can we de-duplicate? | |
llvm/unittests/ADT/WaymarkingTest.cpp | ||
19 | nit: Can you please hoist all of these static functions into the global namespace and mark them with 'static'? LLVM style is to generally only use anonymous namespaces for classes(or in this case, TEST). |
llvm/include/llvm/ADT/Waymarking.h | ||
---|---|---|
42 | Is the rightmost vertical line one bit too far to the right here? |
Thanks for the review! I really appreciate it, as I know this is a complicated one.
I'll add more documentation, and try to make it simpler/clearer.
llvm/include/llvm/ADT/Waymarking.h | ||
---|---|---|
42 | Correct. I'll fix it. | |
120 | Sure, I will. | |
213 | You are correct. The more general case is to use the == and != operators. I'll change that. | |
217 | Will do. | |
228 | Right. Will do. | |
llvm/unittests/ADT/WaymarkingTest.cpp | ||
19 | Will do. |
The docs made it much easier for me to follow, thanks!
llvm/unittests/ADT/WaymarkingTest.cpp | ||
---|---|---|
2 | This looks incorrect. |
llvm/unittests/ADT/WaymarkingTest.cpp | ||
---|---|---|
2 | Right. I'll fix that. |
Is the rightmost vertical line one bit too far to the right here?