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

Ben Shi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 1 21:11:31 PDT 2021


benshi001 added a comment.

In D107133#2918956 <https://reviews.llvm.org/D107133#2918956>, @mhjacobson wrote:

> Sure, I'm open to that.
>
> It's rare for a program not to use any global variables, whereas programs that don't use any constructor/destructor functions are pretty common.  Luckily, though, `__do_global_ctors` is pretty cheap (just a few instructions) if the constructor table is empty.
>
> So I think your suggestion would be fine.
>
> But can you explain more the reason why we don't want this state in AVRAsmPrinter?  If I'm reading correctly, the superclass, AsmPrinter, keeps mutable state, and (AFAICT) it's not unusual for other targets' AsmPrinter subclasses to keep state, either.  I'm admittedly not an expert here though, so I'd like to learn why it's a problem.
>
> Thanks!

I see your idea. It is OK to keep states in AsmPrinter. But I still would like to see if there is a unique way for all such '.globl' symbol declaration.

Maybe either temporarily put them all in `AVRTargetStreamer::finish` and add FIXMEs, or put all in `AsmPrinter` with flags ( a bit flag variable or something else)?

What about Dylan's idea?


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