[flang] [llvm] [LLVM] only add exclude metadata to ELF and COFF only (PR #80722)

Sean Fertile via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 11:17:08 PST 2024


mandlebug wrote:

>  It's an attribute in LLVM-IR, so it's perfectly legal to have in LLVM-IR. 

I disagree with this statement. The documentation for the exclude metadata node explicitly states its only valid for [ELF or COFF](https://llvm.org/docs/LangRef.html#exclude-metadata),  likewise the SectionKind the metadata node causes the global to get mapped to is commented as [only valid on ELF or COFF targets](https://github.com/llvm/llvm-project/blob/6d4ffbdfa8ff90e4ee6081ad8dbb8ec24e982a02/llvm/include/llvm/MC/SectionKind.h#L28). For XCOFF we have no reliable way to implement this - there is no flag that guarantees a section gets discarded, and individual symbols may or may not be discarded but it varies based on compile/link options and the individual symbols properties, as well as the properties of the section it gets mapped to. 

> I was mulling over whether or not it should get a warning or something if it's present on an unsupported platform when we do the lowering.

I believe `TargetLoweringObjectFileXCOFF` will emit a fatal error when trying to codegen a symbol that has a section kind of 'Exclude' although it will just say unsupported section kind. It might be nice to have a more specific error for this case explaining why the node is not supported.

https://github.com/llvm/llvm-project/pull/80722


More information about the llvm-commits mailing list