Advise on which copy to use.

I am generating llvm code for nested procedures. Each one gets a static link,
which I am passing as an internally added, first parameter. However, it needs
to be stored in memory too, so a debugger can find it. So, when I need to use
the value, is it better to use the ssl parameter or load the memory copy?

I can imagine the ssl value might avoid unnecessary fetches, but then, it
might also sometimes result in storage of a second copy in a memory temp.

Also, do I need to do something to prevent the unused copy from being
eliminated altogether?

I’d recommend storing the link parameter in memory and loading from it at the first use in every basic block. This should give you the best variable tracking debug info after optimization, because LLVM will insert @llvm.dbg.value calls at the point of each load, and you won’t have to do that yourself.