An asserting value handle still pointed to this value! (Value.cpp:633)

Hi,

When I try using eraseFromParent to delete a function declaration (use_empty), the following error was trigger:

While deleting: void (%“class.Concurrency::index”) %_ZN11Concurrency5indexILi1EE21__cxxamp_opencl_indexEv

An asserting value handle still pointed to this value!
UNREACHABLE executed at /home/pvario/cppamp/src/compiler/lib/IR/Value.cpp:633!

What could be the cause of this? Thanks in advance.

Best Regards,
Paul

This means that there's a value handle referencing that function. I recommend
looking at what's going on in a debugger.

A quick `git grep` says that in LLVM ToT there are references to `AssertingVH`
in these files:

$ git grep -l AssertingVH
include/llvm/Analysis/AliasSetTracker.h
include/llvm/Analysis/CallGraph.h
include/llvm/Analysis/ScalarEvolution.h
include/llvm/Analysis/ScalarEvolutionExpander.h
include/llvm/ExecutionEngine/ExecutionEngine.h
include/llvm/IR/IRBuilder.h
include/llvm/IR/ValueHandle.h
lib/Analysis/LazyValueInfo.cpp
lib/CodeGen/MachineModuleInfo.cpp
lib/ExecutionEngine/ExecutionEngine.cpp
lib/IR/Value.cpp
lib/Transforms/IPO/MergeFunctions.cpp
lib/Transforms/Scalar/IndVarSimplify.cpp
lib/Transforms/Scalar/JumpThreading.cpp
lib/Transforms/Scalar/Reassociate.cpp
lib/Transforms/Utils/Local.cpp
unittests/IR/ValueHandleTest.cpp
$ cd tools/clang/
$ git grep -l AssertingVH
lib/CodeGen/CGOpenMPRuntime.h
lib/CodeGen/CodeGenFunction.h

Likely, something there has an active handle to your function.