LTO and probe-stack functions


I've been trying to fix an issue[1] where LTO is optimizing out
probe-stack functions when calls to the function are emitted by
the backend, but aren't present in the IR.

So for example if we have a function @main that has the
"probe-stack"="probestack" attribute, this tells the backend
to emit a call to probestack() when it needs to insert a stack
probe. This call is only emitted after LTO is complete, so the
LTO optimizer has no idea this function will be used in the final

What is the correct way to fix this? Do we need to change the
attributes/visibility of the probestack function, which is currently
defined as `define dso_local void @probestack() ` or should the
optimizer be checking the value of the "probe-stack' attribute and
consider any function referenced by that attribute to be used?


[1] Link failure with LLVM gold plugin when embedded bitcode is involved for e.g. probe-stack symbol · Issue #47216 · llvm/llvm-project · GitHub