[LLVMdev] CloneFunctionInto() Error

shahid shahid shahid77c at yahoo.com
Wed May 29 06:38:16 PDT 2013


After cloning you need to replace all the uses of original one with the cloned function.Probably you can use "replaceAllUsesWith( )" function to do this.
Regards,Shahid

--- On Wed, 5/29/13, Rasha Omar <rasha.sala7 at gmail.com> wrote:

From: Rasha Omar <rasha.sala7 at gmail.com>
Subject: Re: [LLVMdev] CloneFunctionInto() Error
To: LLVMdev at cs.uiuc.edu
Date: Wednesday, May 29, 2013, 5:23 AM

Does cloning copies the function with its address or it constructs a new address to the new function? Is this real copying for the CFG or just opaque one to do some work?
If it's not real copying, please I need a method that can help me in copying the function in another with new pointer to another address.


Please  I need answer urgent
Thanks


On 29 May 2013 10:14, Rasha Omar <rasha.sala7 at gmail.com> wrote:

Dear All,

I need your help urgently
I have to copy the CFG of each function using CloneFunction or CloneFunctionInto.

After I made the copy function. Print the basic blocks then get this error :


While deleting: i32 %
Use still stuck around after Def is destroyed:  %mul2_ = mul nsw i32 %6, 3
Use still stuck around after Def is destroyed:  store i32 3, i32* %x_, align 4
opt: Value.cpp:75: virtual llvm::Value::~Value(): Assertion `use_empty() && "Uses remain when a value is destroyed!"' failed.


0  opt             0x0000000000fc7fe2
1  opt             0x0000000000fc8473
2  libpthread.so.0 0x00007f0396f43cb0
3  libc.so.6       0x00007f0396195425 gsignal + 53
4  libc.so.6       0x00007f0396198b8b abort + 379


5  libc.so.6       0x00007f039618e0ee
6  libc.so.6       0x00007f039618e192
7  opt             0x0000000000f7cd7d
8  opt             0x0000000000ee3c52
9  opt             0x0000000000f5bddf llvm::LLVMContextImpl::~LLVMContextImpl() + 1999


10 opt             0x0000000000f5ad1c
11 opt             0x0000000000fb9d69 llvm::llvm_shutdown() + 41
12 opt             0x00000000005285b3 main + 7251
13 libc.so.6       0x00007f039618076d __libc_start_main + 237


14 opt             0x0000000000521f91
Stack dump:
0.    Program arguments: opt -load ../../../Release+Asserts/lib/Blocks.so -blocks 
Aborted (core dumped)



***The code is




 > std::vector<Type*> ArgTypes;

 > ValueToValueMapTy VMap;

 >FunctionType *FTy = FunctionType::get(F.getFunctionType()->getReturnType(),
                        ArgTypes, F.getFunctionType()->isVarArg());



 >Function *NewF = Function::Create(FTy, F.getLinkage(), F.getName());

 > SmallVector<ReturnInst*, 8> Returns; 

  >CloneFunctionInto(NewF, (Function*) &F, VMap, false, Returns, "_", 0, 0);




Thanks in advance

-- 
Rasha Salah Omar

Msc Student at E-JUST

Demonestrator  at Faculty of Computers and Informatics
Benha University





-- 
Rasha Salah Omar
Msc Student at E-JUST

Demonestrator  at Faculty of Computers and Informatics
Benha University



-----Inline Attachment Follows-----

_______________________________________________
LLVM Developers mailing list
LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130529/cb021a31/attachment.html>


More information about the llvm-dev mailing list