cyclical use between caller and callee

charles quarra wrote:


I have two functions in a module,, which is the callee, and
Y.foo2, which calls

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 %read)
F is used in instruction:
   %"calling function" = call i32 %read)
While deleting: i32 (i32)*
Use still stuck around after Def is destroyed: %"calling function" =
call 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:


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 %read)
F is used in instruction:
  %"calling function" = call i32 %read)
mytests: /home/charlesq/third_party/llvm-3.1.src/include/llvm/ADT/ValueMap.h:220:
void llvm::ValueMapCallbackVH<KeyT, ValueT,

::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<>"'

how do i pass a type for the uses such that isa<KeySansPointerT>?