================
@@ -2980,6 +2980,27 @@ bool AsmPrinter::doFinalization(Module &M) {
 
   TLOF.emitModuleMetadata(*OutStreamer, M);
 
+  // Emit raw section data from llvm.raw.sections metadata.
+  if (const NamedMDNode *RawSections =
+          M.getNamedMetadata("llvm.raw.sections")) {
----------------
steffenlarsen wrote:

> If we're going to add a new kind of metadata like this, it needs to be 
> documented in LangRef.

Documentation added to LangRef!

> Do we need some way to set section properties/flags? Whatever default we 
> choose might not apply to other scenarios.

It would definitely live up to the generalized name. I've embedded the 
`SectionKind` internal enum value into the a new field. This seems like the 
simplest solution, avoiding the need to repeat logic, though I worry that we 
are binding the SectionKind to always being an enum internally (or at least 
something we can serialize as i32.) If we are fine with this, we may want to 
specify the values inside `SectionKind::Kind` and maybe mention the dependency 
in a comment, just to avoid instability for the new metadata node.

> (I vaguely recall the Rust compiler ran into a similar situation, and they 
> solved their problem by generating a module inline assembly block.)

That is definitely another option, though it would result in much larger 
modules due to the way the bytes are encoded in sections inside inline 
assembly. That said, it would be less introdusive to LLVM, as we won't need a 
new named metadata node.

https://github.com/llvm/llvm-project/pull/214135
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to