Setting a function in a module to extern

Hello again,

as mentioned in a different mail, I’m a beginner with the LLVM and writing a JIT-Client under Windows.

In my llvm::Module I have a certain function – now I want to delete this function, but keep all the calls and references to it. I kind of want to set the function to an external function.

Is this possible?

Kind greetings


I think you just need to llvm::Function::Create(Type, Linkage, Name, Module) it and not add any basic blocks to it.

Boldizsár Palotás

But in my module this function already exist… I first want to delete it but without also deleting the calls to it…

You need to delete the body of the function then.



Finally I was able to test the suggestion of deleting the body. So I did:


Wit the result, that the function “hello_worldEx” disappeared completely – it was not set to an external function which I could resolve again.

“setLinkage” seems not to influence the code at all

“deleteBody” deletes the functions but also all calls to it…

So what can I do?

Kind greetings