Address feedback in https://reviews.llvm.org/D158817. Since extractProbe can be used for both calliste and BB probe, we can leverage this to unify the callsite handling code.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/IPO/SampleProfile.cpp | ||
---|---|---|
2154–2158 | nit: may be good to hoist this code into a lamda and share it with the line-number path. |
addressing feedback
llvm/lib/Transforms/IPO/SampleProfile.cpp | ||
---|---|---|
2154–2158 | Good point, done! |
llvm/lib/Transforms/IPO/SampleProfile.cpp | ||
---|---|---|
2170–2172 | Actually can this be unified with FindTopLevelFrame? For not inlined calls, DIL->getSubprogramLinkageName should be equivalent to FindCalleeName(dyn_cast<CallBase>(&I))? |
llvm/lib/Transforms/IPO/SampleProfile.cpp | ||
---|---|---|
2170–2172 | Good point, but to clarify: Maybe my variable name is misleading in the new patch. Here is actually not FindTopLevelFrame, For example: "main:1 @ foo", the term "top-level" frame is "main:1", but here what it returns is {1, foo} , i,e {the top-level frame's location, the second top's frame's func name} uh..I need to fix it. That said, maybe we still can merge FindTopLevelFrame and FindCalleeName , like check if it's inlined code inside of the lambda, let me think. |
llvm/lib/Transforms/IPO/SampleProfile.cpp | ||
---|---|---|
2170–2172 | OK.. I'm done one version, please take a look https://reviews.llvm.org/D159221 I ran into some bugs and spent some times debugging, the tricky parts are :
I then made it work, but as it introduces more complexity, maybe it's still not what we want, any thoughts on this? |
llvm/lib/Transforms/IPO/SampleProfile.cpp | ||
---|---|---|
2114 | Maybe assert that DIL->getInlinedAt() is not null first. For not inlined DIL, this will not get what we want. Assert helps make it clear. With the assert, the loop can also changed to do-while to make it explicit. I find do-while slightly more readable for this kind of cases. do { PrevDIL = DIL; DIL = DIL->getInlinedAt(); } while (DIL->getInlinedAt()) | |
2124 | nit: this does not involve search/find, so maybe just GetCanonicalCalleeName. | |
2170–2172 | I guess, FindTopLevelFrame can be called FindTopLevelInlinedCallsite? It would also help to explain in a comment what it does with an example, like the main:1 @ foo one you mentioned above.
Thanks for clarification - I think that answered my original question, and the answer is no. Getting callsite (loc, callee_name pair) from debug info is only doable for inlined callsite, so for not inlined code, we need to get callee from the call instructions. I looked at https://reviews.llvm.org/D159221, i think that with better naming, the version in this patch is actually more readable. wdyt? |
Maybe assert that DIL->getInlinedAt() is not null first. For not inlined DIL, this will not get what we want. Assert helps make it clear.
With the assert, the loop can also changed to do-while to make it explicit. I find do-while slightly more readable for this kind of cases.