[PATCH] D107133: [AVR] emit `MCSA_Global` references to `__do_global_ctors` and `__do_global_dtors`

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 3 21:05:29 PDT 2021


MaskRay added a comment.

If GCC does emit `__do_global_ctors`, having parity is fine.

If AVR supports COMDAT, make sure you test the case when the third field references a function in a comdat.



================
Comment at: llvm/lib/Target/AVR/AVRAsmPrinter.cpp:203
+    OutStreamer->emitRawComment(
+        " Emitting these symbol references causes us to link the libgcc code"
+        " that runs our constructors/destructors.");
----------------
delete period


================
Comment at: llvm/lib/Target/AVR/AVRAsmPrinter.cpp:207
+    MCSymbol *CtorsSym = OutContext.getOrCreateSymbol("__do_global_ctors");
+    CtorsSym->setExternal(true);
+    OutStreamer->emitSymbolAttribute(CtorsSym, MCSA_Global);
----------------
delete

ELF doesn't need setExternal


================
Comment at: llvm/test/CodeGen/AVR/ctors.ll:11
+
+; CHECK: .globl __do_global_ctors
+ at llvm.global_ctors = appending global [1 x { i32, void () addrspace(1)*, i8* }] [{ i32, void () addrspace(1)*, i8* } { i32 65535, void () addrspace(1)* @do_nothing, i8* null }]
----------------
This is insufficient. It should additionally check whether the label is defined.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D107133/new/

https://reviews.llvm.org/D107133



More information about the llvm-commits mailing list