PHI node operads

Hi all,

I have a pass that duplicates all instructions and keeps a "reference
map" of duplicated values, which is later used to update all the
references, thus creating a whole copy of a previous function. How I was
doing it is calling "replaceUsesOfWith" in all the replicated
instructions.

This used to work on 2.9 and older, in svn it no longer does in the case
of PHI nodes, because the BasicBlocks are not "uses" in the PHI node. I
have read in the svn log that "replaceAllUsesWith" was updated to cope
with this, but in my case I do not want to replace all uses of the basic
block, only those *in the replicated* instructions.

I can make a special case in my code to solve this, but my question is:
should replaceUsesOfWith be overloaded in PHI so it mimics the previous
behaviour? PHINode inherits from User, after all, it being an
instruction, and it is a little confusing not to be able to replace its
uses.

Or maybe I am just missing something?

BR

Carlos

Hi Carlos,

I have a pass that duplicates all instructions and keeps a "reference
map" of duplicated values, which is later used to update all the
references, thus creating a whole copy of a previous function.

...

why don't you just call something like CloneFunction?

Ciao, Duncan.

Hi Duncan,

thanks for your answer.

> I have a pass that duplicates all instructions and keeps a "reference
> map" of duplicated values, which is later used to update all the
> references, thus creating a whole copy of a previous function.
...

why don't you just call something like CloneFunction?

Because I do not want to replicate the whole function, just some BBs
(you might think of it as replicating a subgraph of a given function). I
suppose I could "extract" the required BBs to functions, clone and
re-inline, but I find that a little too messy.

BR,

Carlos