[LLVMdev] Cloning Functions
David Greene
dag at cray.com
Fri Jul 11 12:47:24 PDT 2008
On Friday 11 July 2008 12:12, David Greene wrote:
> On Friday 11 July 2008 12:05, Devang Patel wrote:
> > > Ok, I've mostly got a mechanism to do what I want:
> > >
> > > 1. As each function comes in for op/codegen, clone it and save off
> > > the clone and its associated ValueMap (I call these clones
> > > "pristine"
> > > functions.
> > >
> > > 2. After all processing is done, clone the resulting Module (this
> > > has all of
> > > the global data and the optimized functions). Save the ValueMap
> > > from this
> > > operation.
> >
> > The global data is also optimized at this point. Will it map properly
> > with un-optimized pristine functions ?
>
> I had wondered that myself. In what way is global data optimized?
> My assumption is that global data might be added by optimizations
> but that nothing would be deleted or drastically changed.
Hmm...it seems you are right. When I try to merge the two value maps I
get a faullt mapping a ConstantValue from one of the pristine Function
clones. Apparently this ConstantValue got deleted by optimization
somewhere.
This actually doesn't make a lot of sense to me. What happens if I
clone a function and optimize it or the original function and ConstantValues
start getting deleted? That ConstantValue could still be referenced by
the unoptimized version of the function. I would think this situation would
be rather common.
Is it because the pristine Function clones live outside a Module that I'm
having this issue?
This seems much harder than it should be.
-Dave
More information about the llvm-dev
mailing list