This problem has been introduced recently in commit 8a9fc2c52f95a29d5a9ef4332880cf1c6717e18d.
If we try to specialize a callsite in module m1 that calls a function defined in module m2 where one of the actual parameters is a pointer to function foo (defined in m1), then foo can become dead in m1. However, foo can be called from m2 but if foo is removed from m1 then the linker will raise an error.
There are function attributes like OptimizeNone that in principle can avoid a function to be optimized but LLVM passes do not necessarily consider it. In fact, DCE doesn't. Instead, the solution was to mark foo as external. Unfortunately, this works only if there is not another function with same name foo in m2. In that case, we will get a linking error.
This problem has been introduced recently in commit 8a9fc2c52f95a29d5a9ef4332880cf1c6717e18d.
If we try to specialize a callsite in module
m1
that calls a function defined in modulem2
where one of the actual parameters is a pointer to functionfoo
(defined inm1
), thenfoo
can become dead inm1
. However,foo
can be called fromm2
but iffoo
is removed fromm1
then the linker will raise an error.There are function attributes like
OptimizeNone
that in principle can avoid a function to be optimized but LLVM passes do not necessarily consider it. In fact, DCE doesn't. Instead, the solution was to markfoo
asexternal
. Unfortunately, this works only if there is not another function with same namefoo
inm2
. In that case, we will get a linking error.I need to find a proper solution.