[llvm-dev] How to force unused external routine declaration into object

John Reagan via llvm-dev llvm-dev at lists.llvm.org
Wed May 6 18:29:10 PDT 2020


I'm defining an external function in the IR that has no uses at all.  No
calls, no address taken, nada.

Such an unused declaration seems to be just dropped on the floor as not
needed.  Seems reasonable in most cases.

However, one of my OpenVMS compilers (BLISS) has a language rule that
expects such definitions to get into the ELF symbol table as a way to
compel the linker to include certain object modules.

With our backend for our older targets, we had a "required_om_entry"
function attribute that told our backend to put it out regardless.

I was looking at the list of function attributes and don't see anything
that would accomplish this.

I could just create a bogus variable and initialize it with the
function's value, but that seems unsavory.

I'm still using a way old version but I'll adapt as needed.

Any suggestions?  Did I miss something?

John (safely at home with sufficient food & wine)


More information about the llvm-dev mailing list