<div dir="ltr"><div>Dear All,<br><br></div><div>I need your help urgently<br></div><div>I have to copy the CFG of each function using CloneFunction or CloneFunctionInto.<br></div><div>After I made the copy function. Print the basic blocks then get this error :<br>
<br>While deleting: i32 %<br>Use still stuck around after Def is destroyed:  %mul2_ = mul nsw i32 %6, 3<br>Use still stuck around after Def is destroyed:  store i32 3, i32* %x_, align 4<br>opt: Value.cpp:75: virtual llvm::Value::~Value(): Assertion `use_empty() && "Uses remain when a value is destroyed!"' failed.<br>
0  opt             0x0000000000fc7fe2<br>1  opt             0x0000000000fc8473<br>2  libpthread.so.0 0x00007f0396f43cb0<br>3  libc.so.6       0x00007f0396195425 gsignal + 53<br>4  libc.so.6       0x00007f0396198b8b abort + 379<br>
5  libc.so.6       0x00007f039618e0ee<br>6  libc.so.6       0x00007f039618e192<br>7  opt             0x0000000000f7cd7d<br>8  opt             0x0000000000ee3c52<br>9  opt             0x0000000000f5bddf llvm::LLVMContextImpl::~LLVMContextImpl() + 1999<br>
10 opt             0x0000000000f5ad1c<br>11 opt             0x0000000000fb9d69 llvm::llvm_shutdown() + 41<br>12 opt             0x00000000005285b3 main + 7251<br>13 libc.so.6       0x00007f039618076d __libc_start_main + 237<br>
14 opt             0x0000000000521f91<br>Stack dump:<br>0.    Program arguments: opt -load ../../../Release+Asserts/lib/Blocks.so -blocks <br>Aborted (core dumped)<br><br><br><br></div><div><div><div>***The code is<br><br>
<br> > std::vector<Type*> ArgTypes;<br><br> > ValueToValueMapTy VMap;<br><br> >FunctionType *FTy = FunctionType::get(F.getFunctionType()->getReturnType(),<br>                        ArgTypes, F.getFunctionType()->isVarArg());<br>
<br> >Function *NewF = Function::Create(FTy, F.getLinkage(), F.getName());<br><br> > SmallVector<ReturnInst*, 8> Returns; <br><br>  >CloneFunctionInto(NewF, (Function*) &F, VMap, false, Returns, "_", 0, 0);<br>
<br><br></div><div>Thanks in advance<br></div><div><br></div><div>-- <br><div dir="ltr"><b><span style="color:rgb(0,0,102)">Rasha Salah Omar</span><br style="color:rgb(0,0,102)"><span style="color:rgb(0,0,102)">Msc Student at E-JUST</span><br style="color:rgb(0,0,102)">
<span style="color:rgb(0,0,102)">Demonestrator  at Faculty of Computers and Informatics</span><br style="color:rgb(0,0,102)"><span style="color:rgb(0,0,102)">Benha University</span><br></b></div>
</div></div></div></div>