Thanks, but I replaceAllUsesWith() - works well, but I still get bug in eraseFromParent(): While deleting: i32 (%class.B*, i32)* %_ZN1B1xEi An asserting value handle still pointed to this value! UNREACHABLE executed at /Users/neonomaly/LLVM/LLVM/lib/VMCore/Value.cpp:561! Yours sincerely, Kadysev Mikhail 21.04.2012, в 23:45, Nick Lewycky написал(а):> Михаил wrote: >> How correctly remove function from module? >> For example: >> >> int f1(int x) { >> ... >> a = f2(smth); >> ... >> } >> int f2 (int y) { >> ... >> b = f1(smth); >> ... >> } >> >> I need delete from module both f1 and f2. They haven't uses in other >> part of module, but I can't delete them with eraseFromParent, because >> they are use each other. > > Call X->replaceAllUsesWith(UndefValue::get(X->getType)) before calling X->eraseFromParent(). > > Nick-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120422/a1ef5335/attachment.html>
Could you reproduce this assertion with my test program? 22 апреля 2012 г. 0:09 пользователь Михаил <neonomaly.x at gmail.com> написал:> Thanks, but I replaceAllUsesWith() - works well, but I still get bug in > eraseFromParent(): > > While deleting: i32 (%class.B*, i32)* %_ZN1B1xEi > An asserting value handle still pointed to this value! > UNREACHABLE executed at /Users/neonomaly/LLVM/LLVM/lib/VMCore/Value.cpp:561! > > > Yours sincerely, > Kadysev Mikhail > > 21.04.2012, в 23:45, Nick Lewycky написал(а): > > Михаил wrote: > > How correctly remove function from module? > > For example: > > > int f1(int x) { > > ... > > a = f2(smth); > > ... > > } > > int f2 (int y) { > > ... > > b = f1(smth); > > ... > > } > > > I need delete from module both f1 and f2. They haven't uses in other > > part of module, but I can't delete them with eraseFromParent, because > > they are use each other. > > > Call X->replaceAllUsesWith(UndefValue::get(X->getType)) before calling > X->eraseFromParent(). > > Nick > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >
It also occurs on several (different) test cases. I have founded that assershion rises in void ValueHandleBase::ValueIsDeleted(Value *V); Code from function: // All callbacks, weak references, and assertingVHs should be dropped by now. if (V->HasValueHandle) { #ifndef NDEBUG // Only in +Asserts mode... dbgs() << "While deleting: " << *V->getType() << " %" << V->getNameStr() << "\n"; if (pImpl->ValueHandles[V]->getKind() == Assert) llvm_unreachable("An asserting value handle still pointed to this " value!"); #endif llvm_unreachable("All references to V were not removed?"); } Yours sincerely, Kadysev Mikhail 22.04.2012, в 1:41, Dmitry N. Mikushin написал(а):> Assertion occurs on some different test case? Could you attach its IR-code? > > 22 апреля 2012 г. 1:38 пользователь Михаил <neonomaly.x at gmail.com> написал: >> Yes >> >> Yours sincerely, >> Kadysev Mikhail >> >> 22.04.2012, в 0:30, Dmitry N. Mikushin написал(а): >> >> Could you reproduce this assertion with my test program? >> >> 22 апреля 2012 г. 0:09 пользователь Михаил <neonomaly.x at gmail.com> написал: >> >> Thanks, but I replaceAllUsesWith() - works well, but I still get bug in >> >> eraseFromParent(): >> >> >> While deleting: i32 (%class.B*, i32)* %_ZN1B1xEi >> >> An asserting value handle still pointed to this value! >> >> UNREACHABLE executed at /Users/neonomaly/LLVM/LLVM/lib/VMCore/Value.cpp:561! >> >> >> >> Yours sincerely, >> >> Kadysev Mikhail >> >> >> 21.04.2012, в 23:45, Nick Lewycky написал(а): >> >> >> Михаил wrote: >> >> >> How correctly remove function from module? >> >> >> For example: >> >> >> >> int f1(int x) { >> >> >> ... >> >> >> a = f2(smth); >> >> >> ... >> >> >> } >> >> >> int f2 (int y) { >> >> >> ... >> >> >> b = f1(smth); >> >> >> ... >> >> >> } >> >> >> >> I need delete from module both f1 and f2. They haven't uses in other >> >> >> part of module, but I can't delete them with eraseFromParent, because >> >> >> they are use each other. >> >> >> >> Call X->replaceAllUsesWith(UndefValue::get(X->getType)) before calling >> >> X->eraseFromParent(). >> >> >> Nick >> >> >> >> >> _______________________________________________ >> >> 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/20120422/44313fd8/attachment.html>
Михаил wrote:> Thanks, but I replaceAllUsesWith() - works well, but I still get bug in > eraseFromParent(): > > While deleting: i32 (%class.B*, i32)* %_ZN1B1xEi > An asserting value handle still pointed to this value! > UNREACHABLE executed at /Users/neonomaly/LLVM/LLVM/lib/VMCore/Value.cpp:561!The replaceAllUsesWith + eraseFromParent pattern remains correct, but there's more to the story than the parts we've focused on. This error means that there's some other code that is holding a pointer to the function you tried to delete, but is using AssertingVH to do so, so as to catch errors exactly like this producing a dangling pointer. The error message doesn't tell us who owns the AssertingVH (indeed, the asserting-vh doesn't know, much like a pointer doesn't know who owns it). So, under what circumstance are you doing this deletion? Is it inside a FunctionPass, or another kind of Pass? Are you using AssertingVH's or calling other code that is? Such as ValueMap's, or some llvm analysis pass which stores an AssertingVH? Nick> > > Yours sincerely, > Kadysev Mikhail > > 21.04.2012, в 23:45, Nick Lewycky написал(а): > >> Михаил wrote: >>> How correctly remove function from module? >>> For example: >>> >>> int f1(int x) { >>> ... >>> a = f2(smth); >>> ... >>> } >>> int f2 (int y) { >>> ... >>> b = f1(smth); >>> ... >>> } >>> >>> I need delete from module both f1 and f2. They haven't uses in other >>> part of module, but I can't delete them with eraseFromParent, because >>> they are use each other. >> >> Call X->replaceAllUsesWith(UndefValue::get(X->getType)) before calling >> X->eraseFromParent(). >> >> Nick > > > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
It is ModulePass with AnalysisUsage of CallGraph Yours sincerely, Kadysev Mikhail 22.04.2012, в 5:20, Nick Lewycky написал(а):> Михаил wrote: >> Thanks, but I replaceAllUsesWith() - works well, but I still get bug in >> eraseFromParent(): >> >> While deleting: i32 (%class.B*, i32)* %_ZN1B1xEi >> An asserting value handle still pointed to this value! >> UNREACHABLE executed at /Users/neonomaly/LLVM/LLVM/lib/VMCore/Value.cpp:561! > > The replaceAllUsesWith + eraseFromParent pattern remains correct, but there's more to the story than the parts we've focused on. This error means that there's some other code that is holding a pointer to the function you tried to delete, but is using AssertingVH to do so, so as to catch errors exactly like this producing a dangling pointer. > > The error message doesn't tell us who owns the AssertingVH (indeed, the asserting-vh doesn't know, much like a pointer doesn't know who owns it). > > So, under what circumstance are you doing this deletion? Is it inside a FunctionPass, or another kind of Pass? Are you using AssertingVH's or calling other code that is? Such as ValueMap's, or some llvm analysis pass which stores an AssertingVH? > > Nick > >> >> >> Yours sincerely, >> Kadysev Mikhail >> >> 21.04.2012, в 23:45, Nick Lewycky написал(а): >> >>> Михаил wrote: >>>> How correctly remove function from module? >>>> For example: >>>> >>>> int f1(int x) { >>>> ... >>>> a = f2(smth); >>>> ... >>>> } >>>> int f2 (int y) { >>>> ... >>>> b = f1(smth); >>>> ... >>>> } >>>> >>>> I need delete from module both f1 and f2. They haven't uses in other >>>> part of module, but I can't delete them with eraseFromParent, because >>>> they are use each other. >>> >>> Call X->replaceAllUsesWith(UndefValue::get(X->getType)) before calling >>> X->eraseFromParent(). >>> >>> Nick >> >> >> >> _______________________________________________ >> 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/20120422/27fccec4/attachment.html>