================
@@ -1012,6 +1021,59 @@ void SystemZAsmPrinter::emitMachineConstantPoolValue(
   OutStreamer->emitValue(Expr, Size);
 }
 
+// Emit the ctor or dtor list taking into account the init priority.
+void SystemZAsmPrinter::emitXXStructorList(const DataLayout &DL,
+                                           const Constant *List, bool IsCtor) {
+  if (TM.getTargetTriple().isOSBinFormatGOFF())
+    AsmPrinter::emitXXStructorList(DL, List, IsCtor);
+
+  SmallVector<Structor, 8> Structors;
+  preprocessXXStructorList(DL, List, Structors);
+  if (Structors.empty())
+    return;
+
+  const Align Align = llvm::Align(4);
+  const TargetLoweringObjectFile &Obj = getObjFileLowering();
+  for (Structor &S : Structors) {
+    MCSection *OutputSection =
+        (IsCtor ? Obj.getStaticCtorSection(S.Priority, nullptr)
+                : Obj.getStaticDtorSection(S.Priority, nullptr));
+    OutStreamer->switchSection(OutputSection);
+    if (OutStreamer->getCurrentSection() != OutStreamer->getPreviousSection())
+      emitAlignment(Align);
+
+    const MCSectionGOFF *Section =
+        static_cast<const MCSectionGOFF *>(getCurrentSection());
+    uint32_t XtorPriority = Section->getPRAttributes().SortKey;
----------------
amy-kwan wrote:

Good question. It's technically not the same, as in the function above, the 
`Priority` is the input and it is recalculated as `Prio` prior to going into 
section with the PR attribute.

If this code sequence is unclear, would it make more sense to move the priority 
calculation into this function? Unless there are other suggestions?

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

Reply via email to