Hi, I have two functions in a module, X.foo, which is the callee, and Y.foo2, which calls X.foo. If i either try to run llvm::Function::eraseFromParent() on any one of the functions, i'll get this assertion error: F is used in instruction: %"calling function" = call i32 @X.foo(i32 %read) F is used in instruction: %"calling function" = call i32 @X.foo(i32 %read) While deleting: i32 (i32)* %X.foo Use still stuck around after Def is destroyed: %"calling function" call i32 @X.foo(i32 %read) mytests: Value.cpp:75: virtual llvm::Value::~Value(): Assertion `use_empty() && "Uses remain when a value is destroyed!"' failed. regardless of which one i call first. What is the appropiate way to delete a function from an existing module?
charles quarra wrote:> Hi, > > I have two functions in a module, X.foo, which is the callee, and > Y.foo2, which calls X.foo. > > If i either try to run llvm::Function::eraseFromParent() on any one of > the functions, i'll > get this assertion error: > > F is used in instruction: > %"calling function" = call i32 @X.foo(i32 %read) > F is used in instruction: > %"calling function" = call i32 @X.foo(i32 %read) > While deleting: i32 (i32)* %X.foo > Use still stuck around after Def is destroyed: %"calling function" > call i32 @X.foo(i32 %read) > mytests: Value.cpp:75: virtual llvm::Value::~Value(): Assertion > `use_empty()&& "Uses remain when a value is destroyed!"' failed. > > regardless of which one i call first. > > What is the appropiate way to delete a function from an existing module?The common idiom to delete any Value* is: V->replaceAllUsesWith(UndefValue::get(V->getType()); V->eraseFromParent(); Does that work for functions? You may need to make sure the 'undef' has a pointer to function type instead of the function type. Nick
charles quarra
2013-Mar-27 17:28 UTC
[LLVMdev] Fwd: cyclical use between caller and callee
2013/3/27 Nick Lewycky <nicholas at mxc.ca>:> charles quarra wrote: >> >> Hi, >> >> I have two functions in a module, X.foo, which is the callee, and >> Y.foo2, which calls X.foo. >> >> If i either try to run llvm::Function::eraseFromParent() on any one of >> the functions, i'll >> get this assertion error: >> >> F is used in instruction: >> %"calling function" = call i32 @X.foo(i32 %read) >> F is used in instruction: >> %"calling function" = call i32 @X.foo(i32 %read) >> While deleting: i32 (i32)* %X.foo >> Use still stuck around after Def is destroyed: %"calling function" >> call i32 @X.foo(i32 %read) >> mytests: Value.cpp:75: virtual llvm::Value::~Value(): Assertion >> `use_empty()&& "Uses remain when a value is destroyed!"' failed. >> >> >> regardless of which one i call first. >> >> What is the appropiate way to delete a function from an existing module? > > > The common idiom to delete any Value* is: > > V->replaceAllUsesWith(UndefValue::get(V->getType()); > V->eraseFromParent(); > > Does that work for functions? You may need to make sure the 'undef' has a > pointer to function type instead of the function type. >I just tried this, passing the type returned by llvm::Function::getType(), but i get this assertion failure: %"calling function" = call i32 @X.foo(i32 %read) F is used in instruction: %"calling function" = call i32 @X.foo(i32 %read) mytests: /home/charlesq/third_party/llvm-3.1.src/include/llvm/ADT/ValueMap.h:220: void llvm::ValueMapCallbackVH<KeyT, ValueT, Config>::allUsesReplacedWith(llvm::Value*) [with KeyT = const llvm::Function*; ValueT = {anonymous}::JITEmitter::EmittedCode; Config = {anonymous}::JITEmitter::EmittedFunctionConfig]: Assertion `isa<KeySansPointerT>(new_key) && "Invalid RAUW on key of ValueMap<>"' failed. how do i pass a type for the uses such that isa<KeySansPointerT>?
Possibly Parallel Threads
- [LLVMdev] cyclical dependence between caller and callee in JIT
- [LLVMdev] Fwd: cyclical use between caller and callee
- [LLVMdev] cyclical use between caller and callee
- [LLVMdev] compile error when using overloaded = operator of DenseMap
- [LLVMdev] compile error when using overloaded = operator of DenseMap