I ran into the same issue some time back
and just made all functions with ExternalLinkage,
which forced the inliner to not delete any functions
and I got my code to run.
In my interpreter, for every top level expression, I create
a wrapper function that takes no arguments and then do
EE->runFunction (just like in the tutorial). As the interaction proceeds,
these wrapper functions remain in the module, so I'd like to
delete them soon after their purpose has been fulfilled.
It looks like I should be able to call f->eraseFromParent()
on the wrapper function to get rid of it. However, if I do that,
my top level evaluator gives correct results only for the first
few calls. After the first 3 or 4 calls, the evaluation always yields
a constant! This is pretty bizzare and left me scratching my head
in disbelief, especially since there are no assert failures in
either my code or LLVM's.
I reiterate that the only difference between these "constant"
results and correct behaviour is my eraseFromParent() call.
Any tips anyone?
BTW: I'm using Function::Create() and not module->getOrInsertFunction().