[LLVMdev] Why is BasicBlock's copy constructor private?

me22 me22.ca at gmail.com
Thu Mar 25 17:23:56 PDT 2010


On 25 March 2010 20:04, Trevor Harmon <trevor.w.harmon at nasa.gov> wrote:
>
> So why exactly is BasicBlock's copy constructor private? The ominous
> "Do not implement" warning leads me to think there is some sort of
> design issue that is preventing a copy constructor here. Is there any
> possibility of working around it?
>

I think the problem is that LLVM deals largely in pointer types, so
things like BasicBlock aren't value types since objects with
equivalent contents cannot be used interchangeably.

For one, other blocks (and presumably the function) hold them by
pointer, so the copy wouldn't be reachable.  Also, the instructions in
the basic block are held by pointer and refer to their arguments by
pointer, so copying them would mean intelligently updating the
instruction arguments, which is likely infeasible.

Given that LLVM is already managing the memory and presumably will do
so for the life of your graph processing, could you just use a
boost::directed_graph<llvm::BasicBlock*> instead?

Alternatively, perhaps you want "external adaptation" as described in
http://www.boost.org/doc/libs/1_42_0/libs/graph/doc/leda_conversion.html

HTH,
~ Scott



More information about the llvm-dev mailing list