[PATCH] D68852: [Attributor] Pointer privatization attribute (argument promotion)

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 12 11:19:31 PST 2019


jdoerfert added a comment.

In D68852#1781869 <https://reviews.llvm.org/D68852#1781869>, @uenoku wrote:

> Looks generally fine.
>  I couldn't imagine what is Pointer privatization at first hand. Could you add an example result of Pointer privatization? Like,
>
>   int f(int* ptr){
>    ...
>   }
>   =>
>   int f(int p){
>    int* ptr = &p;
>    ...
>   }
>


I will add the example to the class comment in the header file.

For the record:
Privatization, at least the part implemented so far, is roughly argument promotion. Instead of passing a pointer, pass the values accessed through it by the callee.
The existing argument promotion does not do privatization but tries to replace the uses of the pointer with the values passed right away. Privatization is simpler in that
regard but later, partially because of this, also more powerful.

> And I guess the current implementation always does privatization if possible. I think the cost may increase in some cases. What do you think about?

That is correct. So far, we build the Attribtor to be powerful (=applicable) not to be "smart" about costs. We'll have to write heurisitcs soon but before that I want to ask people to test the powerful version in order to get more coverage and sniff out bugs.

In fact, we might always do privatization once another piece of code I have only locally is available. With it, privatization might cause arbitrarily many arguments at the call site but we can always recover the original call site from it. More on that later though. For comparison: ArgumentPromotion restricts the size of the structs that are expanded arbitrarily to 3, which is beyond me.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68852/new/

https://reviews.llvm.org/D68852





More information about the llvm-commits mailing list