I have a test.c file which has this function call:
functiontest(2,x);
I would like to delete this function call (with an llvm pass) and when I try to use removeFromParent() function like this:
calledFunction1->removeFromParent();
this causes LLVM to produce the following error:
Referencing function in another module!
call void @functiontest(i32 2, float %tmp15)LLVM ERROR: Broken function found, compilation aborted!
I also tried calling eraseFromParent() but this triggers an assert:
Assertion `use_empty() && "Uses remain when a value is destroyed!"' failed.
I would prefer to use removeFromParent()
Any ideas what's wrong ?
First of all, it would be really helpful if you could post a minimal code sample that demonstrates your problem. Otherwise, we can only guess. Some observations though:
removeFromParent
? The call instruction has to be deleted too, that's what eraseFromParent
does.replaceAllUsesWith
before erasing/removing? Otherwise, uses stick around.