This patch introduces call base context information to the IRPosition
This patch is part of the patch set that are going to introduce call base specific analysis.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
We need some way of testing this, so tests that enable this and some way of checking the output. We could look for the debug output or add some other way of checking
llvm/lib/Transforms/IPO/Attributor.cpp | ||
---|---|---|
83 | typo |
Wouldn't just testing the uses of this path enough.
For example if we have are getting a correct call site constant range would that be enough ?
Not by this patch no. But I have patches that use CBContext(That I am going to send to phabricator soon).
Btw this patch introduces 8 bytes per attribute because of the CBContext.
I think we would ideally move it to a map inside the attributor.
I can inject the context through the update method or make the attribute ask the Attributor
like A.getCBContext(this); one problem with it is that since the operator<< for IRPosition don't have access
to the attributor we would not be able to print it even though it is useful to have.
One potential solution to this is to use a macro switch to have the CBContext inside the IRPosition only in debug builds.
Any other ideas ?
Run heapcheck and if the cgscc memory usage is not impacted much keep it this way ;)
We need a test for this. We can use unit tests or check the printed output (lit test + requires: asserts IIRC). Either works but we should add one.
llvm/include/llvm/Transforms/IPO/Attributor.h | ||
---|---|---|
457 | I'd prefer to copy the entire thing and then null the context. Will be optimized to the same code but is future proof :) | |
462 | Documentation for all of them please. | |
591 | Nit: I would prefer to move/add the initialization here. Assuming it is all the same to you. | |
953 | Move this into a helper function so we don't have to "make LLVM_DEBUG" work here. | |
955 | & RealIRP or maybe: if (!should...) IRP = IRP.strip... | |
llvm/lib/Transforms/IPO/Attributor.cpp | ||
91 | Nit: attributor-enable-call-site-specific is missing a final word, maybe specialization or deduction or something. | |
466 | Good thinking! | |
804 | Nit, formatting. |
llvm/include/llvm/Transforms/IPO/Attributor.h | ||
---|---|---|
955 | You are right. We can remove the const and reference from IRP actually. Either way is fine with me. If we do it as you have it now, maybe make it a reference. I'm not sold on Real as a name, maybe Effective, but that is not perfect either. |
add missing documentation.
improve formating and readability.
fix typos.
rename command line option
All this is missing now is a test :). We can just check for the debug output.
llvm/include/llvm/Transforms/IPO/Attributor.h | ||
---|---|---|
937 | Nit: newline Now we are in a hybrid solution, should we do if (should...) IRP = ... ? |
The problem I have is that this patch does not add anything that would trigger any of the code here.
There isn't much logic here either, most of it is in D83744.
I can add a unittest for 'hasCallBaseContext` and stripCallBaseContext
Hmm, I hoped with the flag you would see the context printed somewhere but it is never added I suppose. Do we have a unit test setup for the Attributor? Would be good :D
Memory usage for this patch:
comand: $LLVM_BIN/opt -S -attributor-cgscc test-suit/CTMark/SPASS/clause.ll
before:
calls to allocation functions: 78794 (82506/s) temporary memory allocations: 3942 (4127/s) peak heap memory consumption: 2.58MB peak RSS (including heaptrack overhead): 355.73MB total memory leaked: 140.33KB
after:
calls to allocation functions: 78802 (86977/s) temporary memory allocations: 3942 (4350/s) peak heap memory consumption: 2.59MB peak RSS (including heaptrack overhead): 356.60MB total memory leaked: 140.33KB
difference:
calls to allocation functions: 8 (-163/s) temporary memory allocations: 0 (0/s) peak heap memory consumption: 8.26KB peak RSS (including heaptrack overhead): 0B total memory leaked: 0B
Interesting, there doesn't seem to be much of a difference.
I made a mistake while creating this revision.
This is incomplete. instead of amending the [Attributor] Introduce CallBaseContext to the IRPosition I created a new commit and when I did arc diff It updated it to the state it is.
I will update this to include all of the patch.
sorry for the mess.
llvm/include/llvm/Transforms/IPO/Attributor.h | ||
---|---|---|
937 | Yes thank you, I should have ran the tests in D83744 before updating the revision. |
clang-tidy: warning: invalid case style for function 'function_scope' [readability-identifier-naming]
not useful