[LLVMdev] cyclical dependence between caller and callee in JIT

charles quarra charllsnotieneningunputocorreo at gmail.com
Tue Apr 2 14:04:20 PDT 2013


2013/3/27 Nick Lewycky <nicholas at mxc.ca>:
>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 tried this code sample, 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.


Apparently, the undefValue is expected to be isa<KeySansPointerT>. Are
there any examples or references about how to bring such an
undefValue?



More information about the llvm-dev mailing list